From 09038f4fb52b97a9b82cc8dc14ea0d962ad6b0f1 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 28 Mar 2023 19:23:28 +0200 Subject: [PATCH] JS: Make field.value return a number if possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quoting the Adobe documentation 'for a field with a value of “020”, value returns the integer 20' BUGS: 467852 --- core/script/kjs_field.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/script/kjs_field.cpp b/core/script/kjs_field.cpp index bc2862bcb..46af92080 100644 --- a/core/script/kjs_field.cpp +++ b/core/script/kjs_field.cpp @@ -134,7 +134,14 @@ static KJSObject fieldGetValue(KJSContext * /*context*/, void *object) } case FormField::FormText: { const FormFieldText *text = static_cast(field); - return KJSString(text->text()); + const QLocale locale; + bool ok; + const double textAsNumber = locale.toDouble(text->text(), &ok); + if (ok) { + return KJSNumber(textAsNumber); + } else { + return KJSString(text->text()); + } } case FormField::FormChoice: { const FormFieldChoice *choice = static_cast(field);