parcoursup/node_modules/riot/esm/core/create-attribute-bindings.js

28 lines
839 B
JavaScript
Raw Normal View History

2023-03-05 13:23:23 +01:00
/* Riot WIP, @license MIT */
import { createCoreAPIMethods } from './create-core-api-methods.js';
import { createExpression } from '@riotjs/dom-bindings';
/**
* 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
*/
function createAttributeBindings(node, attributes) {
if (attributes === void 0) {
attributes = [];
}
const expressions = attributes.map(a => createExpression(node, a));
const binding = {};
return Object.assign(binding, Object.assign({
expressions
}, createCoreAPIMethods(method => scope => {
expressions.forEach(e => e[method](scope));
return binding;
})));
}
export { createAttributeBindings };