| 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 var attributes = {}; |
| 6 var parameter = {}; |
| 7 for (var key in children[0]) { |
| 8 if (key == 'mode') |
| 9 parameter[key] = children[0][key]; |
| 10 else |
| 11 attributes[key] = children[0][key]; |
| 12 } |
| 5 return {'isShadowRoot': true, | 13 return {'isShadowRoot': true, |
| 6 'attributes': children[0], | 14 'parameter': parameter, |
| 15 'attributes': attributes, |
| 7 'children': children.slice(1)}; | 16 'children': children.slice(1)}; |
| 17 } |
| 8 return {'isShadowRoot': true, | 18 return {'isShadowRoot': true, |
| 9 'children': children}; | 19 'children': children}; |
| 10 } | 20 } |
| 11 | 21 |
| 12 function createUserAgentShadowRoot() | 22 function createUserAgentShadowRoot() |
| 13 { | 23 { |
| 14 var shadowRoot = createShadowRoot.apply(null, arguments); | 24 var shadowRoot = createShadowRoot.apply(null, arguments); |
| 15 shadowRoot.isUserAgentShadowRoot = true; | 25 shadowRoot.isUserAgentShadowRoot = true; |
| 16 return shadowRoot; | 26 return shadowRoot; |
| 17 } | 27 } |
| 18 | 28 |
| 19 // This function can take optional child elements, which might be a result of cr
eateShadowRoot(), as arguments[2:]. | 29 // This function can take optional child elements, which might be a result of cr
eateShadowRoot(), as arguments[2:]. |
| 20 function createDOM(tagName, attributes) | 30 function createDOM(tagName, attributes) |
| 21 { | 31 { |
| 22 var element = document.createElement(tagName); | 32 var element = document.createElement(tagName); |
| 23 for (var name in attributes) | 33 for (var name in attributes) |
| 24 element.setAttribute(name, attributes[name]); | 34 element.setAttribute(name, attributes[name]); |
| 25 var childElements = Array.prototype.slice.call(arguments, 2); | 35 var childElements = Array.prototype.slice.call(arguments, 2); |
| 26 for (var i = 0; i < childElements.length; ++i) { | 36 for (var i = 0; i < childElements.length; ++i) { |
| 27 var child = childElements[i]; | 37 var child = childElements[i]; |
| 28 if (child.isShadowRoot) { | 38 if (child.isShadowRoot) { |
| 29 var shadowRoot; | 39 var shadowRoot; |
| 30 if (child.isUserAgentShadowRoot) { | 40 if (child.isUserAgentShadowRoot) { |
| 31 shadowRoot = window.internals.createUserAgentShadowRoot(element)
; | 41 shadowRoot = window.internals.createUserAgentShadowRoot(element)
; |
| 32 } else { | 42 } else { |
| 33 shadowRoot = element.createShadowRoot(); | 43 if (child.parameter && Object.keys(child.parameter).length > 0) |
| 44 shadowRoot = element.createShadowRoot(child.parameter); |
| 45 else |
| 46 shadowRoot = element.createShadowRoot(); |
| 34 } | 47 } |
| 35 if (child.attributes) { | 48 if (child.attributes) { |
| 36 for (var attribute in child.attributes) { | 49 for (var attribute in child.attributes) { |
| 37 // Shadow Root does not have setAttribute. | 50 // Shadow Root does not have setAttribute. |
| 38 shadowRoot[attribute] = child.attributes[attribute]; | 51 shadowRoot[attribute] = child.attributes[attribute]; |
| 39 } | 52 } |
| 40 } | 53 } |
| 41 for (var j = 0; j < child.children.length; ++j) | 54 for (var j = 0; j < child.children.length; ++j) |
| 42 shadowRoot.appendChild(child.children[j]); | 55 shadowRoot.appendChild(child.children[j]); |
| 43 } else | 56 } else |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 debug('Traverse in backward.'); | 272 debug('Traverse in backward.'); |
| 260 showComposedShadowTreeByTraversingInBackward(node); | 273 showComposedShadowTreeByTraversingInBackward(node); |
| 261 | 274 |
| 262 debug(''); | 275 debug(''); |
| 263 } | 276 } |
| 264 | 277 |
| 265 function showNextNode(node) { | 278 function showNextNode(node) { |
| 266 var next = internals.nextInComposedTree(node); | 279 var next = internals.nextInComposedTree(node); |
| 267 debug('Next node of [' + dumpNode(node) + '] is [' + dumpNode(next) + ']'); | 280 debug('Next node of [' + dumpNode(node) + '] is [' + dumpNode(next) + ']'); |
| 268 } | 281 } |
| OLD | NEW |