Cleaned up code, added support for lists, classes, attributes, and more. Added more test code, everything appears to be working. More cleanup and testing is needed.
This commit is contained in:
50
src/ignite-element.js
Normal file
50
src/ignite-element.js
Normal file
@ -0,0 +1,50 @@
|
||||
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
|
||||
};
|
Reference in New Issue
Block a user