From 0c19d3aa588a039f2f22953a703f1e66384e65ce Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 29 Mar 2023 12:38:32 +0100 Subject: [PATCH] LibWeb: Add HTMLAnchorElement.text getter and setter And a FIXME for the missing `referrerPolicy` property. --- .../Libraries/LibWeb/HTML/HTMLAnchorElement.cpp | 14 ++++++++++++++ Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h | 3 +++ .../Libraries/LibWeb/HTML/HTMLAnchorElement.idl | 2 ++ 3 files changed, 19 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 311236b97e6..adc04c6cc26 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -100,4 +100,18 @@ Optional 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); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 64a90ca4697..103ef7d2848 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -23,6 +23,9 @@ public: 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); } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl index 925db85842f..49598f3aeb3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLAnchorElement.idl @@ -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;