diff --git a/src/_implementation/feature_detect.ts b/src/_implementation/feature_detect.ts index 8df76a7..30e7f3b 100644 --- a/src/_implementation/feature_detect.ts +++ b/src/_implementation/feature_detect.ts @@ -18,9 +18,14 @@ let hasNative: boolean|undefined; export function hasNativeDeclarativeShadowRoots(): boolean { if (hasNative === undefined) { const html = `
`; - const fragment = (new DOMParser() as DOMParser).parseFromString(html, 'text/html', { - includeShadowRoots: true - }); + let fragment: Document; + if ('parseHTMLUnsafe' in Document) { + fragment = (Document as { parseHTMLUnsafe: (html: string) => Document }).parseHTMLUnsafe(html); + } else { + fragment = (new DOMParser() as DOMParser).parseFromString(html, 'text/html', { + includeShadowRoots: true + }); + } hasNative = !!fragment.querySelector('div')?.shadowRoot; } return hasNative;