From 5296338e7aef6384fa80e2f70b03cbd9b6d6bcc2 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 17 May 2024 06:05:39 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp index 20cf7e02dfd..26f668e8a13 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLabelElement.cpp @@ -43,7 +43,7 @@ JS::GCPtr 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([&](auto& element) { + root().for_each_in_inclusive_subtree_of_type([&](auto& element) { if (element.id() == *for_() && element.is_labelable()) { control = &const_cast(element); return TraversalDecision::Break;