refactor: get sandbox
This commit is contained in:
parent
ec4cf55696
commit
4acff224a8
1 changed files with 3 additions and 5 deletions
|
@ -53,12 +53,10 @@ export const getSandboxWindowAsync = async (): Promise<Window> => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const targetEl = document.documentElement
|
const targetEl = document.documentElement
|
||||||
const eventName = 'onmousemove'
|
const eventName = 'onmousemove'
|
||||||
|
|
||||||
const unsafe = getUnsafeWindow()
|
|
||||||
const id = Math.random().toString()
|
const id = Math.random().toString()
|
||||||
|
|
||||||
unsafe[id] = (iframe: HTMLIFrameElement) => {
|
targetEl[id] = (iframe: HTMLIFrameElement) => {
|
||||||
delete unsafe[id]
|
delete targetEl[id]
|
||||||
targetEl.removeAttribute(eventName)
|
targetEl.removeAttribute(eventName)
|
||||||
|
|
||||||
iframe.style.display = 'none'
|
iframe.style.display = 'none'
|
||||||
|
@ -67,7 +65,7 @@ export const getSandboxWindowAsync = async (): Promise<Window> => {
|
||||||
resolve(w as Window)
|
resolve(w as Window)
|
||||||
}
|
}
|
||||||
|
|
||||||
targetEl.setAttribute(eventName, `window['${id}'](document.createElement('iframe'))`)
|
targetEl.setAttribute(eventName, `this['${id}'](document.createElement('iframe'))`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue