@laco0416
class MyElement extends HTMLElement {
constructor() {
super();
}
}
customElements.define("my-element", MyElement);
Custom Elements v1
const container = document.getElementById('shadow-container');
container.attachShadow({mode: 'open'});
Shadow DOM v1
class MyElement extends Polymer.Element {
static get is() { return ‘my-element’; }
static get config() {
properties: {
//the properties you know and love from Polymer
},
observers: [
//the observers you know and love from Polymer
]
}
constructor() {
super();
…
}
}
customElements.define(MyElement.is, MyElement);
skate.define('x-counter', {
props: {
count: skate.prop.number(),
},
attached(elem) {
elem.__ival = setInterval(() => ++elem.count, 1000);
},
detached(elem) {
clearInterval(elem.__ival);
},
render(elem) {
return <span>Count: {elem.count}</span>;
},
});