script: safe compile
This commit is contained in:
parent
856627604b
commit
62af51dcc7
2 changed files with 12 additions and 5 deletions
|
|
@ -91,7 +91,7 @@
|
|||
- always hidden except in project tree
|
||||
- `script` property must not be wrapped in a JS{{}} block anymore
|
||||
- added `stateGet` and `stateSet` functions
|
||||
- added `storage` object, proxy to the document's sessionStorage object (allows storing data that persist after page refresh, but not closing)
|
||||
- added `storage` object, proxy to the document's localStorage object (allows storing data that persist after refresh/close (cleared with the browser's cache)
|
||||
- added `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` function proxies with an extra `id` argument (they clear automatically when called multiple times and upon widget removal. `id` is scoped to the widget)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,10 +65,17 @@ class Script extends Widget {
|
|||
|
||||
if (this.getProp('event') === 'value') {
|
||||
|
||||
this.script = scriptVm.compile(this.getProp('script'), {
|
||||
id: '',
|
||||
value: 0
|
||||
})
|
||||
try {
|
||||
this.script = scriptVm.compile(this.getProp('script'), {
|
||||
id: '',
|
||||
value: 0
|
||||
})
|
||||
} catch(err) {
|
||||
var stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
this.script = ()=>{}
|
||||
}
|
||||
|
||||
} else if (this.getProp('event') === 'keyboard' && this.getProp('keyBinding')) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue