LibWeb: Implement the HTMLAreaElement.relList attribute

This returns a DOMTokenList that reflects the `rel` attribute.
This commit is contained in:
Tim Ledbetter 2024-05-16 06:02:56 +01:00 committed by Andreas Kling
parent b7fd39c2e6
commit 0a3e1846f0
Notes: sideshowbarker 2024-07-17 02:29:45 +09:00
5 changed files with 24 additions and 1 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/Bindings/HTMLAreaElementPrototype.h>
#include <LibWeb/DOM/DOMTokenList.h>
#include <LibWeb/HTML/HTMLAreaElement.h>
#include <LibWeb/HTML/Window.h>
@ -31,9 +32,21 @@ void HTMLAreaElement::attribute_changed(FlyString const& name, Optional<String>
HTMLElement::attribute_changed(name, value);
if (name == HTML::AttributeNames::href) {
set_the_url();
} else if (name == HTML::AttributeNames::rel) {
if (m_rel_list)
m_rel_list->associated_attribute_changed(value.value_or(String {}));
}
}
// https://html.spec.whatwg.org/multipage/image-maps.html#dom-area-rellist
JS::GCPtr<DOM::DOMTokenList> HTMLAreaElement::rel_list()
{
// The IDL attribute relList must reflect the rel content attribute.
if (!m_rel_list)
m_rel_list = DOM::DOMTokenList::create(*this, HTML::AttributeNames::rel);
return m_rel_list;
}
Optional<String> HTMLAreaElement::hyperlink_element_utils_href() const
{
return attribute(HTML::AttributeNames::href);