@riotjs/util
Advanced tools
Comparing version 1.0.0 to 1.1.0
30
misc.js
@@ -1,2 +0,2 @@ | ||
import {createExpression, expressionTypes} from '@riotjs/dom-bindings' | ||
import {ATTRIBUTE, VALUE} from './expression-types' | ||
import {dashToCamelCase} from './strings' | ||
@@ -14,26 +14,2 @@ | ||
/** | ||
* Create the bindings to update the component attributes | ||
* @param {HTMLElement} node - node where we will bind the expressions | ||
* @param {Array} attributes - list of attribute bindings | ||
* @returns {TemplateChunk} - template bindings object | ||
*/ | ||
export function createAttributeBindings(node, attributes = []) { | ||
const expressions = attributes.map(a => createExpression(node, a)) | ||
const binding = {} | ||
const updateValues = method => scope => { | ||
expressions.forEach(e => e[method](scope)) | ||
return binding | ||
} | ||
return Object.assign(binding, { | ||
expressions, | ||
mount: updateValues('mount'), | ||
update: updateValues('update'), | ||
unmount: updateValues('unmount') | ||
}) | ||
} | ||
/** | ||
* Evaluate a list of attribute expressions | ||
@@ -49,3 +25,3 @@ * @param {Array} attributes - attribute expressions generated by the riot compiler | ||
// spread attribute | ||
case !attribute.name && type === expressionTypes.ATTRIBUTE: | ||
case !attribute.name && type === ATTRIBUTE: | ||
return { | ||
@@ -56,3 +32,3 @@ ...acc, | ||
// value attribute | ||
case type === expressionTypes.VALUE: | ||
case type === VALUE: | ||
acc.value = attribute.value | ||
@@ -59,0 +35,0 @@ break |
{ | ||
"name": "@riotjs/util", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Riot.js util functions", | ||
@@ -16,2 +16,4 @@ "scripts": { | ||
"checks.js", | ||
"expression-types.js", | ||
"binding-types.js", | ||
"misc.js" | ||
@@ -35,3 +37,2 @@ ], | ||
"devDependencies": { | ||
"@riotjs/dom-bindings": "^4.3.0", | ||
"chai": "^4.2.0", | ||
@@ -38,0 +39,0 @@ "eslint": "^6.4.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7
11
10835