(target, html, doc)
| 4920 | } |
| 4921 | |
| 4922 | function setHTML(target, html, doc) { |
| 4923 | if (!target) return; |
| 4924 | const htmlStr = html === null || html === undefined ? '' : String(html); |
| 4925 | if (tryDirectSetHTML(target, htmlStr) || tryPolicySetHTML(target, htmlStr)) return; |
| 4926 | const targetDoc = doc || target.ownerDocument || document; |
| 4927 | const fragment = createHTML(htmlStr, targetDoc); |
| 4928 | const targetIsHtml = target.nodeType === 1 && target.nodeName.toLowerCase() === 'html'; |
| 4929 | if (targetIsHtml) { |
| 4930 | let htmlNode = null; |
| 4931 | const fragChildren = fragment.childNodes; |
| 4932 | for (let i = 0; i < fragChildren.length; i++) { |
| 4933 | const child = fragChildren[i]; |
| 4934 | if (child.nodeType === 1 && child.nodeName.toLowerCase() === 'html') { |
| 4935 | htmlNode = child; |
| 4936 | break; |
| 4937 | } |
| 4938 | } |
| 4939 | if (htmlNode) { |
| 4940 | const attrs = target.attributes; |
| 4941 | for (let i = attrs.length - 1; i >= 0; i--) { |
| 4942 | target.removeAttribute(attrs[i].name); |
| 4943 | } |
| 4944 | const srcAttrs = htmlNode.attributes; |
| 4945 | for (let i = 0; i < srcAttrs.length; i++) { |
| 4946 | target.setAttribute(srcAttrs[i].name, srcAttrs[i].value); |
| 4947 | } |
| 4948 | while (target.firstChild) { |
| 4949 | target.removeChild(target.firstChild); |
| 4950 | } |
| 4951 | const htmlChildren = Array.from(htmlNode.childNodes); |
| 4952 | for (let i = 0; i < htmlChildren.length; i++) { |
| 4953 | target.appendChild(htmlChildren[i]); |
| 4954 | } |
| 4955 | return; |
| 4956 | } |
| 4957 | } |
| 4958 | while (target.firstChild) { |
| 4959 | target.removeChild(target.firstChild); |
| 4960 | } |
| 4961 | target.appendChild(fragment); |
| 4962 | } |
| 4963 | |
| 4964 | const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor; |
| 4965 |
no test coverage detected