OLD | NEW |
1 <!-- | 1 <!-- |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 --> | 5 --> |
6 <import src="TemplateBinding.sky" /> | 6 <import src="TemplateBinding.sky" /> |
7 <script> | 7 <script> |
8 var templates = new Map(); | 8 var templates = new Map(); |
9 | 9 |
10 function createPrototype(proto, definition) { | 10 function createPrototype(proto, definition) { |
(...skipping 13 matching lines...) Expand all Loading... |
24 }, | 24 }, |
25 | 25 |
26 created: function() { | 26 created: function() { |
27 // override | 27 // override |
28 }, | 28 }, |
29 | 29 |
30 attachedCallback: function() { | 30 attachedCallback: function() { |
31 if (!this.shadowRoot) { | 31 if (!this.shadowRoot) { |
32 var template = templates.get(this.localName); | 32 var template = templates.get(this.localName); |
33 if (template) { | 33 if (template) { |
34 var shadow = this.createShadowRoot(); | 34 var shadow = this.ensureShadowRoot(); |
35 shadow.appendChild(template.createInstance(this)); | 35 shadow.appendChild(template.createInstance(this)); |
36 } | 36 } |
37 } | 37 } |
38 this.attached(); | 38 this.attached(); |
39 }, | 39 }, |
40 | 40 |
41 attached: function() { | 41 attached: function() { |
42 // override | 42 // override |
43 }, | 43 }, |
44 | 44 |
(...skipping 20 matching lines...) Expand all Loading... |
65 if (template && template.localName === 'template') | 65 if (template && template.localName === 'template') |
66 templates.set(prototype.name, template); | 66 templates.set(prototype.name, template); |
67 | 67 |
68 document.registerElement(prototype.name, { | 68 document.registerElement(prototype.name, { |
69 prototype: createPrototype(BasePrototype, prototype), | 69 prototype: createPrototype(BasePrototype, prototype), |
70 }); | 70 }); |
71 }; | 71 }; |
72 | 72 |
73 module.exports = SkyElement; | 73 module.exports = SkyElement; |
74 </script> | 74 </script> |
OLD | NEW |