0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

Prevent Partytown integration from inserting a 'null' string into the body (#11829)

This commit is contained in:
Yuta Osawa 2024-08-26 22:36:35 +09:00 committed by GitHub
parent 1ffaae04cf
commit f1df1b3b46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/partytown': patch
---
Prevent Partytown integration from inserting a 'null' string into the body

View file

@ -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,