From f1df1b3b462309444a9a50ecbf229840dff8c9d0 Mon Sep 17 00:00:00 2001 From: Yuta Osawa Date: Mon, 26 Aug 2024 22:36:35 +0900 Subject: [PATCH] Prevent Partytown integration from inserting a 'null' string into the body (#11829) --- .changeset/eight-rice-tap.md | 5 +++++ packages/integrations/partytown/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/eight-rice-tap.md diff --git a/.changeset/eight-rice-tap.md b/.changeset/eight-rice-tap.md new file mode 100644 index 000000000000..f31d24115c71 --- /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 739ff0e4b9b4..05a1b4c11588 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,