From ab3958d6e835ca9b522d11eb3798b4a86a22de42 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 8 May 2022 15:43:02 +0200 Subject: [PATCH] [JS] Formatted value has to be a string when neither null nor undefined --- src/core/annotation.js | 2 ++ src/scripting_api/event.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/annotation.js b/src/core/annotation.js index 6f6c533e13f77..7105516393e42 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1532,6 +1532,8 @@ class WidgetAnnotation extends Annotation { } } + assert(typeof value === "string", "Expected `value` to be a string."); + value = value.trim(); if (value === "") { diff --git a/src/scripting_api/event.js b/src/scripting_api/event.js index c57f3ddae15a5..f4036bb2643e6 100644 --- a/src/scripting_api/event.js +++ b/src/scripting_api/event.js @@ -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({ @@ -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({