diff --git a/.changeset/eight-rice-tap.md b/.changeset/eight-rice-tap.md new file mode 100644 index 0000000000..f31d24115c --- /dev/null +++ b/.changeset/eight-rice-tap.md @@ -0,0 +1,5 @@ +--- +'@astrojs/partytown': patch +--- + +Prevent Partytown integration from inserting a 'null' string into the body diff --git a/packages/integrations/partytown/src/index.ts b/packages/integrations/partytown/src/index.ts index 739ff0e4b9..05a1b4c115 100644 --- a/packages/integrations/partytown/src/index.ts +++ b/packages/integrations/partytown/src/index.ts @@ -26,7 +26,7 @@ export default function createPlugin(options?: PartytownOptions): AstroIntegrati hooks: { 'astro:config:setup': ({ config: _config, command, injectScript }) => { const lib = `${appendForwardSlash(_config.base)}~partytown/`; - const recreateIFrameScript = `;(e=>{e.addEventListener("astro:before-swap",e=>{let r=document.body.querySelector("iframe[src*='${lib}']");e.newDocument.body.append(r)})})(document);`; + const recreateIFrameScript = `;(e=>{e.addEventListener("astro:before-swap",e=>{let r=document.body.querySelector("iframe[src*='${lib}']");if(r)e.newDocument.body.append(r)})})(document);`; const partytownConfig = { lib, ...options?.config,