From f60c3a05a7513041e4075cce82c376d1f21da7ca Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Thu, 22 Jun 2023 21:23:43 -0700 Subject: [PATCH 1/3] Ignore DOM state when hiding popovers if needed Fixes https://github.com/whatwg/html/issues/9161 Fixes https://github.com/whatwg/html/issues/9367 Makes obsolete https://github.com/whatwg/dom/pull/1185 This PR prevents the hide popover algorithm from returning early when the popover attribute is removed or when the element with the popover attribute is removed from the document. The fireEvents parameter is used as an indicator that either the element is being removed or that the attribute is being removed, and when it is false, the calls to check popover validity are replaced with a check to simply see if the popover is already hidden. This patch also makes removal of the popover attribute stop firing events in order to signal to the hide popover algorithm that checks for the popover attribute should be ignored. --- source | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source b/source index be9f621d529..1a55b52687c 100644 --- a/source +++ b/source @@ -82409,9 +82409,11 @@ dictionary DragEventInit : MouseEventInit {
  • If localName is not popover, then return.

  • +
  • Let fireEvents be false if value is null, otherwise true.

  • +
  • If oldValue and value are in different states, then run the hide popover algorithm given - element, true, true, and false.

  • + element, true, fireEvents, and false.

    @@ -82613,8 +82615,12 @@ dictionary DragEventInit : MouseEventInit { boolean fireEvents, and a boolean throwExceptions:

      -
    1. If the result of running check popover validity given element, - true, throwExceptions, and null is false, then return.

    2. +
    3. If fireEvents is true and the result of running check popover + validity given element, true, throwExceptions, and null is false, + then return.

    4. + +
    5. If fireEvents is false and element's popover visibility + state is hidden, then return.

    6. Let document be element's node document.

    7. @@ -82643,15 +82649,19 @@ dictionary DragEventInit : MouseEventInit { element, focusPreviousElement, and fireEvents.

    8. -

      If the result of running check popover validity given element, - true, and throwExceptions is false, then run cleanupHidingFlag and - return.

      +

      If fireEvents is true and the result of running check popover + validity given element, true, and throwExceptions is false, then + run cleanupHidingFlag and return.

      Check popover validity is called again because running hide all popovers until could have disconnected element or changed its popover attribute.

    9. +
    10. If fireEvents is false and element's popover visibility + state is hidden, then run + cleanupHidingFlag and return.

    11. +
    12. If the last item in document's auto popover list is element, then break.

    From acbbfdbec547c2d7e493137acc4c5c6ae916e121 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 11 Jul 2023 10:51:17 -0700 Subject: [PATCH 2/3] make removeattribute start firing events again --- source | 79 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 41 deletions(-) diff --git a/source b/source index 1a55b52687c..3c8b743173f 100644 --- a/source +++ b/source @@ -1832,7 +1832,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • If removedNode's popover attribute is not in the no popover state, then run the hide - popover algorithm given removedNode, false, false, and false.

  • + popover algorithm given removedNode, false, false, false, true, and + false.

    A DragEventInit : MouseEventInit {

  • If localName is not popover, then return.

  • -
  • Let fireEvents be false if value is null, otherwise true.

  • -
  • If oldValue and value are in different states, then run the hide popover algorithm given - element, true, fireEvents, and false.

  • + element, true, true, false, and true.

    @@ -82464,8 +82463,8 @@ dictionary DragEventInit : MouseEventInit {
  • If the result of running check popover validity given element, - false, throwExceptions, and null is false, then run cleanupShowingFlag and - return.

  • + false, throwExceptions, null, and false is false, then run + cleanupShowingFlag and return.

  • Assert: element is not in document's top layer.

  • @@ -82487,7 +82486,7 @@ dictionary DragEventInit : MouseEventInit {
  • If the result of running check popover validity given element, false, - throwExceptions, and document is false, then run + throwExceptions, document, and false is false, then run cleanupShowingFlag and return.

    Check popover validity is called again because firing the DragEventInit : MouseEventInit {

  • If the result of running check popover validity given element, - false, throwExceptions, and document is false, then run + false, throwExceptions, document, and false is false, then run cleanupShowingFlag and return.

    Check popover validity is called again because running DragEventInit : MouseEventInit { method steps are:

      -
    1. Run the hide popover algorithm given this, true, true, and - true.

    2. +
    3. Run the hide popover algorithm given this, true, true, true, and + false.

    To hide a popover given an HTML element element, a boolean focusPreviousElement, a - boolean fireEvents, and a boolean throwExceptions:

    + boolean fireEvents, a boolean throwExceptions, and a boolean + ignoreDomState:

      -
    1. If fireEvents is true and the result of running check popover - validity given element, true, throwExceptions, and null is false, - then return.

    2. - -
    3. If fireEvents is false and element's popover visibility - state is hidden, then return.

    4. +
    5. If the result of running check popover validity given element, + true, throwExceptions, null, and ignoreDomState is false, then + return.

    6. Let document be element's node document.

    7. @@ -82649,19 +82646,15 @@ dictionary DragEventInit : MouseEventInit { element, focusPreviousElement, and fireEvents.

    8. -

      If fireEvents is true and the result of running check popover - validity given element, true, and throwExceptions is false, then - run cleanupHidingFlag and return.

      +

      If the result of running check popover validity given element, + true, throwExceptions, and ignoreDomState is false, then run + cleanupHidingFlag and return.

      Check popover validity is called again because running hide all popovers until could have disconnected element or changed its popover attribute.

    9. -
    10. If fireEvents is false and element's popover visibility - state is hidden, then run - cleanupHidingFlag and return.

    11. -
    12. If the last item in document's auto popover list is element, then break.

    @@ -82681,8 +82674,8 @@ dictionary DragEventInit : MouseEventInit {
  • If the result of running check popover validity given element, - true, throwExceptions, and null is false, then run cleanupHidingFlag and - return.

    + true, throwExceptions, null, and ignoreDomState is false, then run + cleanupHidingFlag and return.

    Check popover validity is called again because firing the beforetoggle event could have disconnected @@ -82730,8 +82723,8 @@ dictionary DragEventInit : MouseEventInit {

    1. If this's popover visibility state is showing, and force is not present or false, then - run the hide popover algorithm given this, true, true, and - true.

    2. + run the hide popover algorithm given this, true, true, true, and + false.

    3. Otherwise, if force is not present or true, then run show popover given this true, and null.

    4. @@ -82759,7 +82752,7 @@ dictionary DragEventInit : MouseEventInit {
      1. Run the hide popover algorithm given popover, - focusPreviousElement, fireEvents, and false.

      2. + focusPreviousElement, fireEvents, false, and false.

      3. Set popover to document's topmost auto popover.

      4. @@ -82807,7 +82800,7 @@ dictionary DragEventInit : MouseEventInit {
        1. Run the hide popover algorithm given document's auto popover list's last element, focusPreviousElement, fireEvents, - and false.

        2. + false, and false.

        @@ -82986,13 +82979,15 @@ dictionary DragEventInit : MouseEventInit {

        To check popover validity for an HTML element element given a boolean expectedToBeShowing, a boolean - throwExceptions, and a Document or null expectedDocument - perform the following steps. They throw an exception or return a boolean.

        + throwExceptions, a Document or null expectedDocument, and a + boolean ignoreDomState, perform the following steps. They throw an exception or return + a boolean.

        1. -

          If element's popover attribute is in the - no popover state, then:

          +

          If ignoreDomState is false and element's popover attribute is in the no popover state, then:

          1. If throwExceptions is true, then throw a @@ -83020,10 +83015,11 @@ dictionary DragEventInit : MouseEventInit {

            If one of the following conditions is true

              -
            • element is not connected

            • +
            • ignoreDomState is false and element is not + connected

            • -
            • expectedDocument is not null and element's node - document is not expectedDocument

            • +
            • ignoreDomState is false and expectedDocument is not null and + element's node document is not expectedDocument

            • element is a dialog element and its is modal flag is set to true.

            • @@ -83175,12 +83171,12 @@ dictionary DragEventInit : MouseEventInit {
            • If popover's popover visibility state is showing, then run the hide popover algorithm - given popover, true, true, and false.

            • + given popover, true, true, false, and false.

            • Otherwise, if popover's popover visibility state is hidden and the result of running check popover - validity given popover, false, false, and null is true, then run show - popover given popover, false, and node.

            • + validity given popover, false, false, null, and false is true, then run + show popover given popover, false, and node.

          To get the popover target element given a Node node, perform @@ -83217,7 +83213,8 @@ dictionary DragEventInit : MouseEventInit { topmost auto popover showing, user agents may provide a user interface that, upon activation, queues an element task on the user interaction task source given topmost auto popover to run the hide - popover algorithm given the topmost auto popover, true, true, and false.

          + popover algorithm given the topmost auto popover, true, true, false, and + false.

          To light dismiss open popovers, given an Event event:

          From d683a6ba45a98034edd6e6e14001f2d753843d07 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Mon, 17 Jul 2023 06:10:05 -0700 Subject: [PATCH 3/3] fix args --- source | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source b/source index 3c8b743173f..153476f71e1 100644 --- a/source +++ b/source @@ -1832,8 +1832,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
        2. If removedNode's popover attribute is not in the no popover state, then run the hide - popover algorithm given removedNode, false, false, false, true, and - false.

        3. + popover algorithm given removedNode, false, false, false, and true.

        A