Index: third_party/WebKit/LayoutTests/fast/dom/shadow/resources/shadow-dom.js |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/shadow/resources/shadow-dom.js b/third_party/WebKit/LayoutTests/fast/dom/shadow/resources/shadow-dom.js |
index 50a8492a4b0122f6bc8f0bd9b9edcc50d3b32305..5f3d1c0c0e02a57c002b2d95f17230510fa32a1a 100644 |
--- a/third_party/WebKit/LayoutTests/fast/dom/shadow/resources/shadow-dom.js |
+++ b/third_party/WebKit/LayoutTests/fast/dom/shadow/resources/shadow-dom.js |
@@ -66,6 +66,22 @@ function createDOM(tagName, attributes) |
return element; |
} |
+function removeWhiteSpaceOnlyTextNodes(node) |
+{ |
+ for (var i = 0; i < node.childNodes.length; i++) { |
+ var child = node.childNodes[i]; |
+ if (child.nodeType === Node.TEXT_NODE && child.nodeValue.trim().length == 0) { |
+ node.removeChild(child); |
+ i--; |
+ } else if (child.nodeType === Node.ELEMENT_NODE || child.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { |
+ removeWhiteSpaceOnlyTextNodes(child); |
+ } |
+ } |
+ if (node.shadowRoot) { |
+ removeWhiteSpaceOnlyTextNodes(node.shadowRoot); |
+ } |
+} |
+ |
function convertTemplatesToShadowRootsWithin(node) { |
var nodes = node.querySelectorAll("template"); |
for (var i = 0; i < nodes.length; ++i) { |