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

const polyfillCheckEl = Document.parseHTMLUnsafe(
	`<p><template shadowrootmode="open"></template></p>`
).querySelector('p');

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