JS: Make field.value return a number if possible

Quoting the Adobe documentation
 'for a field with a value of “020”, value returns the integer 20'

BUGS: 467852
remotes/origin/work/sune/use-parsed-distinguished-name
Albert Astals Cid 3 years ago
parent 128a2a778f
commit 09038f4fb5
  1. 9
      core/script/kjs_field.cpp

@ -134,7 +134,14 @@ static KJSObject fieldGetValue(KJSContext * /*context*/, void *object)
}
case FormField::FormText: {
const FormFieldText *text = static_cast<const FormFieldText *>(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<const FormFieldChoice *>(field);

Loading…
Cancel
Save