From a591a53195ba3a1ebf36c149c72e11800a674a1a Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Thu, 18 Feb 2021 11:59:41 +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();