From ff527d9732f306fe2fe73dddea1cb6ca7d0497aa Mon Sep 17 00:00:00 2001 From: David Reed Date: Sun, 20 Nov 2022 01:28:51 -0500 Subject: [PATCH] fix undefined --- src/uv.handler.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/uv.handler.js b/src/uv.handler.js index 577fab3..25c5cb4 100644 --- a/src/uv.handler.js +++ b/src/uv.handler.js @@ -691,28 +691,29 @@ function __uvHook(window, config = {}, bare = '/bare/') { }, }); + const contentWindowGet = Object.getOwnPropertyDescriptor( + HTMLIFrameElement.prototype, + 'contentWindow' + ).get; + client.element.hookProperty(HTMLIFrameElement, 'contentWindow', { get: (target, that) => { const win = target.call(that); try { if (!win.__uv) __uvHook(win, config, bare); - return win; - } catch (e) { - return win; - } + } catch (e) {} + return win; }, }); client.element.hookProperty(HTMLIFrameElement, 'contentDocument', { get: (target, that) => { + const win = contentWindowGet.call(that); const doc = target.call(that); try { - const win = doc.defaultView; if (!win.__uv) __uvHook(win, config, bare); - return doc; - } catch (e) { - return win; - } + } catch (e) {} + return doc; }, });