mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Limit HTMLProgressElement.max
to positive values
Previously, 0 was returned if `HTMLProgressElement.max` was set to a negative value.
This commit is contained in:
parent
a94bf9bd09
commit
353e3e75dc
Notes:
github-actions[bot]
2024-08-19 07:03:11 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/353e3e75dcf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1118
3 changed files with 5 additions and 1 deletions
|
@ -2,6 +2,7 @@ value attribute initial value: 0
|
|||
max attribute initial value: 1
|
||||
value attribute after setting value attribute to -1: 0
|
||||
max attribute after setting max attribute to -1: 1
|
||||
max attribute after setting max attribute to 0: 1
|
||||
value attribute after setting value attribute to 50: 1
|
||||
value attribute after setting max attribute to 100: 50
|
||||
max attribute after setting max attribute to 100: 100
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
println(`value attribute after setting value attribute to -1: ${progressElement.value}`);
|
||||
progressElement.max = -1;
|
||||
println(`max attribute after setting max attribute to -1: ${progressElement.max}`);
|
||||
progressElement.max = 0;
|
||||
println(`max attribute after setting max attribute to 0: ${progressElement.max}`);
|
||||
progressElement.value = 50;
|
||||
println(`value attribute after setting value attribute to 50: ${progressElement.value}`);
|
||||
progressElement.max = 100;
|
||||
|
|
|
@ -64,7 +64,8 @@ double HTMLProgressElement::max() const
|
|||
{
|
||||
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())
|
||||
return AK::max(*max, 0);
|
||||
if (*max > 0)
|
||||
return *max;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue