OLD | NEW |
1 function createShadowRoot() | 1 function createShadowRoot() |
2 { | 2 { |
3 var children = Array.prototype.slice.call(arguments); | 3 var children = Array.prototype.slice.call(arguments); |
4 if ((children[0] instanceof Object) && !(children[0] instanceof Node)) | 4 if ((children[0] instanceof Object) && !(children[0] instanceof Node)) |
5 return attachShadow.apply(null, children); | 5 return attachShadow.apply(null, children); |
6 return {'isShadowRoot': true, | 6 return {'isShadowRoot': true, |
7 'children': children}; | 7 'children': children}; |
8 } | 8 } |
9 | 9 |
10 // TODO(kochi): This is not pure attachShadow wrapper, but also handles createSh
adowRoot() | 10 // TODO(kochi): This is not pure attachShadow wrapper, but also handles createSh
adowRoot() |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 var template = nodes[i]; | 88 var template = nodes[i]; |
89 var mode = template.getAttribute("data-mode"); | 89 var mode = template.getAttribute("data-mode"); |
90 var parent = template.parentNode; | 90 var parent = template.parentNode; |
91 parent.removeChild(template); | 91 parent.removeChild(template); |
92 var shadowRoot; | 92 var shadowRoot; |
93 if (!mode) { | 93 if (!mode) { |
94 shadowRoot = parent.createShadowRoot(); | 94 shadowRoot = parent.createShadowRoot(); |
95 } else { | 95 } else { |
96 shadowRoot = parent.attachShadow({'mode': mode}); | 96 shadowRoot = parent.attachShadow({'mode': mode}); |
97 } | 97 } |
| 98 var expose = template.getAttribute("data-expose-as"); |
| 99 if (expose) |
| 100 window[expose] = shadowRoot; |
98 if (template.id) | 101 if (template.id) |
99 shadowRoot.id = template.id; | 102 shadowRoot.id = template.id; |
100 var fragments = document.importNode(template.content, true); | 103 var fragments = document.importNode(template.content, true); |
101 shadowRoot.appendChild(fragments); | 104 shadowRoot.appendChild(fragments); |
102 | 105 |
103 convertTemplatesToShadowRootsWithin(shadowRoot); | 106 convertTemplatesToShadowRootsWithin(shadowRoot); |
104 } | 107 } |
105 } | 108 } |
106 | 109 |
107 function isShadowHost(node) | 110 function isShadowHost(node) |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 return node; | 354 return node; |
352 } | 355 } |
353 | 356 |
354 return null; | 357 return null; |
355 }; | 358 }; |
356 | 359 |
357 if (!window.internals) | 360 if (!window.internals) |
358 return null; | 361 return null; |
359 return iter(root, id); | 362 return iter(root, id); |
360 } | 363 } |
OLD | NEW |