ignite-html/src/ignite-element.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

import { IgniteProperty } from './ignite-html.js';
import { IgniteTemplate } from './ignite-template.js';
class IgniteElement extends HTMLElement {
constructor() {
super();
this.template = null;
this.createProperties();
}
properties() {
return [];
}
createProperties() {
var props = this.properties();
for (var i = 0; i < props.length; i++) {
this[`_${props[i]}`] = new IgniteProperty();
((propName) => {
Object.defineProperty(this, propName, {
get: function () {
return this[`_${propName}`];
},
set: function (value) {
this[`_${propName}`].value = value;
}
});
})(props[i]);
}
}
connectedCallback() {
this.template = new IgniteTemplate();
this.template.element = this;
this.render().construct(this);
}
render() {
return null;
}
}
export {
IgniteElement
};