{"ScriptPreparationCode":"// language=HTML\r\nconst html = \u0060\r\n \u003C!-- article out start --\u003E\r\n \u003Carticle\u003E\r\n \u003C!-- article in start --\u003E\r\n \u003Ch1\u003ELorem ipsum\u003C/h1\u003E\r\n \u003Cp\u003ELorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.\u003C/p\u003E\r\n \u003C!-- article in end --\u003E\r\n \u003C/article\u003E\r\n \u003C!-- article out end --\u003E\r\n\r\n \u003C!-- article out start --\u003E\r\n \u003Carticle\u003E\r\n \u003C!-- article in start --\u003E\r\n \u003Ch1\u003ELorem ipsum\u003C/h1\u003E\r\n \u003Cp\u003ELorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.\u003C/p\u003E\r\n \u003C!-- article in end --\u003E\r\n \u003C/article\u003E\r\n \u003C!-- article out end --\u003E\r\n\r\n \u003C!-- article out start --\u003E\r\n \u003Carticle\u003E\r\n \u003C!-- article in start --\u003E\r\n \u003Ch1\u003ELorem ipsum\u003C/h1\u003E\r\n \u003Cp\u003ELorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque, nostrum.\u003C/p\u003E\r\n \u003C!-- article in end --\u003E\r\n \u003C/article\u003E\r\n \u003C!-- article out end --\u003E\r\n\u0060;\r\nconst template = document.createElement(\u0027template\u0027);\r\ntemplate.innerHTML = html;\r\n\r\nwindow.testTemplate = template;\r\n","TestCases":[{"Name":"Traverse function","Code":"const elements = [];\r\nfunction traverse(node) {\r\n if (!node) return;\r\n \tif (node.nodeType === Node.ELEMENT_NODE) {\r\n elements.push(node);\r\n }\r\n traverse(node.nextElementSibling);\r\n traverse(node.firstElementChild);\r\n}\r\ntraverse(testTemplate.content.firstElementChild);\r\nif (elements.length !== 9) throw new Error(\u0060Expected 9 elements, got ${elements.length}\u0060);","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) {\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 elements = [];\r\nwhile (nodeIterator.nextNode()) {\r\n elements.push(nodeIterator.currentNode);\r\n}\r\nif (elements.length !== 9) throw new Error(\u0060Expected 9 elements, got ${elements.length}\u0060);","IsDeferred":false},{"Name":"NodeIterator with filter param","Code":"const nodeIterator = document.createNodeIterator(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ELEMENT\r\n);\r\n\r\nconst elements = [];\r\nwhile (nodeIterator.nextNode()) {\r\n elements.push(nodeIterator.currentNode);\r\n}\r\nif (elements.length !== 9) throw new Error(\u0060Expected 9 elements, got ${elements.length}\u0060);","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) {\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 elements = [];\r\nwhile (treeWalker.nextNode()) {\r\n elements.push(treeWalker.currentNode);\r\n}\r\nif (elements.length !== 9) throw new Error(\u0060Expected 9 elements, got ${elements.length}\u0060);","IsDeferred":false},{"Name":"TreeWalker with filter param","Code":"const treeWalker = document.createTreeWalker(\r\n testTemplate.content,\r\n NodeFilter.SHOW_ELEMENT\r\n);\r\n\r\nconst elements = [];\r\nwhile (treeWalker.nextNode()) {\r\n elements.push(treeWalker.currentNode);\r\n}\r\nif (elements.length !== 9) throw new Error(\u0060Expected 9 elements, got ${elements.length}\u0060);","IsDeferred":false}]}