Skip to content

Commit

Permalink
[JS] Formatted value has to be a string when neither null nor undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed May 8, 2022
1 parent cfac6fa commit ab3958d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,8 @@ class WidgetAnnotation extends Annotation {
}
}

assert(typeof value === "string", "Expected `value` to be a string.");

value = value.trim();

if (value === "") {
Expand Down
4 changes: 2 additions & 2 deletions src/scripting_api/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class EventDispatcher {
let formattedValue = null;

if (this.runActions(source, source, event, "Format")) {
formattedValue = event.value;
formattedValue = event.value?.toString?.();
}

source.obj._send({
Expand Down Expand Up @@ -296,7 +296,7 @@ class EventDispatcher {
savedValue = event.value = target.obj.value;
let formattedValue = null;
if (this.runActions(target, target, event, "Format")) {
formattedValue = event.value;
formattedValue = event.value?.toString?.();
}

target.obj._send({
Expand Down

0 comments on commit ab3958d

Please sign in to comment.