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

     1 <HTML>
     2 <HEAD>
     3 <SCRIPT>
     4 function docFragAppendTest() {
     5   var d = document.createDocumentFragment();
     6   d.appendChild(document.createTextNode(" Hello"));
     7   var b = document.createElement("B")
     8   b.appendChild(document.createTextNode(" there"));
     9   d.appendChild(b);
    10   p = document.getElementById("appendTest");
    11   p.appendChild(d);
    12   alert("This number should be 0: " + d.childNodes.length);
    13 }
    14 function docFragReplaceTest() {
    15   var d = document.createDocumentFragment();
    16   d.appendChild(document.createTextNode(" new"));
    17   var b = document.createElement("B")
    18   b.appendChild(document.createTextNode(" ones"));
    19   d.appendChild(b);
    20   p = document.getElementById("replaceTest");
    21   s = document.getElementById("replaceSpan");
    22   if (null != s) {
    23     p.replaceChild(d, s);
    24   }
    25   alert("This number should be 0: " + d.childNodes.length);
    26 }
    27 </SCRIPT>
    28 </HEAD>
    29 <BODY>
    30 <H1>Document Fragment test</H1>
    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>
    34 <P ID="replaceTest">
    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>.
    36 </P>
    38 </BODY>
    39 </HTML>

mercurial