From b1bb1c1bad0264955a9ccda458dea21854be1aac Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 11 May 2020 16:05:11 +0200 Subject: [PATCH] script: better globals init --- src/client/widgets/vm.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/widgets/vm.js b/src/client/widgets/vm.js index e77847b5..be1903ae 100644 --- a/src/client/widgets/vm.js +++ b/src/client/widgets/vm.js @@ -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'