mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Use correct integer parsing rules in HTMLOListElement::start()
This commit is contained in:
parent
a61883ae88
commit
9face18ab2
Notes:
github-actions[bot]
2024-11-26 18:51:13 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/9face18ab26 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2593
2 changed files with 14 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <LibWeb/Bindings/HTMLOListElementPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/HTMLOListElement.h>
|
||||
#include <LibWeb/HTML/Numbers.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -25,4 +26,14 @@ void HTMLOListElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLOListElement);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/grouping-content.html#dom-ol-start
|
||||
WebIDL::Long HTMLOListElement::start()
|
||||
{
|
||||
// The start IDL attribute must reflect the content attribute of the same name, with a default value of 1.
|
||||
auto content_attribute_value = get_attribute(AttributeNames::start).value_or("1"_string);
|
||||
if (auto maybe_number = HTML::parse_integer(content_attribute_value); maybe_number.has_value())
|
||||
return *maybe_number;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <LibWeb/ARIA/Roles.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/WebIDL/Types.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -21,8 +22,8 @@ public:
|
|||
// https://www.w3.org/TR/html-aria/#el-ol
|
||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::list; }
|
||||
|
||||
i32 start() { return get_attribute(AttributeNames::start).value_or("1"_string).to_number<i32>().value_or(1); }
|
||||
void set_start(i32 start)
|
||||
WebIDL::Long start();
|
||||
void set_start(WebIDL::Long start)
|
||||
{
|
||||
set_attribute(AttributeNames::start, String::number(start)).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue