LibWeb: Use Reflect for HTMLAnchorElement.referrerPolicy

This commit is contained in:
Jamie Mansfield 2024-05-31 21:14:26 +01:00 committed by Andreas Kling
commit 469cbe78de
Notes: sideshowbarker 2024-07-16 22:14:49 +09:00
3 changed files with 2 additions and 27 deletions

View file

@ -156,27 +156,4 @@ void HTMLAnchorElement::set_text(String const& text)
string_replace_all(text);
}
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-referrerpolicy
StringView HTMLAnchorElement::referrer_policy() const
{
// FIXME: This should probably be `Reflect` in the IDL.
// The IDL attribute referrerPolicy must reflect the referrerpolicy content attribute, limited to only known values.
auto maybe_policy_string = attribute(HTML::AttributeNames::referrerpolicy);
if (!maybe_policy_string.has_value())
return ""sv;
auto maybe_policy = ReferrerPolicy::from_string(maybe_policy_string.value());
if (!maybe_policy.has_value())
return ""sv;
return ReferrerPolicy::to_string(maybe_policy.value());
}
// https://html.spec.whatwg.org/multipage/text-level-semantics.html#dom-a-referrerpolicy
WebIDL::ExceptionOr<void> HTMLAnchorElement::set_referrer_policy(String const& referrer_policy)
{
// The IDL attribute referrerPolicy must reflect the referrerpolicy content attribute, limited to only known values.
return set_attribute(HTML::AttributeNames::referrerpolicy, referrer_policy);
}
}