UNPKG

mframejs

Version:
79 lines 3.26 kB
import * as tslib_1 from "tslib"; import { customAttribute } from '../decorator/exported'; import { BindingEngine } from '../binding/exported'; let MiscAttributes = class MiscAttributes { created() { this.value = this.$attribute.value; this.name = this.$attribute.name.replace('.bind', ''); this.init = true; this.subscribeInternal = { name: this.name + 'Attribute(misc)', value: this.value, call: (newValue, oldValue) => { if (oldValue !== newValue || this.init) { this.init = false; switch (this.name) { case 'readonly': if (newValue) { this.$element.readOnly = newValue; } else { this.$element.removeAttribute(this.name); } break; case 'src': if (newValue) { this.$element.src = newValue; } else { this.$element.removeAttribute(this.name); } break; case 'disabled': if (newValue) { this.$element.disabled = newValue; } else { this.$element.removeAttribute(this.name); } break; case 'class': if (newValue) { this.$element.className = newValue; } else { this.$element.className = ''; } break; case 'show': if (newValue) { this.$element.style['display'] = 'block'; } else { this.$element.style['display'] = 'none'; } break; default: this.$element.setAttribute(this.name, newValue); } } } }; BindingEngine.subscribeClassProperty(this.$bindingContext, this.value, this.subscribeInternal); } detached() { BindingEngine.unSubscribeClassProperty(this.$bindingContext, this.subscribeInternal); } attached() { this.$element.removeAttribute(this.$attribute.name); } }; MiscAttributes = tslib_1.__decorate([ customAttribute('readonly.bind'), customAttribute('disabled.bind'), customAttribute('show.bind'), customAttribute('class.bind'), customAttribute('src.bind') ], MiscAttributes); export { MiscAttributes }; //# sourceMappingURL=miscAttribute.js.map