script: better globals init
This commit is contained in:
parent
66fb046929
commit
db12c286f0
1 changed files with 9 additions and 9 deletions
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue