Skip to content
This repository was archived by the owner on Sep 25, 2022. It is now read-only.

Commit e517e07

Browse files
committed
1 parent 46e6291 commit e517e07

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

my-element.html

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
<script>
2-
(function() {
3-
// Creates an object based in the HTML Element prototype
4-
var element = Object.create(HTMLElement.prototype);
2+
// Creates MyElements extending HTML Element
3+
class MyElement extends HTMLElement {
4+
// Fires when an instance of the element is created or updated
5+
constructor() {
6+
super();
7+
}
58

6-
// Fires when an instance of the element is created
7-
element.createdCallback = function() {};
9+
// Fires when an instance was inserted into the document
10+
connectedCallback() {
11+
}
812

9-
// Fires when an instance was inserted into the document
10-
element.attachedCallback = function() {};
13+
// Fires when an instance was removed from the document
14+
disconnectedCallback() {
15+
}
1116

12-
// Fires when an instance was removed from the document
13-
element.detachedCallback = function() {};
17+
attributeChangedCallback(attrName, oldVal, newVal) {
18+
}
1419

15-
// Fires when an attribute was added, removed, or updated
16-
element.attributeChangedCallback = function(attr, oldVal, newVal) {};
20+
// Fires when an attribute was added, removed, or updated
21+
adoptedCallback() {
22+
}
23+
}
1724

1825
// Registers custom element
19-
document.registerElement('my-element', {
20-
prototype: element
21-
});
22-
}());
26+
window.customElements.define('my-element', MyElement);
2327
</script>

0 commit comments

Comments
 (0)