mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 09:52:54 +00:00
LibWeb: Use correct integer parsing rules in HTMLLIElement::value()
This commit is contained in:
parent
67d05b0104
commit
a61883ae88
Notes:
github-actions[bot]
2024-11-26 18:51:19 +00:00
Author: https://github.com/tcl3
Commit: a61883ae88
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2593
2 changed files with 16 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibWeb/Bindings/HTMLLIElementPrototype.h>
|
||||
#include <LibWeb/HTML/HTMLLIElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -25,4 +26,16 @@ void HTMLLIElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLIElement);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/grouping-content.html#dom-li-value
|
||||
WebIDL::Long HTMLLIElement::value()
|
||||
{
|
||||
// The value IDL attribute must reflect the value of the value content attribute.
|
||||
// NOTE: This is equivalent to the code that would be generated by the IDL generator if we used [Reflect] on the value attribute.
|
||||
// We don't do that in this case, since this method is used elsewhere.
|
||||
auto content_attribute_value = get_attribute(AttributeNames::value).value_or("0"_string);
|
||||
if (auto maybe_number = HTML::parse_integer(content_attribute_value); maybe_number.has_value())
|
||||
return *maybe_number;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue