mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +00:00
LibWeb: Check all <fieldset> ancestors in FormAssociatedElement::enabled
A form associated element is disabled if _any_ <fieldset> ancestor in the ancestor chain has the disabled attribute, not just the first one.
This commit is contained in:
parent
30815c25a2
commit
c85fcd442f
1 changed files with 6 additions and 5 deletions
|
@ -37,11 +37,12 @@ bool FormAssociatedElement::enabled() const
|
|||
return false;
|
||||
|
||||
// 2. The element is a descendant of a fieldset element whose disabled attribute is specified, and is not a descendant of that fieldset element's first legend element child, if any.
|
||||
auto* fieldset_ancestor = html_element.first_ancestor_of_type<HTMLFieldSetElement>();
|
||||
if (fieldset_ancestor && fieldset_ancestor->has_attribute(HTML::AttributeNames::disabled)) {
|
||||
auto* first_legend_element_child = fieldset_ancestor->first_child_of_type<HTMLLegendElement>();
|
||||
if (!first_legend_element_child || !html_element.is_descendant_of(*first_legend_element_child))
|
||||
return false;
|
||||
for (auto* fieldset_ancestor = html_element.first_ancestor_of_type<HTMLFieldSetElement>(); fieldset_ancestor; fieldset_ancestor = fieldset_ancestor->first_ancestor_of_type<HTMLFieldSetElement>()) {
|
||||
if (fieldset_ancestor->has_attribute(HTML::AttributeNames::disabled)) {
|
||||
auto* first_legend_element_child = fieldset_ancestor->first_child_of_type<HTMLLegendElement>();
|
||||
if (!first_legend_element_child || !html_element.is_descendant_of(*first_legend_element_child))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue