Lit polyfill - wait to polyfill on DOMContentLoaded (#3484)

* Lit polyfill - wait to polyfill on DOMContentLoaded

* Adds changeset
This commit is contained in:
Matthew Phillips 2022-05-31 11:40:26 -04:00 committed by GitHub
parent 5e66ffb3a0
commit 55820fa784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/lit': patch
---
Wait for DOMCOntentLoaded to polyfill in Lit

View file

@ -2,7 +2,7 @@ async function polyfill() {
const { hydrateShadowRoots } = await import(
'@webcomponents/template-shadowroot/template-shadowroot.js'
);
hydrateShadowRoots(document.body);
window.addEventListener('DOMContentLoaded', () => hydrateShadowRoots(document.body), { once: true });
}
const polyfillCheckEl = new DOMParser()

View file

@ -77,7 +77,7 @@ var S = i(() => {
});
async function g() {
let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v));
t(document.body);
window.addEventListener('DOMContentLoaded', () => t(document.body),{once:true});
}
var x = new DOMParser()
.parseFromString('<p><template shadowroot="open"></template></p>', 'text/html', {