From 5e4a554188888088fdfa7a4adacc46703f9d0f13 Mon Sep 17 00:00:00 2001 From: Yuta Osawa Date: Thu, 22 Aug 2024 00:00:29 +0900 Subject: [PATCH 1/2] Prevent partytown recreate script inserts "null" string to body --- .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..3c1e49afd80b --- /dev/null +++ b/.changeset/eight-rice-tap.md @@ -0,0 +1,5 @@ +--- +'@astrojs/partytown': patch +--- + +Prevent Partytown 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, From 42f633e243702b713d543c534138533f33f9141a Mon Sep 17 00:00:00 2001 From: Yuta Osawa Date: Sat, 24 Aug 2024 18:43:40 +0900 Subject: [PATCH 2/2] fix changeset message --- .changeset/eight-rice-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/eight-rice-tap.md b/.changeset/eight-rice-tap.md index 3c1e49afd80b..f31d24115c71 100644 --- a/.changeset/eight-rice-tap.md +++ b/.changeset/eight-rice-tap.md @@ -2,4 +2,4 @@ '@astrojs/partytown': patch --- -Prevent Partytown from inserting a 'null' string into the body +Prevent Partytown integration from inserting a 'null' string into the body