1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:38:11 +00:00

LibWeb: Port HTMLBaseElement interface from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-09-03 15:46:55 +12:00 committed by Tim Flynn
parent 2a732e6ddd
commit c405ba6b08
3 changed files with 8 additions and 10 deletions

View file

@ -80,15 +80,13 @@ void HTMLBaseElement::set_the_frozen_base_url()
} }
// https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href // https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href
DeprecatedString HTMLBaseElement::href() const String HTMLBaseElement::href() const
{ {
// 1. Let document be element's node document. // 1. Let document be element's node document.
auto& document = this->document(); auto const& document = this->document();
// 2. Let url be the value of the href attribute of this element, if it has one, and the empty string otherwise. // 2. Let url be the value of the href attribute of this element, if it has one, and the empty string otherwise.
auto url = DeprecatedString::empty(); auto url = attribute(AttributeNames::href).value_or(String {});
if (has_attribute(AttributeNames::href))
url = deprecated_attribute(AttributeNames::href);
// 3. Let urlRecord be the result of parsing url with document's fallback base URL, and document's character encoding. (Thus, the base element isn't affected by other base elements or itself.) // 3. Let urlRecord be the result of parsing url with document's fallback base URL, and document's character encoding. (Thus, the base element isn't affected by other base elements or itself.)
// FIXME: Pass in document's character encoding. // FIXME: Pass in document's character encoding.
@ -99,11 +97,11 @@ DeprecatedString HTMLBaseElement::href() const
return url; return url;
// 5. Return the serialization of urlRecord. // 5. Return the serialization of urlRecord.
return url_record.to_deprecated_string(); return MUST(url_record.to_string());
} }
// https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href // https://html.spec.whatwg.org/multipage/semantics.html#dom-base-href
WebIDL::ExceptionOr<void> HTMLBaseElement::set_href(DeprecatedString const& href) WebIDL::ExceptionOr<void> HTMLBaseElement::set_href(String const& href)
{ {
// The href IDL attribute, on setting, must set the href content attribute to the given new value. // The href IDL attribute, on setting, must set the href content attribute to the given new value.
return set_attribute(AttributeNames::href, href); return set_attribute(AttributeNames::href, href);

View file

@ -16,8 +16,8 @@ class HTMLBaseElement final : public HTMLElement {
public: public:
virtual ~HTMLBaseElement() override; virtual ~HTMLBaseElement() override;
DeprecatedString href() const; String href() const;
WebIDL::ExceptionOr<void> set_href(DeprecatedString const& href); WebIDL::ExceptionOr<void> set_href(String const& href);
AK::URL const& frozen_base_url() const { return m_frozen_base_url; } AK::URL const& frozen_base_url() const { return m_frozen_base_url; }

View file

@ -1,7 +1,7 @@
#import <HTML/HTMLElement.idl> #import <HTML/HTMLElement.idl>
// https://html.spec.whatwg.org/multipage/semantics.html#htmlbaseelement // https://html.spec.whatwg.org/multipage/semantics.html#htmlbaseelement
[Exposed=Window, UseDeprecatedAKString] [Exposed=Window]
interface HTMLBaseElement : HTMLElement { interface HTMLBaseElement : HTMLElement {
[HTMLConstructor] constructor(); [HTMLConstructor] constructor();