Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c110cc1814093427588f3c7c421aed4587087ff2
      
https://github.com/WebKit/WebKit/commit/c110cc1814093427588f3c7c421aed4587087ff2
  Author: Chris Dumez <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/dom/events/label-default-action-expected.txt
    M Source/WebCore/html/HTMLLabelElement.cpp

  Log Message:
  -----------
  Label default action incorrectly triggers when clicked interactive content 
removes itself
https://bugs.webkit.org/show_bug.cgi?id=321257

Reviewed by Ryosuke Niwa.

When a <label> contains interactive content (e.g. a <button>), the label's
activation behavior must do nothing for clicks targeting that interactive
content, per https://html.spec.whatwg.org/#the-label-element.

HTMLLabelElement::isEventTargetedAtInteractiveDescendants determined this by
walking the live composed tree from the event target up to the label. But the
event path is computed once, up front, at dispatch time, so the label still
default-handles the click even if the interactive content removes itself from
the tree while handling that same click. In that case the target is no longer
a descendant of the label, the isShadowIncludingInclusiveAncestorOf() guard
bailed early returning false, and the label went on to activate its control.

Only reject a target that is still connected but outside the label. A
disconnected target means interactive content removed itself mid-dispatch; its
own subtree and ancestor chain remain intact, so the interactive-content walk
below still detects it and correctly does nothing.

No new tests, rebaselined existing WPT test. This test was already passing
in both Chrome and Firefox.

* 
LayoutTests/imported/w3c/web-platform-tests/dom/events/label-default-action-expected.txt:
* Source/WebCore/html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::isEventTargetedAtInteractiveDescendants const):

Canonical link: https://commits.webkit.org/318827@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to