Skip to content

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

@keithamus

Description

@keithamus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions