UNPKG

mframejs

Version:
44 lines 2.2 kB
Object.defineProperty(exports, "__esModule", { value: true }); var exported_1 = require("../container/exported"); var attributeController_1 = require("./attributeController"); var interpolateController_1 = require("./interpolateController"); function addAttribute(htmlNode, bindingContext, attributeName, value, viewController, autoAttach) { autoAttach = autoAttach === undefined ? true : autoAttach; var arr = []; if (htmlNode.getAttribute) { htmlNode.setAttribute(attributeName, value); var attributeNode = htmlNode.getAttributeNode(attributeName); var customAttribute = exported_1.ContainerAttributes.findAttribute(attributeNode.name); if (!customAttribute && attributeNode.name) { customAttribute = exported_1.ContainerAttributes.findAttribute(attributeNode.name.replace('.bind', '')); if (!customAttribute && attributeNode.name) { customAttribute = exported_1.ContainerAttributes.findAttribute(attributeNode.name.replace(/([@a-z]\w+\.)/g, '#VARIABLE#')); } } if (customAttribute) { var instance = new attributeController_1.AttributeController(bindingContext, htmlNode, attributeNode, customAttribute, viewController); instance.init(); if (instance) { if (autoAttach) { instance.attached(); } arr.push(instance); } } else { if (attributeNode.value.indexOf('${') !== -1 || attributeNode.value.indexOf('@{') !== -1) { if (attributeNode.name.indexOf('.bind') === -1) { var interpolateController = new interpolateController_1.InterpolateController(bindingContext, attributeNode, viewController, true); interpolateController.init(); if (autoAttach) { interpolateController.attached(); } arr.push(interpolateController); } } } } return arr; } exports.addAttribute = addAttribute; //# sourceMappingURL=addAttribute.js.map