parcoursup/node_modules/riot/esm/core/create-attribute-bindings.js
lalBi94 7bc56c09b5 $
2023-03-05 13:23:23 +01:00

28 lines
839 B
JavaScript

/* 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 };