LibWeb: Add HTML col element span attribute

This commit is contained in:
Bastiaan van der Plaat 2023-11-24 17:40:05 +01:00 committed by Andreas Kling
parent 7e6fc9c26e
commit 01f000acb0
Notes: sideshowbarker 2024-07-17 11:34:34 +09:00
4 changed files with 24 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/HTMLTableColElement.h>
#include <LibWeb/HTML/Numbers.h>
namespace Web::HTML {
@ -24,4 +25,22 @@ void HTMLTableColElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::HTMLTableColElementPrototype>(realm, "HTMLTableColElement"_fly_string));
}
// https://html.spec.whatwg.org/multipage/tables.html#dom-colgroup-span
unsigned int HTMLTableColElement::span() const
{
// The span IDL attribute must reflect the content attribute of the same name. It is clamped to the range [1, 1000], and its default value is 1.
auto maybe_span_string = get_attribute(HTML::AttributeNames::span);
if (maybe_span_string.has_value()) {
auto maybe_span = parse_non_negative_integer(maybe_span_string.value());
if (maybe_span.has_value())
return clamp(maybe_span.value(), 1, 1000);
}
return 1;
}
WebIDL::ExceptionOr<void> HTMLTableColElement::set_span(unsigned int value)
{
return set_attribute(HTML::AttributeNames::span, MUST(String::number(value)));
}
}