File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
packages/rrweb-snapshot/src Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " rrweb-snapshot " : minor
3+ ---
4+
5+ fix for iframe loads in chrome - specifically iframes with custom web components
Original file line number Diff line number Diff line change @@ -308,6 +308,7 @@ export function needMaskingText(
308308}
309309
310310// https://stackoverflow.com/a/36155560
311+ // https://stackoverflow.com/a/69694808 (for handling blank frames in chrome)
311312function onceIframeLoaded (
312313 iframeEl : HTMLIFrameElement ,
313314 listener : ( ) => unknown ,
@@ -342,16 +343,15 @@ function onceIframeLoaded(
342343 }
343344 // check blank frame for Chrome
344345 const blankUrl = 'about:blank' ;
345- if (
346- win . location . href !== blankUrl ||
347- iframeEl . src === blankUrl ||
348- iframeEl . src === ''
346+ if ( ( iframeEl . src === blankUrl ||
347+ ( iframeEl . src !== blankUrl && win . location . href !== blankUrl ) ) &&
348+ readyState === 'complete'
349349 ) {
350350 // iframe was already loaded, make sure we wait to trigger the listener
351351 // till _after_ the mutation that found this iframe has had time to process
352352 setTimeout ( listener , 0 ) ;
353353
354- return iframeEl . addEventListener ( 'load' , listener ) ; // keep listing for future loads
354+ return iframeEl . addEventListener ( 'load' , listener ) ; // keep listening for future loads
355355 }
356356 // use default listener
357357 iframeEl . addEventListener ( 'load' , listener ) ;
You can’t perform that action at this time.
0 commit comments