From 6a93de6950c4a7cce51406e9f26bbc00462c8f22 Mon Sep 17 00:00:00 2001 From: rchlfryn Date: Wed, 18 Feb 2026 11:57:18 -0800 Subject: [PATCH 1/9] Add key to see if will sidestep chromes caching --- src/blocks/GenericEmbed/Component.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/blocks/GenericEmbed/Component.tsx b/src/blocks/GenericEmbed/Component.tsx index 83c315b1..3d1f5948 100644 --- a/src/blocks/GenericEmbed/Component.tsx +++ b/src/blocks/GenericEmbed/Component.tsx @@ -21,6 +21,9 @@ export const GenericEmbedBlockComponent = ({ isLexical = true, }: Props) => { const [sanitizedHtml, setSanitizedHtml] = useState(null) + // Unique key per mount forces a new iframe browsing context, ensuring scripts + // (especially type="module") re-execute after client-side navigation in Chrome. + const [iframeKey] = useState(() => Date.now()) const bgColorClass = `bg-${backgroundColor}` const textColor = getTextColorFromBgColor(backgroundColor) @@ -85,6 +88,7 @@ export const GenericEmbedBlockComponent = ({ )} > Date: Wed, 18 Feb 2026 12:24:29 -0800 Subject: [PATCH 2/9] Cache-busting via DOMPurify --- src/blocks/GenericEmbed/Component.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/blocks/GenericEmbed/Component.tsx b/src/blocks/GenericEmbed/Component.tsx index 3d1f5948..6b4e7180 100644 --- a/src/blocks/GenericEmbed/Component.tsx +++ b/src/blocks/GenericEmbed/Component.tsx @@ -21,9 +21,6 @@ export const GenericEmbedBlockComponent = ({ isLexical = true, }: Props) => { const [sanitizedHtml, setSanitizedHtml] = useState(null) - // Unique key per mount forces a new iframe browsing context, ensuring scripts - // (especially type="module") re-execute after client-side navigation in Chrome. - const [iframeKey] = useState(() => Date.now()) const bgColorClass = `bg-${backgroundColor}` const textColor = getTextColorFromBgColor(backgroundColor) @@ -34,6 +31,17 @@ export const GenericEmbedBlockComponent = ({ // Normalize problematic quotes that are parsed incorrectly by DOMParser and DOMPurify const normalizedHTML = html.replaceAll('"', '"').replaceAll('"', '"') + // Add cache-busting parameter to module script URLs to force re-evaluation. + // Chrome caches module scripts by URL and skips re-evaluation on client-side + // navigation, which prevents widgets from loading when revisiting a page. + DOMPurify.addHook('afterSanitizeAttributes', (node) => { + const src = node.getAttribute('src') + if (node.tagName === 'SCRIPT' && node.getAttribute('type') === 'module' && src) { + const separator = src.includes('?') ? '&' : '?' + node.setAttribute('src', `${src}${separator}_cb=${Date.now()}`) + } + }) + const sanitized = DOMPurify.sanitize(normalizedHTML, { ADD_TAGS: ['iframe', 'script', 'style', 'dbox-widget'], ADD_ATTR: [ @@ -58,6 +66,8 @@ export const GenericEmbedBlockComponent = ({ FORCE_BODY: true, }) + DOMPurify.removeHook('afterSanitizeAttributes') + const styleOverrides = ` ` - setSanitizedHtml(sanitized + styleOverrides) + setSanitizedHtml(withDynamicScripts + styleOverrides) }, [html]) if (sanitizedHtml === null) return null From d5bd8147e7342feb1400c45f8e90180a629ff2b8 Mon Sep 17 00:00:00 2001 From: rchlfryn Date: Wed, 18 Feb 2026 14:31:24 -0800 Subject: [PATCH 6/9] Injects a fresh script element rather than relying on the browser to execute a static