mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
fix: Implement additional logic in DOMString::set_best_representation_of_the_floating_point_number in order to correct some failing tests related to -0 values. (#32272)
This commit is contained in:
parent
3d4fd0e550
commit
8eeb888010
6 changed files with 67 additions and 74 deletions
|
@ -10,6 +10,7 @@ use crate::dom::bindings::codegen::Bindings::HTMLProgressElementBinding::HTMLPro
|
|||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::num::Finite;
|
||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
|
@ -75,11 +76,15 @@ impl HTMLProgressElementMethods for HTMLProgressElement {
|
|||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-progress-value
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-progress-value>
|
||||
fn SetValue(&self, new_val: Finite<f64>) {
|
||||
if 0.0 <= *new_val {
|
||||
if *new_val >= 0.0 {
|
||||
let mut string_value = DOMString::from_string((*new_val).to_string());
|
||||
|
||||
string_value.set_best_representation_of_the_floating_point_number();
|
||||
|
||||
self.upcast::<Element>()
|
||||
.set_string_attribute(&local_name!("value"), (*new_val).to_string().into());
|
||||
.set_string_attribute(&local_name!("value"), string_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,10 +105,16 @@ impl HTMLProgressElementMethods for HTMLProgressElement {
|
|||
})
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-progress-max
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-progress-max>
|
||||
fn SetMax(&self, new_val: Finite<f64>) {
|
||||
self.upcast::<Element>()
|
||||
.set_string_attribute(&local_name!("max"), (*new_val).to_string().into());
|
||||
if *new_val > 0.0 {
|
||||
let mut string_value = DOMString::from_string((*new_val).to_string());
|
||||
|
||||
string_value.set_best_representation_of_the_floating_point_number();
|
||||
|
||||
self.upcast::<Element>()
|
||||
.set_string_attribute(&local_name!("max"), string_value);
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-progress-position
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue