Skip to content

Commit

Permalink
LibWeb: Add HTMLAnchorElement.text getter and setter
Browse files Browse the repository at this point in the history
And a FIXME for the missing `referrerPolicy` property.
  • Loading branch information
AtkinsSJ authored and linusg committed Mar 31, 2023
1 parent 888efe3 commit 0c19d3a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,18 @@ Optional<ARIA::Role> HTMLAnchorElement::default_role() const
return ARIA::Role::generic;
}

// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-text
DeprecatedString HTMLAnchorElement::text() const
{
// The text attribute's getter must return this element's descendant text content.
return descendant_text_content();
}

// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-text
void HTMLAnchorElement::set_text(DeprecatedString const& text)
{
// The text attribute's setter must string replace all with the given value within this element.
string_replace_all(text);
}

}
3 changes: 3 additions & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class HTMLAnchorElement final
DeprecatedString target() const { return attribute(HTML::AttributeNames::target); }
DeprecatedString download() const { return attribute(HTML::AttributeNames::download); }

DeprecatedString text() const;
void set_text(DeprecatedString const&);

// ^EventTarget
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-a-element
virtual bool is_focusable() const override { return has_attribute(HTML::AttributeNames::href); }
Expand Down
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface HTMLAnchorElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString hreflang;
[CEReactions, Reflect] attribute DOMString type;

[CEReactions] attribute DOMString text;

// Obsolete
[CEReactions, Reflect] attribute DOMString coords;
[CEReactions, Reflect] attribute DOMString charset;
Expand Down

0 comments on commit 0c19d3a

Please sign in to comment.