Lit polyfill - wait to polyfill on DOMContentLoaded (#3484)
* Lit polyfill - wait to polyfill on DOMContentLoaded * Adds changeset
This commit is contained in:
parent
5e66ffb3a0
commit
55820fa784
3 changed files with 7 additions and 2 deletions
5
.changeset/gentle-cheetahs-divide.md
Normal file
5
.changeset/gentle-cheetahs-divide.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/lit': patch
|
||||
---
|
||||
|
||||
Wait for DOMCOntentLoaded to polyfill in Lit
|
|
@ -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()
|
||||
|
|
2
packages/integrations/lit/client-shim.min.js
vendored
2
packages/integrations/lit/client-shim.min.js
vendored
|
@ -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', {
|
||||
|
|
Loading…
Reference in a new issue