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

Make togglePopover return a boolean #9393

Merged
merged 4 commits into from
Jun 20, 2023
Merged

Conversation

josepharhar
Copy link
Contributor

@josepharhar josepharhar commented Jun 6, 2023

This PR makes togglePopover return true if it opens the popover or false if it closes it.

Fixes #9043

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff )
/popover.html ( diff )

This PR makes togglePopover return true if it opens the popover or false
if it closes it.

Fixes whatwg#9043
@nt1m
Copy link
Member

nt1m commented Jun 7, 2023

Looks good, may be worth fixing #8999 as well.

@nt1m nt1m added the topic: popover The popover attribute and friends label Jun 7, 2023
source Show resolved Hide resolved
source Outdated
@@ -82665,10 +82666,14 @@ dictionary <dfn dictionary>DragEventInit</dfn> : <span>MouseEventInit</span> {
<li><p>If <span>this</span>'s <span>popover visibility state</span> is <span
data-x="popover-showing-state">showing</span>, and <var>force</var> is not present or false, then
run the <span>hide popover algorithm</span> given <span>this</span>, true, true, and
true.</p></li>
true, then return false.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not end up in a situation where hide returns early without changing the state? E.g., if hide all popovers made some changes.

I think we have to return something at the end based on the current state, instead. This might need test coverage too as @rwlbuis's WebKit implementation didn't catch this. (Assuming I'm correct.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made it return whether the popover is actually open instead of just returning true or false or force, and I updated the WPT

source Show resolved Hide resolved
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks a lot safer. Looks good modulo nit.

webkit-commit-queue pushed a commit to rwlbuis/WebKit that referenced this pull request Jun 12, 2023
https://bugs.webkit.org/show_bug.cgi?id=257769

Reviewed by Tim Nguyen.

Implement togglePopover API change:
whatwg/html#9393

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

Canonical link: https://commits.webkit.org/265064@main
@annevk
Copy link
Member

annevk commented Jun 14, 2023

@josepharhar would you be willing to update OP and address the nit? No need for a WebKit bug.

@josepharhar
Copy link
Contributor Author

@josepharhar would you be willing to update OP and address the nit? No need for a WebKit bug.

Done

@annevk annevk merged commit 3824cd6 into whatwg:main Jun 20, 2023
mnutt pushed a commit to movableink/webkit that referenced this pull request Jun 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=257769

Reviewed by Tim Nguyen.

Implement togglePopover API change:
whatwg/html#9393

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

Canonical link: https://commits.webkit.org/265064@main
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 this pull request may close these issues.

Should togglePopover() return a boolean?
4 participants