LibWeb: Port HTMLFormElement from ByteString

This commit is contained in:
Shannon Booth 2023-12-24 15:51:37 +13:00 committed by Andreas Kling
parent 0b7c8e0de5
commit 10e5458e27
Notes: sideshowbarker 2024-07-17 04:10:16 +09:00
2 changed files with 10 additions and 8 deletions

View file

@ -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.
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.
// 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
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
// 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<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