dom/tests/js/docfrag.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <HTML>
michael@0 2 <HEAD>
michael@0 3 <SCRIPT>
michael@0 4 function docFragAppendTest() {
michael@0 5 var d = document.createDocumentFragment();
michael@0 6 d.appendChild(document.createTextNode(" Hello"));
michael@0 7 var b = document.createElement("B")
michael@0 8 b.appendChild(document.createTextNode(" there"));
michael@0 9 d.appendChild(b);
michael@0 10 p = document.getElementById("appendTest");
michael@0 11 p.appendChild(d);
michael@0 12 alert("This number should be 0: " + d.childNodes.length);
michael@0 13 }
michael@0 14 function docFragReplaceTest() {
michael@0 15 var d = document.createDocumentFragment();
michael@0 16 d.appendChild(document.createTextNode(" new"));
michael@0 17 var b = document.createElement("B")
michael@0 18 b.appendChild(document.createTextNode(" ones"));
michael@0 19 d.appendChild(b);
michael@0 20 p = document.getElementById("replaceTest");
michael@0 21 s = document.getElementById("replaceSpan");
michael@0 22 if (null != s) {
michael@0 23 p.replaceChild(d, s);
michael@0 24 }
michael@0 25 alert("This number should be 0: " + d.childNodes.length);
michael@0 26 }
michael@0 27 </SCRIPT>
michael@0 28 </HEAD>
michael@0 29 <BODY>
michael@0 30 <H1>Document Fragment test</H1>
michael@0 31
michael@0 32 <P ID="appendTest">If this test works, clicking on this <A href="" onclick="docFragAppendTest(); return false;">link</A> will add two words to the end of this paragraph.</P>
michael@0 33
michael@0 34 <P ID="replaceTest">
michael@0 35 Clicking on this <A href="" onclick="docFragReplaceTest(); return false;">link</A> will replace the following two words with new ones: <span id="replaceSpan">two words</span>.
michael@0 36 </P>
michael@0 37
michael@0 38 </BODY>
michael@0 39 </HTML>

mercurial