| <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 id="D" marked="YES"></span><span id="E"></span><span id="F"></span></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.layoutTestController) |
| layoutTestController.dumpAsText(); |
| |
| var parent = document.getElementById('test'); |
| //var root = document.getElementById('A'); |
| var root = document; |
| |
| function testNodeFiter(n) |
| { |
| if (n.getAttribute('marked') == 'YES') return NodeFilter.FILTER_ACCEPT; |
| return NodeFilter.FILTER_SKIP; |
| } |
| |
| var it = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, testNodeFiter, false); |
| var out = ''; |
| while ((n = it.nextNode())) { |
| out += "<br>" + n.tagName + ": " + n.id; |
| } |
| document.write(out); |
| |
| </script> |
| </div> |
| </body> |
| </html> |