mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
LibWeb: Return FACEs from HTML{FieldSet,Form}Element#elements
This commit is contained in:
parent
e111945611
commit
9af3e34875
Notes:
github-actions[bot]
2026-03-25 13:20:51 +00:00
Author: https://github.com/Lubrsi
Commit: 9af3e34875
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8534
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/tcl3
3 changed files with 10 additions and 36 deletions
|
|
@ -78,14 +78,10 @@ GC::Ptr<DOM::HTMLCollection> const& HTMLFieldSetElement::elements()
|
|||
// The elements IDL attribute must return an HTMLCollection rooted at the fieldset element, whose filter matches listed elements.
|
||||
if (!m_elements) {
|
||||
m_elements = DOM::HTMLCollection::create(*this, DOM::HTMLCollection::Scope::Descendants, [](DOM::Element const& element) {
|
||||
// FIXME: Form-associated custom elements return also true
|
||||
return is<HTMLButtonElement>(element)
|
||||
|| is<HTMLFieldSetElement>(element)
|
||||
|| is<HTMLInputElement>(element)
|
||||
|| is<HTMLObjectElement>(element)
|
||||
|| is<HTMLOutputElement>(element)
|
||||
|| is<HTMLSelectElement>(element)
|
||||
|| is<HTMLTextAreaElement>(element);
|
||||
if (auto const* form_associated_element = as_if<FormAssociatedElement>(element); form_associated_element && form_associated_element->is_listed())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return m_elements;
|
||||
|
|
|
|||
|
|
@ -507,29 +507,6 @@ HTMLFormElement::EncodingTypeAttributeState HTMLFormElement::encoding_type_state
|
|||
return EncodingTypeAttributeState::FormUrlEncoded;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
|
||||
static bool is_listed_element(DOM::Element const& element)
|
||||
{
|
||||
// Denotes elements that are listed in the form.elements and fieldset.elements APIs.
|
||||
// These elements also have a form content attribute, and a matching form IDL attribute,
|
||||
// that allow authors to specify an explicit form owner.
|
||||
// => button, fieldset, input, object, output, select, textarea, form-associated custom elements
|
||||
|
||||
if (is<HTMLButtonElement>(element)
|
||||
|| is<HTMLFieldSetElement>(element)
|
||||
|| is<HTMLInputElement>(element)
|
||||
|| is<HTMLObjectElement>(element)
|
||||
|| is<HTMLOutputElement>(element)
|
||||
|| is<HTMLSelectElement>(element)
|
||||
|| is<HTMLTextAreaElement>(element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: Form-associated custom elements return also true
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool is_form_control(DOM::Element const& element, HTMLFormElement const& form)
|
||||
{
|
||||
// The elements IDL attribute must return an HTMLFormControlsCollection rooted at the form element's root,
|
||||
|
|
@ -537,9 +514,6 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const&
|
|||
// with the exception of input elements whose type attribute is in the Image Button state, which must,
|
||||
// for historical reasons, be excluded from this particular collection.
|
||||
|
||||
if (!is_listed_element(element))
|
||||
return false;
|
||||
|
||||
if (is<HTMLInputElement>(element)
|
||||
&& static_cast<HTMLInputElement const&>(element).type_state() == HTMLInputElement::TypeAttributeState::ImageButton) {
|
||||
return false;
|
||||
|
|
@ -549,6 +523,9 @@ static bool is_form_control(DOM::Element const& element, HTMLFormElement const&
|
|||
if (form_associated_element.form() != &form)
|
||||
return false;
|
||||
|
||||
if (!form_associated_element.is_listed())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ Harness status: OK
|
|||
|
||||
Found 3 tests
|
||||
|
||||
3 Fail
|
||||
1 Pass
|
||||
2 Fail
|
||||
Fail Form associated custom elements should work with document.forms.elements.namedItem()
|
||||
Fail Form associated custom elements should work with document.forms.elements.namedItem() after upgrading
|
||||
Fail Form associated custom elements should work with document.forms.elements.namedItem() after updating the name attribute
|
||||
Pass Form associated custom elements should work with document.forms.elements.namedItem() after updating the name attribute
|
||||
Loading…
Add table
Add a link
Reference in a new issue