From 10e5458e27541109a375024cb47d4e6ec9873e9b Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 24 Dec 2023 15:51:37 +1300 Subject: [PATCH] LibWeb: Port HTMLFormElement from ByteString --- .../Libraries/LibWeb/HTML/HTMLFormElement.cpp | 16 +++++++++------- Userland/Libraries/LibWeb/HTML/HTMLFormElement.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 39adfef256..33423a307e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -162,7 +162,7 @@ WebIDL::ExceptionOr HTMLFormElement::submit_form(JS::NonnullGCPtrurl_string().to_byte_string(); + action = form_document->url_string(); // 14. Parse a URL given action, relative to the submitter element's node document. If this fails, return. // 15. Let parsed action be the resulting URL record. @@ -302,19 +302,21 @@ void HTMLFormElement::remove_associated_element(Badge, HT } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fs-action -ByteString HTMLFormElement::action_from_form_element(JS::NonnullGCPtr element) const +String HTMLFormElement::action_from_form_element(JS::NonnullGCPtr element) const { // The action of an element is the value of the element's formaction attribute, if the element is a submit button // and has such an attribute, or the value of its form owner's action attribute, if it has one, or else the empty // string. if (auto const* form_associated_element = dynamic_cast(element.ptr()); - form_associated_element && form_associated_element->is_submit_button() && element->has_attribute(AttributeNames::formaction)) - return deprecated_attribute(AttributeNames::formaction); + form_associated_element && form_associated_element->is_submit_button()) { + if (auto maybe_attribute = element->attribute(AttributeNames::formaction); maybe_attribute.has_value()) + return maybe_attribute.release_value(); + } - if (this->has_attribute(AttributeNames::action)) - return deprecated_attribute(AttributeNames::action); + if (auto maybe_attribute = attribute(AttributeNames::action); maybe_attribute.has_value()) + return maybe_attribute.release_value(); - return ByteString::empty(); + return String {}; } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-attributes:attr-fs-method-2 diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index b5f24864ce..24294ccd8c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -35,7 +35,7 @@ class HTMLFormElement final : public HTMLElement { public: virtual ~HTMLFormElement() override; - ByteString action_from_form_element(JS::NonnullGCPtr element) const; + String action_from_form_element(JS::NonnullGCPtr element) const; enum class MethodAttributeState { #define __ENUMERATE_FORM_METHOD_ATTRIBUTE(_, state) state,