From 340fe25f47c676912e6f3b1d9d1836c1a8f7db45 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Sat, 10 Feb 2024 12:17:58 +0100 Subject: [PATCH] probably now obsolete part for issue 9953 --- .changeset/tough-queens-travel.md | 5 +++++ packages/integrations/lit/client-shim.js | 4 +++- packages/integrations/lit/client-shim.min.js | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/tough-queens-travel.md diff --git a/.changeset/tough-queens-travel.md b/.changeset/tough-queens-travel.md new file mode 100644 index 0000000000..89951b5461 --- /dev/null +++ b/.changeset/tough-queens-travel.md @@ -0,0 +1,5 @@ +--- +"@astrojs/lit": patch +--- + +Adds processing of declarative shadow DOMs (DSD) during view transitions for browsers that do not support DSD natively. diff --git a/packages/integrations/lit/client-shim.js b/packages/integrations/lit/client-shim.js index bf45dd9128..513a31737f 100644 --- a/packages/integrations/lit/client-shim.js +++ b/packages/integrations/lit/client-shim.js @@ -2,7 +2,9 @@ async function polyfill() { const { hydrateShadowRoots } = await import( '@webcomponents/template-shadowroot/template-shadowroot.js' ); - window.addEventListener('DOMContentLoaded', () => hydrateShadowRoots(document.body), { + const listener = () => hydrateShadowRoots(document.body); + document.addEventListener('astro:after-swap', listener); + window.addEventListener('DOMContentLoaded', listener, { once: true, }); } diff --git a/packages/integrations/lit/client-shim.min.js b/packages/integrations/lit/client-shim.min.js index 7588f315ff..69c5599c1e 100644 --- a/packages/integrations/lit/client-shim.min.js +++ b/packages/integrations/lit/client-shim.min.js @@ -86,8 +86,9 @@ var S = i(() => { E(); }); async function N() { - let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v)); - window.addEventListener('DOMContentLoaded', () => t(document.body), { once: !0 }); + let { hydrateShadowRoots: t } = await Promise.resolve().then(() => (S(), v)), + n = () => t(document.body); + window.addEventListener('DOMContentLoaded', n, { once: !0 }); } var R = new DOMParser() .parseFromString(