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

[Popup] Do we need the "open" attribute? #467

Closed
mfreed7 opened this issue Mar 26, 2021 · 1 comment
Closed

[Popup] Do we need the "open" attribute? #467

mfreed7 opened this issue Mar 26, 2021 · 1 comment
Assignees

Comments

@mfreed7
Copy link

mfreed7 commented Mar 26, 2021

The "open" attribute was recently re-added to the proposal. I'm wondering what the driving use case is for that attribute. I can see from the explainer that opening a popup on "load" is listed there. Is that it?

An easy alternative to the "open" attribute, for that use case, is:

window.onload = () => {myPopup.show();};

I ask because there are complexities:

  1. What if multiple non-nested (or nested!) popups have the "open" attribute?
    1. In this case, only one of them should show, so at least an order needs to be determined. Perhaps the behavior should be as-if the .show() method were called in tree order on all of them?
    2. For the non-shown popups above, should a "hide" event be fired on them?
    3. For the non-shown popups above, should their "open" attribute be removed? If not, then they'll still be wearing the "open" attribute while not actually being displayed. (The UA stylesheet cannot therefore simply use popup:not([open]) {display: none !important;} to hide the popup.)
  2. When an open <popup> is removed from the tree, the <popup> plus all of its non-ancestor <popup>s need to be hidden.
    1. Without the "open" attribute, this is relatively easy, because hiding popups doesn't affect the DOM tree, just the layout tree.
    2. However, when the "open" attribute needs to be removed from each of those hidden popups, this gets more tricky. Node removal (in Chromium, and I think by spec, modulo mutation events) is forbidden from modifying the DOM tree. Therefore, the removal of the "open" attribute would need to be done at a later time (micro-task timing?), which would be observable.
  3. What if a disconnected <popup open> node is created?
    1. Is it confusing that popup.getAttribute('open') is non-null for this disconnected, non-displayed <popup>?
    2. What if this node is appended to the document? Should it act as if .show() were called upon insertion? If so, some of the same concerns as #2 above apply here - other <popup>s will need to be hidden as this node is inserted into the document.

All of the above can be overcome, but I'm curious if the added complexity is worth the benefit provided by the "open" attribute. I do know that parallelism to <dialog> has been brought up here. But in this case specifically, <dialog> is quite different - many <dialog>s can be open at a time, and they don't close each other. So none of the complexity above applies to <dialog>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants