mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
implement range input sanitization
This commit is contained in:
parent
525758ea5e
commit
b29230bd76
6 changed files with 75 additions and 19 deletions
|
@ -1047,11 +1047,17 @@ impl HTMLInputElement {
|
|||
}
|
||||
InputType::Number => {
|
||||
let mut textinput = self.textinput.borrow_mut();
|
||||
if !textinput.single_line_content().is_valid_number_string() {
|
||||
if !textinput.single_line_content().is_valid_floating_point_number_string() {
|
||||
textinput.single_line_content_mut().clear();
|
||||
}
|
||||
}
|
||||
// TODO: Implement more value sanitization algorithms for different types of inputs
|
||||
// https://html.spec.whatwg.org/multipage/#range-state-(type=range):value-sanitization-algorithm
|
||||
InputType::Range => {
|
||||
self.textinput
|
||||
.borrow_mut()
|
||||
.single_line_content_mut()
|
||||
.set_best_representation_of_the_floating_point_number();
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue