Skip to content

Commit

Permalink
Bug 1801355 [wpt PR 37029] - Move hide event before state changes on …
Browse files Browse the repository at this point in the history
…`:open`, a=testonly

Automatic update from web-platform-tests
Move hide event before state changes on `:open`

Move the timing of the popover `popoverhide` event a bit earlier
in the process, just *before* the state changes to "transitioning".
This has the effect of making the state clean (either :open or
:closed) for both `popoverhide` and `popovershow`.

See the discussion here:
openui/open-ui#607

Bug: 1307772
Change-Id: I5aaabfd48204e54831ce435c71a54e692e139caf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4032919
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1074159}

--

wpt-commits: 8bb98a4f9e3f84fb450a5093aa88d8bd2be53c45
wpt-pr: 37029
  • Loading branch information
mfreed7 authored and moz-wptsync-bot committed Dec 11, 2022
1 parent 4e11c19 commit c6123fe
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,31 @@
assert_false(popover.matches(':open'));
let showCount = 0;
let hideCount = 0;
function showListener(e) {
assert_true(e.target.matches(':closed'),'The popover should be in the :closed state when the popovershow event fires.');
assert_false(e.target.matches(':open'),'The popover should *not* be in the :open state when the popovershow event fires.');
++showCount;
};
function hideListener(e) {
assert_true(e.target.matches(':open'),'The popover should be in the :open state when the popoverhide event fires.');
assert_false(e.target.matches(':closed'),'The popover should *not* be in the :closed state when the popoverhide event fires.');
++hideCount;
};
switch (method) {
case "listener":
const controller = new AbortController();
const signal = controller.signal;
t.add_cleanup(() => controller.abort());
document.addEventListener('popovershow',() => ++showCount, {signal});
document.addEventListener('popoverhide',() => ++hideCount, {signal});
document.addEventListener('popovershow',showListener, {signal});
document.addEventListener('popoverhide',hideListener, {signal});
break;
case "attribute":
assert_false(popover.hasAttribute('onpopovershow'));
assert_false(popover.hasAttribute('onpopoverhide'));
t.add_cleanup(() => popover.removeAttribute('onpopovershow'));
t.add_cleanup(() => popover.removeAttribute('onpopoverhide'));
popover.onpopovershow = () => ++showCount;
popover.onpopoverhide = () => ++hideCount;
popover.onpopovershow = showListener;
popover.onpopoverhide = hideListener;
break;
default: assert_unreached();
}
Expand Down

0 comments on commit c6123fe

Please sign in to comment.