mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb: Make HTMLInputElement of type number use the new double parser
This commit is contained in:
parent
8abd4f6102
commit
6e9969ded0
Notes:
sideshowbarker
2024-07-18 04:38:32 +09:00
Author: https://github.com/davidot
Commit: 6e9969ded0
Pull-request: https://github.com/SerenityOS/serenity/pull/15377
Issue: https://github.com/SerenityOS/serenity/issues/14691
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/linusg
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