From 4acff224a89accd877de93b8032d61a549b2796a Mon Sep 17 00:00:00 2001 From: Xmader Date: Thu, 26 Nov 2020 14:21:19 -0500 Subject: [PATCH] refactor: get sandbox --- src/utils.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index c044702..fbdbee2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -53,12 +53,10 @@ export const getSandboxWindowAsync = async (): Promise => { return new Promise((resolve) => { const targetEl = document.documentElement const eventName = 'onmousemove' - - const unsafe = getUnsafeWindow() const id = Math.random().toString() - unsafe[id] = (iframe: HTMLIFrameElement) => { - delete unsafe[id] + targetEl[id] = (iframe: HTMLIFrameElement) => { + delete targetEl[id] targetEl.removeAttribute(eventName) iframe.style.display = 'none' @@ -67,7 +65,7 @@ export const getSandboxWindowAsync = async (): Promise => { resolve(w as Window) } - targetEl.setAttribute(eventName, `window['${id}'](document.createElement('iframe'))`) + targetEl.setAttribute(eventName, `this['${id}'](document.createElement('iframe'))`) }) }