From d449a1263d4ad1b92fe02b2f19186ca3cfc60f1b Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] safe access iframe document --- src/snapshot.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/snapshot.ts b/src/snapshot.ts index 77544656..2c0f67e4 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -208,7 +208,14 @@ function onceIframeLoaded( } // document is loading let fired = false; - if (win.document.readyState !== 'complete') { + + let readyState: DocumentReadyState; + try { + readyState = win.document.readyState; + } catch (error) { + return; + } + if (readyState !== 'complete') { const timer = setTimeout(() => { if (!fired) { listener();