mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 10:24:57 +00:00
LibWeb: Make HTMLInputElement of type number use the new double parser
This commit is contained in:
parent
8abd4f6102
commit
6e9969ded0
1 changed files with 4 additions and 3 deletions
|
@ -446,9 +446,10 @@ String HTMLInputElement::value_sanitization_algorithm(String value) const
|
|||
}
|
||||
} else if (type_state() == HTMLInputElement::TypeAttributeState::Number) {
|
||||
// If the value of the element is not a valid floating-point number, then set it to the empty string instead.
|
||||
char* end_ptr;
|
||||
auto val = strtod(value.characters(), &end_ptr);
|
||||
if (!isfinite(val) || *end_ptr)
|
||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values
|
||||
// 6. Skip ASCII whitespace within input given position.
|
||||
auto maybe_double = value.to_double(TrimWhitespace::Yes);
|
||||
if (!maybe_double.has_value() || !isfinite(maybe_double.value()))
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue