summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML
diff options
context:
space:
mode:
authorKyle Lanmon <kyle.lanmon@gmail.com>2022-12-04 22:48:36 -0600
committerLinus Groh <mail@linusgroh.de>2022-12-15 09:43:41 +0000
commit0991464de681f460c5ffdbe17444f0d5d52052e7 (patch)
tree14add8566af62b8b6560d0ffb940687b87c73bbc /Userland/Libraries/LibWeb/HTML
parentc5b953e51b60a54cddf28d1519b6c5865001dae1 (diff)
downloadserenity-0991464de681f460c5ffdbe17444f0d5d52052e7.zip
LibWeb: Implement input range type sanitation algorithm
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index c0aaf0b2df..ef824c4448 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -720,6 +720,11 @@ DeprecatedString HTMLInputElement::value_sanitization_algorithm(DeprecatedString
if (is_valid_local_date_and_time_string(value))
return normalize_local_date_and_time_string(value);
return "";
+ } else if (type_state() == HTMLInputElement::TypeAttributeState::Range) {
+ // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):value-sanitization-algorithm
+ auto maybe_double = value.to_double(TrimWhitespace::Yes);
+ if (!maybe_double.has_value() || !isfinite(maybe_double.value()))
+ return JS::number_to_string(maybe_double.value_or(0));
} else if (type_state() == HTMLInputElement::TypeAttributeState::Color) {
// https://html.spec.whatwg.org/multipage/input.html#color-state-(type=color):value-sanitization-algorithm
// If the value of the element is a valid simple color, then set it to the value of the element converted to ASCII lowercase;
@@ -728,8 +733,6 @@ DeprecatedString HTMLInputElement::value_sanitization_algorithm(DeprecatedString
// otherwise, set it to the string "#000000".
return "#000000";
}
-
- // FIXME: Implement remaining value sanitation algorithms
return value;
}