Skip to content

Commit

Permalink
conditionally affect string append, not html return
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Jan 25, 2025
1 parent e6621dc commit 1aaee3d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions libs/qwikdev-astro/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ export async function renderToStaticMarkup(
/** Adds support for visible tasks with Astro's client router */
const htmlWithObservers =
isClientRouter &&
isQwikLoaderNeeded &&
htmlWithRerun +
`
<script data-qwik-astro-client-router>document.addEventListener('astro:after-swap',()=>{const e=document.querySelectorAll('[on\\\\:qvisible]');if(e.length){const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(e.target.dispatchEvent(new CustomEvent('qvisible')),o.unobserve(e.target))})});e.forEach(e=>o.observe(e))}});</script>
${isQwikLoaderNeeded ? `<script data-qwik-astro-client-router>document.addEventListener('astro:after-swap',()=>{const e=document.querySelectorAll('[on\\\\:qvisible]');if(e.length){const o=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&(e.target.dispatchEvent(new CustomEvent('qvisible')),o.unobserve(e.target))})});e.forEach(e=>o.observe(e))}});</script>` : ''}
`;

return {
Expand All @@ -190,4 +189,4 @@ export default {
renderToStaticMarkup,
supportsAstroStaticSlot: true,
check
};
};

0 comments on commit 1aaee3d

Please sign in to comment.