mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 11:06:10 +00:00
LibWeb: Implement the HTMLAnchorElement.relList
attribute
This returns a DOMTokenList that reflects the `rel` attribute.
This commit is contained in:
parent
63246577d2
commit
b7fd39c2e6
Notes:
sideshowbarker
2024-07-17 03:51:15 +09:00
Author: https://github.com/tcl3
Commit: b7fd39c2e6
Pull-request: https://github.com/SerenityOS/serenity/pull/24342
5 changed files with 50 additions and 1 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <LibWeb/ARIA/Roles.h>
|
||||
#include <LibWeb/Bindings/HTMLAnchorElementPrototype.h>
|
||||
#include <LibWeb/DOM/DOMTokenList.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
|
@ -38,6 +39,9 @@ void HTMLAnchorElement::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 {}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,6 +127,15 @@ Optional<ARIA::Role> HTMLAnchorElement::default_role() const
|
|||
return ARIA::Role::generic;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-rellist
|
||||
JS::GCPtr<DOM::DOMTokenList> HTMLAnchorElement::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;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-text
|
||||
String HTMLAnchorElement::text() const
|
||||
{
|
||||
|
|
|
@ -24,6 +24,8 @@ public:
|
|||
String target() const { return get_attribute_value(HTML::AttributeNames::target); }
|
||||
String download() const { return get_attribute_value(HTML::AttributeNames::download); }
|
||||
|
||||
JS::GCPtr<DOM::DOMTokenList> rel_list();
|
||||
|
||||
String text() const;
|
||||
void set_text(String const&);
|
||||
|
||||
|
@ -68,6 +70,8 @@ private:
|
|||
}
|
||||
|
||||
virtual Optional<ARIA::Role> default_role() const override;
|
||||
|
||||
JS::GCPtr<DOM::DOMTokenList> m_rel_list;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ interface HTMLAnchorElement : HTMLElement {
|
|||
[CEReactions, Reflect] attribute DOMString download;
|
||||
[CEReactions, Reflect] attribute DOMString ping;
|
||||
[CEReactions, Reflect] attribute DOMString rel;
|
||||
// FIXME: [SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
||||
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
||||
[CEReactions, Reflect] attribute DOMString hreflang;
|
||||
[CEReactions, Reflect] attribute DOMString type;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue