Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: third_party/WebKit/LayoutTests/shadow-dom/resources/shadow-dom.js

Issue 2432293002: Fix focus navigation for nested slot case (Closed)
Patch Set: More references Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 function removeWhiteSpaceOnlyTextNodes(node) 1 function removeWhiteSpaceOnlyTextNodes(node)
2 { 2 {
3 for (var i = 0; i < node.childNodes.length; i++) { 3 for (var i = 0; i < node.childNodes.length; i++) {
4 var child = node.childNodes[i]; 4 var child = node.childNodes[i];
5 if (child.nodeType === Node.TEXT_NODE && child.nodeValue.trim().length == 0) { 5 if (child.nodeType === Node.TEXT_NODE && child.nodeValue.trim().length == 0) {
6 node.removeChild(child); 6 node.removeChild(child);
7 i--; 7 i--;
8 } else if (child.nodeType === Node.ELEMENT_NODE || child.nodeType === Node.D OCUMENT_FRAGMENT_NODE) { 8 } else if (child.nodeType === Node.ELEMENT_NODE || child.nodeType === Node.D OCUMENT_FRAGMENT_NODE) {
9 removeWhiteSpaceOnlyTextNodes(child); 9 removeWhiteSpaceOnlyTextNodes(child);
10 } 10 }
11 } 11 }
12 if (node.shadowRoot) { 12 if (node.shadowRoot) {
13 removeWhiteSpaceOnlyTextNodes(node.shadowRoot); 13 removeWhiteSpaceOnlyTextNodes(node.shadowRoot);
14 } 14 }
15 } 15 }
16 16
17 function convertTemplatesToShadowRootsWithin(node) { 17 function convertTemplatesToShadowRootsWithin(node) {
18 var nodes = node.querySelectorAll("template"); 18 var nodes = node.querySelectorAll("template");
19 for (var i = 0; i < nodes.length; ++i) { 19 for (var i = 0; i < nodes.length; ++i) {
20 var template = nodes[i]; 20 var template = nodes[i];
21 var mode = template.getAttribute("data-mode"); 21 var mode = template.getAttribute("data-mode");
22 var delegatesFocus = template.hasAttribute("data-delegatesFocus");
22 var parent = template.parentNode; 23 var parent = template.parentNode;
23 parent.removeChild(template); 24 parent.removeChild(template);
24 var shadowRoot; 25 var shadowRoot;
25 if (!mode || mode == 'v0'){ 26 if (!mode || mode == 'v0'){
26 shadowRoot = parent.createShadowRoot(); 27 shadowRoot = parent.createShadowRoot();
27 } else { 28 } else {
28 shadowRoot = parent.attachShadow({'mode': mode}); 29 shadowRoot = parent.attachShadow({'mode': mode,
30 'delegatesFocus': delegatesFocus}) ;
29 } 31 }
30 var expose = template.getAttribute("data-expose-as"); 32 var expose = template.getAttribute("data-expose-as");
31 if (expose) 33 if (expose)
32 window[expose] = shadowRoot; 34 window[expose] = shadowRoot;
33 if (template.id) 35 if (template.id)
34 shadowRoot.id = template.id; 36 shadowRoot.id = template.id;
35 var fragments = document.importNode(template.content, true); 37 var fragments = document.importNode(template.content, true);
36 shadowRoot.appendChild(fragments); 38 shadowRoot.appendChild(fragments);
37 39
38 convertTemplatesToShadowRootsWithin(shadowRoot); 40 convertTemplatesToShadowRootsWithin(shadowRoot);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 assert_equals(actual[i][2], expected[i][2], 'relatedTarget at ' + i + ' shou ld be same'); 192 assert_equals(actual[i][2], expected[i][2], 'relatedTarget at ' + i + ' shou ld be same');
191 assert_array_equals(actual[i][3], expected[i][3], 'composedPath at ' + i + ' should be same'); 193 assert_array_equals(actual[i][3], expected[i][3], 'composedPath at ' + i + ' should be same');
192 } 194 }
193 } 195 }
194 196
195 function assert_background_color(path, color) 197 function assert_background_color(path, color)
196 { 198 {
197 assert_equals(window.getComputedStyle(getNodeInComposedTree(path)).backgroundC olor, color, 199 assert_equals(window.getComputedStyle(getNodeInComposedTree(path)).backgroundC olor, color,
198 'backgroundColor for ' + path + ' should be ' + color); 200 'backgroundColor for ' + path + ' should be ' + color);
199 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698