forked from dannybrian/nfjs-polymer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-custom-example.html
More file actions
51 lines (42 loc) · 1.25 KB
/
Copy path2-custom-example.html
File metadata and controls
51 lines (42 loc) · 1.25 KB
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
41
42
43
44
45
46
47
48
49
50
<style>
our-test {
color: red;
}
[type="himom"] {
font-weight: bold;
}
</style>
<our-test type="himom">
<p>The content!</p>
</our-test>
<script>
// extend HTMLElement with our own prototype
var ourProto = Object.create(HTMLElement.prototype);
// give our prototype a callback to create our shadow root
// and populate it with content
ourProto.createdCallback = function() {
// var root = this.createShadowRoot();
// root.appendChild(document.importNode(template.content, true));
console.log("created");
};
ourProto.attachedCallback = function() {
// called when element is inserted into the DOM
// good place to add event listeners
console.log("attached");
};
ourProto.detachedCallback = function() {
// called when element is removed from the DOM
// good place to remove event listeners
console.log("detached");
};
ourProto.attributeChangedCallback = function(name, oldVal, newVal) {
// make changes based on attribute changes
console.log("attribute changed");
};
// Add a public method
ourProto.doSomething = function() { };
// register the custom element
var ourElement = document.registerElement('our-test', {
prototype: ourProto
});
</script>