Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nice-planes-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rrweb-snapshot": minor
---

fix for iframe loads in chrome - specifically iframes with custom web components
9 changes: 5 additions & 4 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export function needMaskingText(
}

// https://stackoverflow.com/a/36155560
// https://stackoverflow.com/a/69694808 (for handling blank frames in chrome)
function onceIframeLoaded(
iframeEl: HTMLIFrameElement,
listener: () => unknown,
Expand Down Expand Up @@ -343,15 +344,15 @@ function onceIframeLoaded(
// check blank frame for Chrome
const blankUrl = 'about:blank';
if (
win.location.href !== blankUrl ||
iframeEl.src === blankUrl ||
iframeEl.src === ''
(iframeEl.src === blankUrl ||
(iframeEl.src !== blankUrl && win.location.href !== blankUrl)) &&
readyState === 'complete'
) {
// iframe was already loaded, make sure we wait to trigger the listener
// till _after_ the mutation that found this iframe has had time to process
nativeSetTimeout(listener, 0);

return iframeEl.addEventListener('load', listener); // keep listing for future loads
return iframeEl.addEventListener('load', listener); // keep listening for future loads
}
// use default listener
iframeEl.addEventListener('load', listener);
Expand Down