UNPKG

vasille

Version:

The first Developer eXperience Orientated front-end framework (core library).

31 lines (30 loc) 859 B
import { Binding } from "./binding.js"; /** * Represents an Attribute binding description * @class AttributeBinding * @extends Binding */ export class AttributeBinding extends Binding { /** * Constructs an attribute binding description * @param node {INode} the vasille node * @param name {String} the name of attribute * @param value {IValue} value to bind */ constructor(node, name, value) { super(value); this.init((value) => { if (value) { if (typeof value === "boolean") { node.element.setAttribute(name, ""); } else { node.element.setAttribute(name, `${value}`); } } else { node.element.removeAttribute(name); } }); } }