| OLD | NEW |
| 1 function createShadowRoot() | 1 function createShadowRoot() |
| 2 { | 2 { |
| 3 return {'isShadowRoot': true, | 3 return {'isShadowRoot': true, |
| 4 'children': Array.prototype.slice.call(arguments)}; | 4 'children': Array.prototype.slice.call(arguments)}; |
| 5 } | 5 } |
| 6 | 6 |
| 7 function createShadowRootWithAttributes(attributes, children) | 7 function createShadowRootWithAttributes(attributes, children) |
| 8 { | 8 { |
| 9 return {'isShadowRoot': true, | 9 return {'isShadowRoot': true, |
| 10 'attributes': attributes, | 10 'attributes': attributes, |
| 11 'children': children}; | 11 'children': children}; |
| 12 } | 12 } |
| 13 | 13 |
| 14 // This function can take optional child elements, which might be a result of cr
eateShadowRoot(), as arguments[2:]. | 14 // This function can take optional child elements, which might be a result of cr
eateShadowRoot(), as arguments[2:]. |
| 15 // You must enable SHADOW_DOM flag if you use this fucntion to host multiple Sha
dowRoots | 15 // You must enable SHADOW_DOM flag if you use this fucntion to host multiple Sha
dowRoots |
| 16 // since window.internals does not have a function which can be used to host mul
tiple shadow roots. | 16 // since window.internals does not have a function which can be used to host mul
tiple shadow roots. |
| 17 // FIXME: window.internals should have such function and remove the restriction. | 17 // FIXME: window.internals should have such function and remove the restriction. |
| 18 function createDOM(tagName, attributes) | 18 function createDOM(tagName, attributes) |
| 19 { | 19 { |
| 20 var element = document.createElement(tagName); | 20 var element = document.createElement(tagName); |
| 21 for (var name in attributes) | 21 for (var name in attributes) |
| 22 element.setAttribute(name, attributes[name]); | 22 element.setAttribute(name, attributes[name]); |
| 23 var childElements = Array.prototype.slice.call(arguments, 2); | 23 var childElements = Array.prototype.slice.call(arguments, 2); |
| 24 var shadowRootCount = 0; | 24 var shadowRootCount = 0; |
| 25 for (var i = 0; i < childElements.length; ++i) { | 25 for (var i = 0; i < childElements.length; ++i) { |
| 26 var child = childElements[i]; | 26 var child = childElements[i]; |
| 27 if (child.isShadowRoot) { | 27 if (child.isShadowRoot) { |
| 28 ++shadowRootCount; | 28 ++shadowRootCount; |
| 29 var shadowRoot; | 29 var shadowRoot = element.webkitCreateShadowRoot(element); |
| 30 if (element.webkitCreateShadowRoot) | |
| 31 shadowRoot = element.webkitCreateShadowRoot(element); | |
| 32 else | |
| 33 shadowRoot = internals.createShadowRoot(element); | |
| 34 if (child.attributes) { | 30 if (child.attributes) { |
| 35 for (var attribute in child.attributes) { | 31 for (var attribute in child.attributes) { |
| 36 // Shadow Root does not have setAttribute. | 32 // Shadow Root does not have setAttribute. |
| 37 shadowRoot[attribute] = child.attributes[attribute]; | 33 shadowRoot[attribute] = child.attributes[attribute]; |
| 38 } | 34 } |
| 39 } | 35 } |
| 40 for (var j = 0; j < child.children.length; ++j) | 36 for (var j = 0; j < child.children.length; ++j) |
| 41 shadowRoot.appendChild(child.children[j]); | 37 shadowRoot.appendChild(child.children[j]); |
| 42 } else | 38 } else |
| 43 element.appendChild(child); | 39 element.appendChild(child); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 { | 158 { |
| 163 for (var i = 0; i + 1 < elements.length; ++i) | 159 for (var i = 0; i + 1 < elements.length; ++i) |
| 164 shouldNavigateFocus(elements[i], elements[i + 1], 'forward'); | 160 shouldNavigateFocus(elements[i], elements[i + 1], 'forward'); |
| 165 } | 161 } |
| 166 | 162 |
| 167 function testFocusNavigationBackward(elements) | 163 function testFocusNavigationBackward(elements) |
| 168 { | 164 { |
| 169 for (var i = 0; i + 1 < elements.length; ++i) | 165 for (var i = 0; i + 1 < elements.length; ++i) |
| 170 shouldNavigateFocus(elements[i], elements[i + 1], 'backward'); | 166 shouldNavigateFocus(elements[i], elements[i + 1], 'backward'); |
| 171 } | 167 } |
| OLD | NEW |