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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 function convertTemplatesToShadowRootsWithin(node) { | 85 function convertTemplatesToShadowRootsWithin(node) { |
86 var nodes = node.querySelectorAll("template"); | 86 var nodes = node.querySelectorAll("template"); |
87 for (var i = 0; i < nodes.length; ++i) { | 87 for (var i = 0; i < nodes.length; ++i) { |
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 || mode == 'v0'){ |
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"); | 98 var expose = template.getAttribute("data-expose-as"); |
99 if (expose) | 99 if (expose) |
100 window[expose] = shadowRoot; | 100 window[expose] = shadowRoot; |
101 if (template.id) | 101 if (template.id) |
102 shadowRoot.id = template.id; | 102 shadowRoot.id = template.id; |
103 var fragments = document.importNode(template.content, true); | 103 var fragments = document.importNode(template.content, true); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 return node; | 354 return node; |
355 } | 355 } |
356 | 356 |
357 return null; | 357 return null; |
358 }; | 358 }; |
359 | 359 |
360 if (!window.internals) | 360 if (!window.internals) |
361 return null; | 361 return null; |
362 return iter(root, id); | 362 return iter(root, id); |
363 } | 363 } |
OLD | NEW |