Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

togglePopover() algorithm does not check popover validity when force == false and when the popover visibility state is hidden #8999

Closed
nt1m opened this issue Mar 9, 2023 · 11 comments · Fixed by #9451
Labels
topic: popover The popover attribute and friends

Comments

@nt1m
Copy link
Member

nt1m commented Mar 9, 2023

Seems like an oversight to me.

cc @josepharhar @mfreed7 @annevk

@nt1m nt1m added the topic: popover The popover attribute and friends label Mar 9, 2023
@nt1m
Copy link
Member Author

nt1m commented Mar 9, 2023

Probably doesn't matter too much fwiw.

@mfreed7
Copy link
Collaborator

mfreed7 commented Mar 13, 2023

Seems like an oversight to me also, but I'll let @josepharhar comment.

@josepharhar
Copy link
Contributor

togglePopover just calls "hide a popover" or "show popover", and each of those algorithms check popover validity as their first step.

Are you saying that when togglePopover decides not to do anything, we should still call check popover validity...? I don't see why we should.

@nt1m
Copy link
Member Author

nt1m commented Mar 14, 2023

Are you saying that when togglePopover decides not to do anything, we should still call check popover validity...? I don't see why we should.

There is this slight oddity when you call togglePopover(false) on an element with no popover attribute and it ends up doing nothing instead of throwing an exception. Seems like a bad developer experience, though not something I feel too strongly about.

@annevk
Copy link
Member

annevk commented Mar 16, 2023

What if we make the logic:

  1. If visibility state is showing and force is not given, or force is given and is false, then hide.
  2. Otherwise, show.

@nt1m
Copy link
Member Author

nt1m commented Jun 6, 2023

@annevk Do you think it's still worth changing the spec given the recent changes to not throw?

The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

@annevk
Copy link
Member

annevk commented Jun 6, 2023

We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

@josepharhar
Copy link
Contributor

The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

So the following code would result in a call to check popover validity and possibly throw exceptions?

const div = document.createElement('div');
div.setAttribute('popover', 'auto');
// don't connect to document or show
div.togglePopover(/*force=*/false); // try to force close

We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

So the above code I wrote should throw an exception then?

@nt1m
Copy link
Member Author

nt1m commented Jun 8, 2023

The implication of this change is that the other "check popover validity" checks (dialog, fullscreen, disconnected) would run in the cases I mentioned in the title: https://html.spec.whatwg.org/multipage/popover.html#check-popover-validity

So the following code would result in a call to check popover validity and possibly throw exceptions?

const div = document.createElement('div');
div.setAttribute('popover', 'auto');
// don't connect to document or show
div.togglePopover(/*force=*/false); // try to force close

We decided to not throw in certain cases. Did we decide to not throw for cases where state does not match up? It looks to me like showPopover() still throws for this condition so togglePopover() should as well.

So the above code I wrote should throw an exception then?

@josepharhar Since hidePopover() wouldn't throw in this case, I would say it shouldn't (and in fact it wouldn't with the suggested change, since the check popover validity algorithm wouldn't in this case).

But:

const div = document.createElement('div');
// don't set popover attribute
// don't connect to document or show
div.togglePopover(/*force=*/false); // try to force close

would start throwing, unlike the current algorithm.

Stuff in step 3. of the check popover validity would also start throwing.

josepharhar added a commit to josepharhar/html that referenced this issue Jun 21, 2023
This PR makes sure that togglePopover will throw exceptions when it is
disconnected from the document or doesn't have a popover attribute.

Fixes whatwg#8999
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jun 21, 2023
This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
josepharhar added a commit to josepharhar/html that referenced this issue Jun 21, 2023
This PR makes sure that togglePopover will throw exceptions when it is
disconnected from the document or doesn't have a popover attribute.

Fixes whatwg#8999
@josepharhar
Copy link
Contributor

Ok, I created a PR to implement this: #9451

@rwlbuis
Copy link

rwlbuis commented Jun 27, 2023

Ok, I created a PR to implement this: #9451

I have a similar PR for WebKit:
WebKit/WebKit#15333

annevk pushed a commit that referenced this issue Jun 28, 2023
This makes sure that togglePopover() will throw exceptions when it is disconnected from the document or doesn't have a popover attribute.

Fixes #8999.
webkit-commit-queue pushed a commit to rwlbuis/WebKit that referenced this issue Jun 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=258574

Reviewed by Tim Nguyen.

Throw exceptions in togglePopover in case of a disconnected node or the popover
attribute not being set anymore, see whatwg/html#8999.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/togglePopover-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/togglePopover.html:
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::togglePopover):

Canonical link: https://commits.webkit.org/265589@main
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 5, 2023
This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 5, 2023
This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4634324
Auto-Submit: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1166059}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jul 5, 2023
This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4634324
Auto-Submit: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1166059}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jul 12, 2023
…, a=testonly

Automatic update from web-platform-tests
Make togglePopover throw more exceptions

This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

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

--

wpt-commits: 12aef06b95b80e9d489c123a235a2c1cdc85a838
wpt-pr: 40682
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Jul 16, 2023
…, a=testonly

Automatic update from web-platform-tests
Make togglePopover throw more exceptions

This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4634324
Auto-Submit: Joey Arhar <jarharchromium.org>
Reviewed-by: Mason Freed <masonfchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1166059}

--

wpt-commits: 12aef06b95b80e9d489c123a235a2c1cdc85a838
wpt-pr: 40682

UltraBlame original commit: a30b08c8c590ed2562eb20a222a5a4714bd93936
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Jul 16, 2023
…, a=testonly

Automatic update from web-platform-tests
Make togglePopover throw more exceptions

This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4634324
Auto-Submit: Joey Arhar <jarharchromium.org>
Reviewed-by: Mason Freed <masonfchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1166059}

--

wpt-commits: 12aef06b95b80e9d489c123a235a2c1cdc85a838
wpt-pr: 40682

UltraBlame original commit: a30b08c8c590ed2562eb20a222a5a4714bd93936
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Jul 16, 2023
…, a=testonly

Automatic update from web-platform-tests
Make togglePopover throw more exceptions

This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

Change-Id: Iac7a486cd64b09b5657a157dbf3e9e54c1be2a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4634324
Auto-Submit: Joey Arhar <jarharchromium.org>
Reviewed-by: Mason Freed <masonfchromium.org>
Commit-Queue: Joey Arhar <jarharchromium.org>
Cr-Commit-Position: refs/heads/main{#1166059}

--

wpt-commits: 12aef06b95b80e9d489c123a235a2c1cdc85a838
wpt-pr: 40682

UltraBlame original commit: a30b08c8c590ed2562eb20a222a5a4714bd93936
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this issue Jul 16, 2023
…, a=testonly

Automatic update from web-platform-tests
Make togglePopover throw more exceptions

This patch makes sure that togglePopover will throw exceptions when it
is disconnected from the document or doesn't have a popover attribute.

This is being discussed here: whatwg/html#8999

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

--

wpt-commits: 12aef06b95b80e9d489c123a235a2c1cdc85a838
wpt-pr: 40682
mnutt pushed a commit to movableink/webkit that referenced this issue Jul 18, 2023
https://bugs.webkit.org/show_bug.cgi?id=258574

Reviewed by Tim Nguyen.

Throw exceptions in togglePopover in case of a disconnected node or the popover
attribute not being set anymore, see whatwg/html#8999.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/togglePopover-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/popovers/togglePopover.html:
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::togglePopover):

Canonical link: https://commits.webkit.org/265589@main
rubberyuzu pushed a commit to rubberyuzu/html that referenced this issue Jul 20, 2023
This makes sure that togglePopover() will throw exceptions when it is disconnected from the document or doesn't have a popover attribute.

Fixes whatwg#8999.
rubberyuzu pushed a commit to rubberyuzu/html that referenced this issue Jul 21, 2023
This makes sure that togglePopover() will throw exceptions when it is disconnected from the document or doesn't have a popover attribute.

Fixes whatwg#8999.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: popover The popover attribute and friends
Development

Successfully merging a pull request may close this issue.

5 participants