mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-20 01:01:54 +00:00
LibWeb: Return document URL if formAction attribute is missing or empty
This change also ensures that relative URLs are resolved relative to the document's base URL.
This commit is contained in:
parent
f83d082980
commit
c25dda767e
Notes:
github-actions[bot]
2024-09-08 07:48:53 +00:00
Author: https://github.com/tcl3
Commit: c25dda767e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1321
5 changed files with 47 additions and 1 deletions
|
@ -166,6 +166,27 @@ void FormAssociatedElement::reset_form_owner()
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-fs-formaction
|
||||
String FormAssociatedElement::form_action() const
|
||||
{
|
||||
// The formAction IDL attribute must reflect the formaction content attribute, except that on getting, when the content attribute is missing or its value is the empty string,
|
||||
// the element's node document's URL must be returned instead.
|
||||
auto& html_element = form_associated_element_to_html_element();
|
||||
auto form_action_attribute = html_element.attribute(HTML::AttributeNames::formaction);
|
||||
if (!form_action_attribute.has_value() || form_action_attribute.value().is_empty()) {
|
||||
return html_element.document().url_string();
|
||||
}
|
||||
|
||||
auto document_base_url = html_element.document().base_url();
|
||||
return MUST(document_base_url.complete_url(form_action_attribute.value()).to_string());
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> FormAssociatedElement::set_form_action(String const& value)
|
||||
{
|
||||
auto& html_element = form_associated_element_to_html_element();
|
||||
return html_element.set_attribute(HTML::AttributeNames::formaction, value);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value
|
||||
void FormAssociatedTextControlElement::relevant_value_was_changed(JS::GCPtr<DOM::Text> text_node)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue