-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhsnbd-hello-world.js
40 lines (33 loc) · 995 Bytes
/
hsnbd-hello-world.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class HsnbdHelloWorld extends HTMLElement {
constructor() {
super();
const _style = document.createElement('style');
const _template = document.createElement('template');
_style.innerHTML = `
h1 {
color: tomato;
}
`;
_template.innerHTML = `
<h1>
Hello world. This is my first custom element
</h1>
`;
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(_style);
this.shadowRoot.appendChild(_template.content.cloneNode(true));
}
static get observedAttributes() {
return ["theme"];
}
attributeChangedCallback(name, oldVal, newVal) {
console.table({name, oldVal, newVal});
}
connectedCallback() {
console.log("Element added to the dom");
}
disconnectedCallback() {
console.log("Element removed from dom")
}
}
window.customElements.define('hsnbd-hello-world', HsnbdHelloWorld);