script: better globals init

This commit is contained in:
bordun 2020-05-11 16:05:11 +02:00
parent 4a5843ced6
commit b1bb1c1bad

View file

@ -2,19 +2,19 @@ var loopProtect = require('loop-protect'),
{deepCopy} = require('../utils'),
globals
setTimeout(()=>{
globals = {
screen: {width: screen.width, height: screen.height},
env: deepCopy(ENV),
url: document.location.host,
platform: navigator.platform
}
})
class Vm {
constructor() {
if (!globals) {
globals = {
screen: {width: screen.width, height: screen.height},
env: deepCopy(ENV),
url: document.location.host,
platform: navigator.platform
}
}
this.sandbox = document.createElement('iframe')
this.sandbox.style.display = 'none'
this.sandbox.sandbox = 'allow-same-origin'