diff --git a/CHANGELOG.md b/CHANGELOG.md index e29baf40..7ecfe2b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - misc: sending typed arguments (`{type, value}` objects) should override the widget's `typeTags` definition - multixy: errors when `ephemeral` is `true` - scripting: `setVar` not affecting all widgets when mutliple widgets match provided id - + - widgets - renamed `script` to `onValue`, `draw` to `onDraw`, `touch` to `onTouch` - added `onCreate` script property to all widgets @@ -14,6 +14,9 @@ - script: added `onKeyboard` property, removed `event` property - canvas: expose additional touch event informations (`radiusX`, `radiusY`, `rotationAngle` and iOS-only `altitudeAngle`, `azimuthAngle` and `touchType`) +- scripting + - special keyword `this` now returns the string `"this"` + - advanced syntaxes - added `IMPORT{file}` syntax to allow loading external files in properties diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index b197b562..809952a7 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -111,6 +111,9 @@ The following variables and functions are accessible in this context. - `session`: session file path - `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard) +!!! note "this" + Unlike in most javascript contexts, the special keyword `this` doesn't point to an object but instead returns the string `"this"`. + ---- diff --git a/src/client/widgets/vm.js b/src/client/widgets/vm.js index ccba0bb6..e0d0e66f 100644 --- a/src/client/widgets/vm.js +++ b/src/client/widgets/vm.js @@ -136,7 +136,7 @@ class Vm { this.sanitize(__contextValues) - return compiledCode.apply(null, __contextValues) + return compiledCode.apply("this", __contextValues) }