| <html> |
| <head> |
| <script src=traversal.js language="JavaScript" type="text/JavaScript" ></script> |
| <title>Traversal Test</title> |
| </head> |
| <body> |
| <div id="test"> |
| <span id="A"></span><span id="B"></span><span id="C"></span><span id="D"></span><span id="E"></span><span id="F"></span><span id="G"></span><span id="H"></span><span id="I"></span> |
| </div> |
| <div style="font-family: Courier; font-size: 14;"> |
| <script> |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| var root = document.getElementById('test'); |
| |
| function testNodeFiter(n) |
| { |
| if (n.tagName == 'SPAN') return NodeFilter.FILTER_ACCEPT; |
| return NodeFilter.FILTER_SKIP; |
| } |
| |
| var it = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, testNodeFiter, false); |
| for (i = 0; i < 4; i++) |
| it.nextNode(); |
| document.write(dumpNodeIterator(it, "ref node 'D'; pointer after")); |
| |
| // remove node 'E' |
| document.write("<p>remove node 'E'"); |
| root.removeChild(document.getElementById('E')); |
| document.write(dumpNodeIterator(it, "ref node 'D'; pointer after")); |
| |
| // insert new node 'X' before 'F' |
| document.write("<p>insert new node 'X' before 'F'"); |
| var X = document.createElement('SPAN'); |
| X.setAttribute('ID', 'X'); |
| root.insertBefore(X, document.getElementById('F')); |
| document.write(dumpNodeIterator(it, "ref node 'D'; pointer after")); |
| |
| // move node 'I' before 'X' |
| document.write("<p>move node 'I' before 'X'"); |
| var I = document.getElementById('I'); |
| root.removeChild(I); |
| root.insertBefore(I, X); |
| document.write(dumpNodeIterator(it, "ref node 'D'; pointer after")); |
| </script> |
| </div> |
| </body> |
| </html> |