Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/_implementation/feature_detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ let hasNative: boolean|undefined;
export function hasNativeDeclarativeShadowRoots(): boolean {
if (hasNative === undefined) {
const html = `<div><template shadowrootmode="open"></template></div>`;
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;
Expand Down