mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 18:19:03 +00:00
LibWeb: Ignore negative values when setting HTMLProgressElement.max
When attempting to set `HTMLProgressElement.max` to a value not greater than 0, we were previously setting the value to 1. We now retain the previous value.
This commit is contained in:
parent
81f8866606
commit
99f8972928
Notes:
github-actions[bot]
2024-11-29 14:32:57 +00:00
Author: https://github.com/tcl3
Commit: 99f8972928
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2637
3 changed files with 5 additions and 5 deletions
|
@ -61,7 +61,7 @@ WebIDL::ExceptionOr<void> HTMLProgressElement::set_value(double value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-progress-max
|
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-progress-max
|
||||||
double HTMLProgressElement::max() const
|
WebIDL::Double HTMLProgressElement::max() const
|
||||||
{
|
{
|
||||||
if (auto max_string = get_attribute(HTML::AttributeNames::max); max_string.has_value()) {
|
if (auto max_string = get_attribute(HTML::AttributeNames::max); max_string.has_value()) {
|
||||||
if (auto max = parse_floating_point_number(*max_string); max.has_value())
|
if (auto max = parse_floating_point_number(*max_string); max.has_value())
|
||||||
|
@ -74,7 +74,7 @@ double HTMLProgressElement::max() const
|
||||||
WebIDL::ExceptionOr<void> HTMLProgressElement::set_max(double value)
|
WebIDL::ExceptionOr<void> HTMLProgressElement::set_max(double value)
|
||||||
{
|
{
|
||||||
if (value <= 0)
|
if (value <= 0)
|
||||||
value = 1;
|
return {};
|
||||||
|
|
||||||
TRY(set_attribute(HTML::AttributeNames::max, String::number(value)));
|
TRY(set_attribute(HTML::AttributeNames::max, String::number(value)));
|
||||||
update_progress_value_element();
|
update_progress_value_element();
|
||||||
|
|
|
@ -22,8 +22,8 @@ public:
|
||||||
double value() const;
|
double value() const;
|
||||||
WebIDL::ExceptionOr<void> set_value(double);
|
WebIDL::ExceptionOr<void> set_value(double);
|
||||||
|
|
||||||
double max() const;
|
WebIDL::Double max() const;
|
||||||
WebIDL::ExceptionOr<void> set_max(double value);
|
WebIDL::ExceptionOr<void> set_max(WebIDL::Double value);
|
||||||
|
|
||||||
double position() const;
|
double position() const;
|
||||||
|
|
||||||
|
|
|
@ -9,4 +9,4 @@ max attribute after setting max attribute to 100: 100
|
||||||
value attribute after setting max attribute to 101: 100
|
value attribute after setting max attribute to 101: 100
|
||||||
value attribute after setting value attribute to -1: 0
|
value attribute after setting value attribute to -1: 0
|
||||||
value attribute after setting max attribute to 0: 0
|
value attribute after setting max attribute to 0: 0
|
||||||
max attribute after setting max attribute to 0: 1
|
max attribute after setting max attribute to 0: 100
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue