UNPKG

mframejs

Version:
52 lines 2.17 kB
Object.defineProperty(exports, "__esModule", { value: true }); var exported_1 = require("../binding/exported"); var exported_2 = require("../utils/exported"); var SubscribeInternal = (function () { function class_1(node) { this.firstRun = true; this.name = 'Interpolate'; this.node = node; } class_1.prototype.call = function (newValue, oldValue) { if (oldValue !== newValue || this.firstRun) { this.firstRun = false; if (this.node.nodeType === 2) { this.node.value = newValue; } else { this.node.data = newValue; } } }; return class_1; }()); var InterpolateController = (function () { function InterpolateController(bindingContext, htmlNode, viewController, _isAttributeValue) { this.bindingContext = bindingContext; this.htmlNode = htmlNode; this.isAttibuteNode = false; if (!htmlNode.data) { this.isAttibuteNode = true; } this.logger = exported_2.Logger.getLogger(this.isAttibuteNode ? htmlNode.value.trim() : htmlNode.data.trim(), 'interpolate'); viewController.addInterpolate(this); } InterpolateController.prototype.init = function () { this.logger.log('init'); this.subscribeInternal = new SubscribeInternal(this.htmlNode); exported_1.BindingEngine.subscribeClassProperty(this.bindingContext, this.isAttibuteNode ? this.htmlNode.value : this.htmlNode.data, this.subscribeInternal); }; InterpolateController.prototype.attached = function () { this.logger.log('attached'); }; InterpolateController.prototype.detached = function () { this.logger.log('detached'); exported_1.BindingEngine.unSubscribeClassProperty(this.bindingContext, this.subscribeInternal); this.subscribeInternal = null; this.bindingContext = null; this.htmlNode = null; }; return InterpolateController; }()); exports.InterpolateController = InterpolateController; //# sourceMappingURL=interpolateController.js.map