From ed9223eee8f515b22ed9dbba5e28b6d2183c6e3f Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Mon, 27 Jan 2025 20:28:20 +0000 Subject: [PATCH 01/12] Add attribute changed steps to dialog element When the dialogs open attribute is removed: 1. Remove dialog from the document's open dialogs list. 2. Destroy and nullify dialog's close watcher This also adds an assertion to the start of 'set the dialog close watcher' that dialog's close watcher is null. --- source | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/source b/source index 25a6b07eaae..dfc84e1d4ed 100644 --- a/source +++ b/source @@ -62415,6 +62415,38 @@ interface HTMLDialogElement : HTMLElement { removedNode's node document's open dialogs list.

+

The following attribute change + steps, given element, localName, oldValue, + value, and namespace are used for dialog elements:

+ +
    +
  1. If namespace is not null, then return.

  2. + +
  3. If localName is not open, then + return.

  4. + +
  5. If value is null:

    + +
      +
    1. Remove element from element's + node document's open dialogs list.

    2. + +
    3. +

      If element's close watcher is not + null, then:

      + +
        +
      1. Destroy element's close watcher.

      2. + +
      3. Set element's close watcher to + null.

      4. +
      +
    4. +
    +
  6. +
+

To show a modal dialog given a dialog element subject:

    @@ -62509,6 +62541,9 @@ interface HTMLDialogElement : HTMLElement { element dialog:

      +
    1. Assert: dialog's close + watcher is null.

    2. +
    3. Set dialog's close watcher to the result of establishing a close watcher given From d0178b6b120fcdc117d6f2b3e0088eb5c6dfeed2 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Sun, 2 Feb 2025 22:33:27 +0000 Subject: [PATCH 02/12] Replace assert in set the dialog close watcher with an early return --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index dfc84e1d4ed..b9b68fc88d9 100644 --- a/source +++ b/source @@ -62541,8 +62541,8 @@ interface HTMLDialogElement : HTMLElement { element dialog:

        -
      1. Assert: dialog's close - watcher is null.

      2. +
      3. If dialog's close watcher is not + null, then return.

      4. Set dialog's close watcher to the From 4773fbed8aebcbc6538f25210341b3bbc9bbdc7f Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Wed, 12 Feb 2025 12:09:58 +0000 Subject: [PATCH 03/12] Add dialog attribute change steps when adding open attribute Address review comments --- source | 54 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/source b/source index b9b68fc88d9..6aebb6ff44b 100644 --- a/source +++ b/source @@ -62234,15 +62234,6 @@ interface HTMLDialogElement : HTMLElement {

      5. Add an open attribute to this, whose value is the empty string.

      6. -
      7. Assert: this's node document's open - dialogs list does not contain - this.

      8. - -
      9. Add this to this's node document's open - dialogs list.

      10. - -
      11. Set the dialog close watcher with this.

      12. -
      13. Set this's previously focused element to the focused element.

      14. @@ -62425,9 +62416,13 @@ interface HTMLDialogElement : HTMLElement {
      15. If localName is not open, then return.

      16. -
      17. If value is null:

        +
      18. If value is null and oldValue is not null:

          +
        1. Assert: element's node document's open + dialogs list contains + element.

        2. +
        3. Remove element from element's node document's open dialogs list.

        4. @@ -62445,6 +62440,20 @@ interface HTMLDialogElement : HTMLElement {
      19. + +
      20. If value is not null and oldValue is null:

        + +
          +
        1. Assert: element's node document's open + dialogs list does not contain + element.

        2. + +
        3. Add element to this's node document's open + dialogs list.

        4. + +
        5. Set the dialog close watcher with element.

        6. +
        +

      To show a modal dialog given a dialog element subject:

      @@ -62490,13 +62499,6 @@ interface HTMLDialogElement : HTMLElement {
    4. Set is modal of subject to true.

    5. -
    6. Assert: subject's node document's open - dialogs list does not contain - subject.

    7. - -
    8. Add subject to subject's node document's open - dialogs list.

    9. -
    10. Let subject's node document be blocked by the modal dialog subject.

      @@ -62513,8 +62515,6 @@ interface HTMLDialogElement : HTMLElement { already contain subject, then add an element to the top layer given subject.

    11. -
    12. Set the dialog close watcher with subject.

    13. -
    14. Set subject's previously focused element to the focused element.

    15. @@ -62661,9 +62661,6 @@ interface HTMLDialogElement : HTMLElement {
    16. Set is modal of subject to false.

    17. -
    18. Remove subject from subject's - node document's open dialogs list.

    19. -
    20. If result is not null, then set the returnValue attribute to result.

    21. @@ -62689,19 +62686,6 @@ interface HTMLDialogElement : HTMLElement {
    22. Queue an element task on the user interaction task source given the subject element to fire an event named close at subject.

    23. - -
    24. -

      If subject's close watcher is not null, - then:

      - -
        -
      1. Destroy subject's close watcher.

      2. - -
      3. Set subject's close watcher to - null.

      4. -
      -
    From eaaae4bf29c8f9135350e96d486cc5d79dd72360 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Wed, 12 Feb 2025 12:34:27 +0000 Subject: [PATCH 04/12] Run specfmt --- source | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source b/source index 6aebb6ff44b..512da689ccd 100644 --- a/source +++ b/source @@ -62420,8 +62420,7 @@ interface HTMLDialogElement : HTMLElement {
    1. Assert: element's node document's open - dialogs list contains - element.

    2. + dialogs list contains element.

    3. Remove element from element's node document's open dialogs list.

    4. From ba2263d22d8001bed77fbb3d96fbd5162e7f07f8 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 25 Feb 2025 15:47:19 +0000 Subject: [PATCH 05/12] Define dialog cleanup and setup steps and call them from the attribute changed steps --- source | 79 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/source b/source index 512da689ccd..c750da58d20 100644 --- a/source +++ b/source @@ -62416,43 +62416,13 @@ interface HTMLDialogElement : HTMLElement {
    5. If localName is not open, then return.

    6. -
    7. If value is null and oldValue is not null:

      - -
        -
      1. Assert: element's node document's open - dialogs list contains element.

      2. - -
      3. Remove element from element's - node document's open dialogs list.

      4. - -
      5. -

        If element's close watcher is not - null, then:

        - -
          -
        1. Destroy element's close watcher.

        2. - -
        3. Set element's close watcher to - null.

        4. -
        -
      6. -
      -
    8. - -
    9. If value is not null and oldValue is null:

      - -
        -
      1. Assert: element's node document's open - dialogs list does not contain - element.

      2. - -
      3. Add element to this's node document's open - dialogs list.

      4. +
      5. If value is null, oldValue is not null, and element is + connected, then run the dialog cleanup steps given + element.

      6. -
      7. Set the dialog close watcher with element.

      8. -
      -
    10. +
    11. If value is not null, oldValue is null, and element is + connected, then run the dialog setup steps given + element.

    To show a modal dialog given a dialog element subject:

    @@ -62790,6 +62760,43 @@ interface HTMLDialogElement : HTMLElement {
  1. Set topDocument's autofocus processed flag to true.

+

The dialog setup steps, given a dialog element subject, are + as follows:

+ +
    +
  1. Assert: subject's node document's open dialogs + list does not contain subject.

  2. + +
  3. Add subject to subject's node document's open + dialogs list.

  4. + +
  5. Set the dialog close watcher with subject.

  6. +
+ +

The dialog cleanup steps, given a dialog element subject, + are as follows:

+ +
    +
  1. Assert: subject's node document's open dialogs + list contains element.

  2. + +
  3. Remove subject from subject's + node document's open dialogs list.

  4. + +
  5. +

    If subject's close watcher is not null, + then:

    + +
      +
    1. Destroy subject's close watcher.

    2. + +
    3. Set subject's close watcher to + null.

    4. +
    +
  6. +
+

Dialog light dismiss

"Light dismiss" means that clicking outside of a dialog element whose Date: Tue, 25 Feb 2025 16:03:41 +0000 Subject: [PATCH 06/12] Call dialog cleanup steps from dialog removing steps --- source | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/source b/source index c750da58d20..36a879b1ce5 100644 --- a/source +++ b/source @@ -62384,15 +62384,11 @@ interface HTMLDialogElement : HTMLElement {

  1. -

    If removedNode's close watcher is not - null, then:

    +

    If removedNode has an open + attribute:

      -
    1. Destroy removedNode's close watcher.

    2. - -
    3. Set removedNode's close watcher to - null.

    4. +
    5. Run the dialog cleanup steps given removedNode.

  2. @@ -62401,9 +62397,6 @@ interface HTMLDialogElement : HTMLElement { the top layer immediately given removedNode.

  3. Set is modal of removedNode to false.

  4. - -
  5. Remove removedNode from - removedNode's node document's open dialogs list.

The following attribute change From 2b8bce669d940967c64da544773fadbe12963f6b Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 25 Feb 2025 16:09:54 +0000 Subject: [PATCH 07/12] Define dialog HTML element insertion steps and call dialog setup steps --- source | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/source b/source index 36a879b1ce5..e841dd6d762 100644 --- a/source +++ b/source @@ -62379,13 +62379,25 @@ interface HTMLDialogElement : HTMLElement { +

The dialog HTML element insertion steps, given + insertedNode, are:

+ +
    +
  1. +

    If insertedNode has an open attribute:

    + +
      +
    1. Run the dialog setup steps given insertedNode.

    2. +
    +
  2. +
+

The dialog HTML element removing steps, given removedNode and oldParent, are:

  1. -

    If removedNode has an open - attribute:

    +

    If removedNode has an open attribute:

    1. Run the dialog cleanup steps given removedNode.

    2. From e7096dfdffabae2076b86672e03a154a4ecee10f Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 25 Feb 2025 17:13:36 +0000 Subject: [PATCH 08/12] Replace early return with assert --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index e841dd6d762..02374f78e13 100644 --- a/source +++ b/source @@ -62515,8 +62515,8 @@ interface HTMLDialogElement : HTMLElement { element dialog:

        -
      1. If dialog's close watcher is not - null, then return.

      2. +
      3. Assert: dialog's close + watcher is null.

      4. Set dialog's close watcher to the From b5cc2c5ef8d1d747e9d8b04ee7f0b7e2f6904aef Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Fri, 7 Mar 2025 15:52:49 +0000 Subject: [PATCH 09/12] Revert "Replace early return with assert" This reverts commit e7096dfdffabae2076b86672e03a154a4ecee10f. --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index 02374f78e13..e841dd6d762 100644 --- a/source +++ b/source @@ -62515,8 +62515,8 @@ interface HTMLDialogElement : HTMLElement { element dialog:

          -
        1. Assert: dialog's close - watcher is null.

        2. +
        3. If dialog's close watcher is not + null, then return.

        4. Set dialog's close watcher to the From 42db713ef16bcbeb57a61b47bdc6c9cb814725b9 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Tue, 15 Apr 2025 20:29:12 +0100 Subject: [PATCH 10/12] Add connected check to dialog insertion steps --- source | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source b/source index e841dd6d762..d7189041700 100644 --- a/source +++ b/source @@ -62384,7 +62384,8 @@ interface HTMLDialogElement : HTMLElement {

          1. -

            If insertedNode has an open attribute:

            +

            If insertedNode is connected and insertedNode has an open attribute:

            1. Run the dialog setup steps given insertedNode.

            2. From 90282be2fec0226fd8ecacfe5df96f78a83b7079 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 17 Apr 2025 11:05:42 +0100 Subject: [PATCH 11/12] Attempt at fixing issues Dialog setup steps: - Move set the dialog close watcher to step 1 - Add early return when dialog is not connected as a new step 2 (before adding to dialog light dismiss list). Dialog cleanup steps: - Remove assertion - Remove disposing of close watcher. Dialog attribute change steps: - Remove connected check from steps 3 and 4. Dialog insertion steps: - Remove connected check added in previous commit. --- source | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/source b/source index d7189041700..9977e1b008a 100644 --- a/source +++ b/source @@ -62384,8 +62384,7 @@ interface HTMLDialogElement : HTMLElement {
              1. -

                If insertedNode is connected and insertedNode has an open attribute:

                +

                If insertedNode has an open attribute:

                1. Run the dialog setup steps given insertedNode.

                2. @@ -62422,13 +62421,11 @@ interface HTMLDialogElement : HTMLElement {
                3. If localName is not open, then return.

                4. -
                5. If value is null, oldValue is not null, and element is - connected, then run the dialog cleanup steps given - element.

                6. +
                7. If value is null, and oldValue is not null, then run the + dialog cleanup steps given element.

                8. -
                9. If value is not null, oldValue is null, and element is - connected, then run the dialog setup steps given - element.

                10. +
                11. If value is not null, and oldValue is null, then run the + dialog setup steps given element.

                To show a modal dialog given a dialog element subject:

                @@ -62770,37 +62767,23 @@ interface HTMLDialogElement : HTMLElement { as follows:

                  +
                1. Set the dialog close watcher with subject.

                2. + +
                3. If subject is not connected, return.

                4. +
                5. Assert: subject's node document's open dialogs list does not contain subject.

                6. Add subject to subject's node document's open dialogs list.

                7. - -
                8. Set the dialog close watcher with subject.

                The dialog cleanup steps, given a dialog element subject, are as follows:

                  -
                1. Assert: subject's node document's open dialogs - list contains element.

                2. -
                3. Remove subject from subject's node document's open dialogs list.

                4. - -
                5. -

                  If subject's close watcher is not null, - then:

                  - -
                    -
                  1. Destroy subject's close watcher.

                  2. - -
                  3. Set subject's close watcher to - null.

                  4. -
                  -

                Dialog light dismiss

                From 3bffe79d2fa6d8fda99da6f74867f4c88c56dd30 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Thu, 17 Apr 2025 11:53:50 +0100 Subject: [PATCH 12/12] Add back destroy of close watcher to cleanup steps --- source | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source b/source index 9977e1b008a..7447e7aafcd 100644 --- a/source +++ b/source @@ -62784,6 +62784,20 @@ interface HTMLDialogElement : HTMLElement {
                1. Remove subject from subject's node document's open dialogs list.

                2. + +
                3. +

                  If subject's close watcher is not null, + and subject does not have an open attribute, + then:

                  + +
                    +
                  1. Destroy subject's close watcher.

                  2. + +
                  3. Set subject's close watcher to + null.

                  4. +
                  +

                Dialog light dismiss