Skip to content

Commit

Permalink
Lit polyfill - wait to polyfill on DOMContentLoaded (#3484)
Browse files Browse the repository at this point in the history
* Lit polyfill - wait to polyfill on DOMContentLoaded

* Adds changeset
  • Loading branch information
matthewp authored May 31, 2022
1 parent 5e66ffb commit 55820fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-cheetahs-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/lit': patch
---

Wait for DOMCOntentLoaded to polyfill in Lit
2 changes: 1 addition & 1 deletion packages/integrations/lit/client-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/lit/client-shim.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit 55820fa

Please sign in to comment.