{"ScriptPreparationCode":"var htmlBody = \u0060\u003Ch3\u003EA body coming from an API... or somewhere else\u003C/h3\u003E\r\n \u003Cdiv id=\u0022html-mock-body\u0022\u003E\r\n It can contain regular HTML Elements and scripts with links.\r\n \u003C/div\u003E\r\n \u003Cscript type=\u0022text/javascript\u0022\u003E\r\n (function() {\r\n var bodyElement = document.querySelector(\u0027#html-mock-body\u0027);\r\n var tag = document.createElement(\u0027h1\u0027);\r\n tag.textContent =\r\n \u0027This script is injected from external source. Make sure you trust the source before doing this!\u0027;\r\n bodyElement.append(tag);\r\n }());\r\n \u003C/script\u003E\u0060;","TestCases":[{"Name":"DOMParser","Code":" const domParser = new DOMParser();\r\n const doc = domParser.parseFromString(htmlBody, \u0027text/html\u0027);\r\n\r\n const links = Array.from(doc.getElementsByTagName(\u0027link\u0027));\r\n const scripts = Array.from(doc.getElementsByTagName(\u0027script\u0027));\r\n const children = Array.from(doc.body.childNodes);\r\n\r\n const fragment = document.createDocumentFragment();\r\n\r\n fragment.append(...links);\r\n fragment.append(...children);\r\n fragment.append(...scripts);\r\n","IsDeferred":false},{"Name":"InnerHTML","Code":" const container = document.createElement(\u0027div\u0027);\r\n container.innerHTML = htmlBody;\r\n\r\n const links = Array.from(container.getElementsByTagName(\u0027link\u0027));\r\n const scripts = Array.from(container.getElementsByTagName(\u0027script\u0027));\r\n const children = Array.from(container.childNodes);\r\n\r\n const fragment = document.createDocumentFragment();\r\n\r\n fragment.append(...links);\r\n fragment.append(...children);\r\n fragment.append(...scripts);","IsDeferred":false}]}