Base implementation of custom element.
Type in your console:
npm i @diax-js/custom-element
Component definition:
import {Element} from '@diax-js/custom-element'
import { attachListener } from '@diax/context/host';
@Element('my-element')
class MyElement {
name = 'My Element'
constructor() {
attachEventLister('dbclick', () => {
this.alert();
})
}
alert() {
alert(this.name);
}
}
import {getElementClass} from '@diax-js/custom-element';
class MyElement {
... as above
}
const HTMLCtor = getElementClass(MyElement);
customElements.define('my-element', HTMLCtor);
<my-element>
Double click me
</my-element>