advanced syntax/script: print widget id in console.log messages
This commit is contained in:
parent
e84c1d0435
commit
8655a2866c
2 changed files with 25 additions and 3 deletions
|
|
@ -836,7 +836,15 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (!this.parsers[code]) this.parsers[code] = vm.compile(code, defaultScope)
|
||||
|
||||
let r = this.parsers[code](jsScope, this.parsersLocalScope)
|
||||
let r
|
||||
vm.setWidget(this)
|
||||
try {
|
||||
r = this.parsers[code](jsScope, this.parsersLocalScope)
|
||||
} catch (err) {
|
||||
vm.setWidget()
|
||||
throw err
|
||||
}
|
||||
vm.setWidget()
|
||||
|
||||
if (r === undefined) r = ''
|
||||
|
||||
|
|
@ -852,7 +860,15 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (!this.parsers[code]) this.parsers[code] = vm.compile('return ' + code.trim(), defaultScope)
|
||||
|
||||
let r = this.parsers[code](jsScope, this.parsersLocalScope)
|
||||
let r
|
||||
vm.setWidget(this)
|
||||
try {
|
||||
r = this.parsers[code](jsScope, this.parsersLocalScope)
|
||||
} catch (err) {
|
||||
vm.setWidget()
|
||||
throw err
|
||||
}
|
||||
vm.setWidget()
|
||||
|
||||
if (r === undefined) r = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,13 @@ class Vm {
|
|||
|
||||
registerGlobals() {
|
||||
|
||||
this.sandbox.contentWindow.console = console
|
||||
this.sandbox.contentWindow.console = {
|
||||
...console,
|
||||
log: (msg)=>{
|
||||
this.getWidget().log(msg)
|
||||
}
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.setTimeout =
|
||||
this.sandbox.contentWindow.setInterval = ()=>{
|
||||
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue