Skip to content

Commit

Permalink
Always call superclass in HTMLLabelElement::DefaultEventHandler
Browse files Browse the repository at this point in the history
HTMLLabelElement::DefaultEventHandler does not currently call up to
HTMLElement::DefaultEventHandler in many cases. This patch makes sure
that HTMLLabelElement always calls up to HTMLElement, which makes
<label>s in <button>s work.

WebKit's HTMLLabelElement already does this in all branches of
HTMLLabelElement::defaultEventHandler since 2017:
WebKit/WebKit@fec9c1d
WebKit/WebKit@b9bad31

Fixed: 1523168
Change-Id: Ib9d0a63befbb930b9595bcc89fb5955050c97b2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5260750
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1257674}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Feb 8, 2024
1 parent 5407936 commit 3c00d74
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions html/semantics/popovers/label-in-invoker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1523168">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>

<button popovertarget=mypopover>
<label>label</label>
</button>
<div id=mypopover popover=auto>popover</div>

<script>
promise_test(async() => {
const label = document.querySelector('label');
assert_false(mypopover.matches(':popover-open'),
'Popover should be closed at the start of the test.');
await test_driver.click(label);
assert_true(mypopover.matches(':popover-open'),
'The popover should be opened by clicking on the label.');
}, 'Buttons with popovertarget should invoke targets even if there is a label in the button.');
</script>

0 comments on commit 3c00d74

Please sign in to comment.