UNPKG

mframejs

Version:
65 lines 2.66 kB
import { ViewController } from './viewController'; import { ContainerClasses } from '../container/exported'; import { BindingEngine } from '../binding/exported'; import { Logger } from '../utils/exported'; export class AttributeController { constructor(bindingContext, htmlNode, attributeNode, attributeName, viewController) { this.bindingContext = bindingContext; this.htmlNode = htmlNode; this.attributeNode = attributeNode; this.logger = Logger.getLogger(attributeNode.name, 'attribute'); this.classInstance = ContainerClasses.get(attributeName); this.htmlNode = htmlNode; if (attributeNode.name === 'if.bind' || attributeNode.name === 'repeat.for') { this.viewController = new ViewController(htmlNode, viewController); this.viewController.addAttribute(this); } else { viewController.addAttribute(this); this.viewController = viewController; } } init() { this.create(); } searchForInstance(_customElement) { return this.viewController.searchForInstance(_customElement); } getView() { return this.viewController; } create() { this.logger.log('created', this.attributeNode.name, this.attributeNode.value); this.classInstance.$element = this.htmlNode; this.classInstance.$bindingContext = this.bindingContext; this.classInstance.$attribute = this.attributeNode; this.classInstance.$controller = this; BindingEngine.subscribeClassMetaBinding(this.classInstance); if (this.classInstance.created) { this.classInstance.created(); } } attached() { this.logger.log('attached', this.attributeNode.name, this.attributeNode.value); if (this.classInstance.attached) { this.classInstance.attached(); } } detached() { this.logger.log('detached', this.attributeNode.name, this.attributeNode.value); if (this.classInstance.detached) { this.classInstance.detached(); } BindingEngine.unSubscribeClassMetaBinding(this.classInstance); this.bindingContext = null; this.htmlNode = null; this.attributeNode = null; this.classInstance.$element = null; this.classInstance.$bindingContext = null; this.classInstance.$attribute = null; this.classInstance.$controller = null; this.classInstance = null; this.viewController = null; } } //# sourceMappingURL=attributeController.js.map