diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index db8d71abc3..4de76994a0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -139,4 +139,17 @@ void HTMLFormElement::remove_associated_element(Badge, HT m_associated_elements.remove_first_matching([&](auto& entry) { return entry.ptr() == &element; }); } +// https://html.spec.whatwg.org/#dom-fs-action +String HTMLFormElement::action() const +{ + auto value = attribute(HTML::AttributeNames::action); + + // Return the current URL if the action attribute is null or an empty string + if (value.is_null() || value.is_empty()) { + return document().url().to_string(); + } + + return value; +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h index 6935e240ca..966dbbebe7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -18,7 +18,7 @@ public: HTMLFormElement(DOM::Document&, QualifiedName); virtual ~HTMLFormElement() override; - String action() const { return attribute(HTML::AttributeNames::action); } + String action() const; String method() const { return attribute(HTML::AttributeNames::method); } void submit_form(RefPtr submitter, bool from_submit_binding = false);