{"ScriptPreparationCode":"// language=HTML\r\nconst html = \u0060\r\n \u003Cdiv\u003E\r\n \u003Cp\u003EThis is some random text.\u003C/p\u003E\r\n \u003Cdiv\u003E\r\n \u003Cp\u003EThis is more random text with \u003Cspan\u003ESPAN ELEMENT\u003C/span\u003E inside.\u003C/p\u003E\r\n \u003C/div\u003E\r\n \u003C/div\u003E\r\n\u0060;\r\nconst template = document.createElement(\u0027template\u0027);\r\ntemplate.innerHTML = html;\r\n\r\nwindow.testTemplate = template;\r\n\r\nwindow.testTraverse = function traverse(node, use) {\r\n if (!node) return;\r\n\r\n use(node);\r\n traverse(node.firstChild, use);\r\n traverse(node.nextSibling, use);\r\n}","TestCases":[{"Name":"Traverse function","Code":"const comments = [];\r\ntestTraverse(testTemplate.content.firstChild, node =\u003E {\r\n if (node.nodeType === Node.ELEMENT_NODE | Node.TEXT_NODE) {\r\n comments.push(node);\r\n }\r\n});","IsDeferred":false},{"Name":"NodeIterator with filter function","Code":"const nodeIterator = document.createNodeIterator(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ALL,\r\n {\r\n acceptNode(node) {\r\n if (node.nodeType === Node.ELEMENT_NODE | Node.TEXT_NODE) {\r\n return NodeFilter.FILTER_ACCEPT;\r\n }\r\n\r\n return NodeFilter.FILTER_REJECT;\r\n }\r\n }\r\n);\r\n\r\nconst comments = [];\r\nwhile (nodeIterator.nextNode()) {\r\n comments.push(nodeIterator.currentNode);\r\n}","IsDeferred":false},{"Name":"NodeIterator with filter param","Code":"const nodeIterator = document.createNodeIterator(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\r\n);\r\n\r\nconst comments = [];\r\nwhile (nodeIterator.nextNode()) {\r\n comments.push(nodeIterator.currentNode);\r\n}","IsDeferred":false},{"Name":"TreeWalker with filter function","Code":"const treeWalker = document.createTreeWalker(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ALL,\r\n {\r\n acceptNode(node) {\r\n if (node.nodeType === Node.ELEMENT_NODE | Node.TEXT_NODE) {\r\n return NodeFilter.FILTER_ACCEPT;\r\n }\r\n\r\n return NodeFilter.FILTER_REJECT;\r\n }\r\n }\r\n);\r\n\r\nconst comments = [];\r\nwhile (treeWalker.nextNode()) {\r\n comments.push(treeWalker.currentNode);\r\n}","IsDeferred":false},{"Name":"TreeWalker with filter param","Code":"const treeWalker = document.createTreeWalker(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT\r\n);\r\n\r\nconst comments = [];\r\nwhile (treeWalker.nextNode()) {\r\n comments.push(treeWalker.currentNode);\r\n}","IsDeferred":false}]}