summaryrefslogtreecommitdiff
path: root/packages/integrations/lit/client-shim.js
blob: bf45dd9128d3b5bec4042591be667117be02fca1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
async function polyfill() {
	const { hydrateShadowRoots } = await import(
		'@webcomponents/template-shadowroot/template-shadowroot.js'
	);
	window.addEventListener('DOMContentLoaded', () => hydrateShadowRoots(document.body), {
		once: true,
	});
}

const polyfillCheckEl = new DOMParser()
	.parseFromString(
		`<p><template shadowroot="open" shadowrootmode="open"></template></p>`,
		'text/html',
		{
			includeShadowRoots: true,
		}
	)
	.querySelector('p');

if (!polyfillCheckEl?.shadowRoot) {
	polyfill();
}