Bläddra i källkod

LibWeb: Check all elements in same tree to determine labeled control

Previously, when looking for the labeled control of a label element, we
were only checking its child elements. The specification says we should
check all elements in the same tree as the label element.
Tim Ledbetter 1 år sedan
förälder
incheckning
5296338e7a
1 ändrade filer med 1 tillägg och 1 borttagningar
  1. 1 1
      Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp

+ 1 - 1
Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp

@@ -43,7 +43,7 @@ JS::GCPtr<HTMLElement> HTMLLabelElement::control() const
     // and the first such element in tree order is a labelable element, then that element is the
     // label element's labeled control.
     if (for_().has_value()) {
-        for_each_in_inclusive_subtree_of_type<HTMLElement>([&](auto& element) {
+        root().for_each_in_inclusive_subtree_of_type<HTMLElement>([&](auto& element) {
             if (element.id() == *for_() && element.is_labelable()) {
                 control = &const_cast<HTMLElement&>(element);
                 return TraversalDecision::Break;