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

Unified Diff: LayoutTests/fast/dom/DocumentFragment/get-element-by-id.html

Issue 251633002: Add support for DocumentFragment.getElementById() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix createElement() calls Created 6 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DocumentFragment/get-element-by-id-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/DocumentFragment/get-element-by-id.html
diff --git a/LayoutTests/fast/dom/DocumentFragment/get-element-by-id.html b/LayoutTests/fast/dom/DocumentFragment/get-element-by-id.html
new file mode 100644
index 0000000000000000000000000000000000000000..8cea938d6d2eaac39f134f9660269ee8ce6d9849
--- /dev/null
+++ b/LayoutTests/fast/dom/DocumentFragment/get-element-by-id.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href="http://dom.spec.whatwg.org/#interface-nonelementparentnode">
+<script src="../../../resources/js-test.js"></script>
+</head>
+<body>
+<div id="notInFragment"></div>
+<div id="duplicateId1"></div>
+<script>
+description("Tests that getElementById() API is exposed on DocumentFragment nodes.");
+
+var fragment = new DocumentFragment();
+var div = document.createElement("div");
+div.id = "divID";
+fragment.appendChild(div);
+var a = document.createElement("a");
+a.id = "aID";
+div.appendChild(a);
+var span = document.createElement("span");
+span.id = "duplicateId1";
+div.appendChild(span);
+var h1 = document.createElement("h1");
+h1.id = "duplicateId2";
+div.appendChild(h1);
+var h2 = document.createElement("h2");
+h2.id = "duplicateId2";
+div.appendChild(h2);
+
+shouldBe("fragment.getElementById('divID')", "div");
+shouldBe("fragment.getElementById('aID')", "a");
+shouldBeNull("fragment.getElementById('notInFragment')");
+shouldBeNull("fragment.getElementById('doesNotExist')");
+
+// Duplicate ID cases.
+shouldBe("fragment.getElementById('duplicateId1')", "span"); // Should return the Element *inside* the DocumentFragment.
+shouldBe("fragment.getElementById('duplicateId2')", "h1"); // Should return the first matching Element in case of duplicate.
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DocumentFragment/get-element-by-id-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698