Skip to content

HTMLDialogElement show can put disconnected dialogs in the open dialogs list. #11259

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

Closed
keithamus opened this issue Apr 25, 2025 · 1 comment
Closed
Labels
topic: dialog The <dialog> element

Comments

@keithamus
Copy link
Contributor

keithamus commented Apr 25, 2025

What is the issue with the HTML Standard?

Step 8 of show():

Add this to this's node document's open dialogs list.

At no point prior does show() assert or guard the document being connected. This can result in a disconnected dialog being in the open dialogs list. Removing open and calling show() again will hit the assert on Step 7, which if implemented precisely would cause a crash.

let d = document.createElement('dialog');
d.show() // In the open dialogs list!
d.open = false;
d.show() // Assert fails!

The reason this fails is because Dialog has no attribute changed steps to remove a Dialog from the open dialogs list. This is solved by #10954 which aligns the behaviour closer to Chrome.

Chrome's impl is divergent from the spec because Chrome's flow goes something like:

  1. Show() sets open attribute
  2. AttributeChangedSteps fire on Element, calling ParseAttribute
  3. HTMLDialogElement::ParseAttribute checks if the open attribute is being added, and the element is connected.
  4. Then do step 8.

/cc @lukewarlow @mfreed7

@annevk annevk added the topic: dialog The <dialog> element label Apr 25, 2025
@keithamus
Copy link
Contributor Author

Actually this is effectively a dupe of #10953, so I'm going to close this one out in favour of that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: dialog The <dialog> element
Development

No branches or pull requests

2 participants