Browse Source

LibWeb: Port HTMLFormElement from ByteString

Shannon Booth 1 year ago
parent
commit
10e5458e27

+ 9 - 7
Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp

@@ -162,7 +162,7 @@ WebIDL::ExceptionOr<void> HTMLFormElement::submit_form(JS::NonnullGCPtr<HTMLElem
 
 
     // 13. If action is the empty string, let action be the URL of the form document.
     // 13. If action is the empty string, let action be the URL of the form document.
     if (action.is_empty())
     if (action.is_empty())
-        action = form_document->url_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.
     // 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.
     // 15. Let parsed action be the resulting URL record.
@@ -302,19 +302,21 @@ void HTMLFormElement::remove_associated_element(Badge<FormAssociatedElement>, HT
 }
 }
 
 
 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fs-action
 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fs-action
-ByteString HTMLFormElement::action_from_form_element(JS::NonnullGCPtr<HTMLElement> element) const
+String HTMLFormElement::action_from_form_element(JS::NonnullGCPtr<HTMLElement> element) const
 {
 {
     // The action of an element is the value of the element's formaction attribute, if the element is a submit button
     // 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
     // and has such an attribute, or the value of its form owner's action attribute, if it has one, or else the empty
     // string.
     // string.
     if (auto const* form_associated_element = dynamic_cast<FormAssociatedElement const*>(element.ptr());
     if (auto const* form_associated_element = dynamic_cast<FormAssociatedElement const*>(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
 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-attributes:attr-fs-method-2

+ 1 - 1
Userland/Libraries/LibWeb/HTML/HTMLFormElement.h

@@ -35,7 +35,7 @@ class HTMLFormElement final : public HTMLElement {
 public:
 public:
     virtual ~HTMLFormElement() override;
     virtual ~HTMLFormElement() override;
 
 
-    ByteString action_from_form_element(JS::NonnullGCPtr<HTMLElement> element) const;
+    String action_from_form_element(JS::NonnullGCPtr<HTMLElement> element) const;
 
 
     enum class MethodAttributeState {
     enum class MethodAttributeState {
 #define __ENUMERATE_FORM_METHOD_ATTRIBUTE(_, state) state,
 #define __ENUMERATE_FORM_METHOD_ATTRIBUTE(_, state) state,