OLD | NEW |
1 SKY MODULE - defines an <element> element | 1 SKY MODULE - defines an <element> element |
2 <import src="sky:core" as="sky"/> | 2 <import src="sky:core" as="sky"/> |
3 | 3 |
4 <!-- usage: | 4 <!-- usage: |
5 | 5 |
6 <element name="tagname"> | 6 <element name="tagname"> |
7 <style> style here (optional) </style> | 7 <style> style here (optional) </style> |
8 <template> shadow tree here (optional) </template> | 8 <template> shadow tree here (optional) </template> |
9 <script> // optional | 9 <script> // optional |
10 module.currentScript.parentNode.setPrototype({ | 10 module.currentScript.parentNode.setPrototype({ |
11 init: function () { | 11 init: function () { |
12 // constructor here | 12 // constructor here |
13 }, | 13 }, |
14 // rest of api here | 14 // rest of api here |
15 }); | 15 }); |
16 </script> | 16 </script> |
17 </element> | 17 </element> |
18 | 18 |
19 --> | 19 --> |
20 | 20 |
21 <script> | 21 <script> |
22 module.exports.Element = sky.registerElement({ | 22 module.exports.Element = sky.registerElement({ |
23 tagName: 'element', | 23 tagName: 'element', |
24 prototype: class extends Element { | 24 constructor: class extends Element { |
25 constructor (module) { | 25 constructor (module) { |
26 super(); | 26 super(); |
27 this.state = 'loading'; | 27 this.state = 'loading'; |
28 this.module = module; | 28 this.module = module; |
29 this.definedPrototype = sky.Element; | 29 this.definedPrototype = sky.Element; |
30 } | 30 } |
31 setPrototype(prototype) { | 31 setPrototype(prototype) { |
32 this.definedPrototype = prototype; | 32 this.definedPrototype = prototype; |
33 } | 33 } |
34 endTagParsedCallback() { | 34 endTagParsedCallback() { |
(...skipping 28 matching lines...) Expand all Loading... |
63 shadow: style || template, | 63 shadow: style || template, |
64 constructor: constructor, | 64 constructor: constructor, |
65 }); | 65 }); |
66 delete this.definedPrototype; | 66 delete this.definedPrototype; |
67 delete this.module; | 67 delete this.module; |
68 this.state = 'loaded'; | 68 this.state = 'loaded'; |
69 } | 69 } |
70 }, | 70 }, |
71 }); | 71 }); |
72 </script> | 72 </script> |
OLD | NEW |