dom/tests/js/docfrag.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/js/docfrag.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,39 @@
     1.4 +<HTML>
     1.5 +<HEAD>
     1.6 +<SCRIPT>
     1.7 +function docFragAppendTest() {
     1.8 +  var d = document.createDocumentFragment();
     1.9 +  d.appendChild(document.createTextNode(" Hello"));
    1.10 +  var b = document.createElement("B")
    1.11 +  b.appendChild(document.createTextNode(" there"));
    1.12 +  d.appendChild(b);
    1.13 +  p = document.getElementById("appendTest");
    1.14 +  p.appendChild(d);
    1.15 +  alert("This number should be 0: " + d.childNodes.length);
    1.16 +}
    1.17 +function docFragReplaceTest() {
    1.18 +  var d = document.createDocumentFragment();
    1.19 +  d.appendChild(document.createTextNode(" new"));
    1.20 +  var b = document.createElement("B")
    1.21 +  b.appendChild(document.createTextNode(" ones"));
    1.22 +  d.appendChild(b);
    1.23 +  p = document.getElementById("replaceTest");
    1.24 +  s = document.getElementById("replaceSpan");
    1.25 +  if (null != s) {
    1.26 +    p.replaceChild(d, s);
    1.27 +  }
    1.28 +  alert("This number should be 0: " + d.childNodes.length);
    1.29 +}
    1.30 +</SCRIPT>
    1.31 +</HEAD>
    1.32 +<BODY>
    1.33 +<H1>Document Fragment test</H1>
    1.34 +
    1.35 +<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>
    1.36 +
    1.37 +<P ID="replaceTest">
    1.38 +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>.
    1.39 +</P>
    1.40 +
    1.41 +</BODY>
    1.42 +</HTML>
    1.43 \ No newline at end of file

mercurial