From 2549f6ba7754448585beb48871540ee304b83c58 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Wed, 18 Jan 2023 10:21:53 -0800 Subject: [PATCH] toggle event coalescing and renaming --- source | 155 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 114 insertions(+), 41 deletions(-) diff --git a/source b/source index abe8cc482a4..098f978af1e 100644 --- a/source +++ b/source @@ -81173,6 +81173,18 @@ dictionary DragEventInit : MouseEventInit {

Every HTML element has a popover invoker, which is an HTML element or null, initially set to null.

+

Every HTML element has a popover toggle task, + initially null, which is either null or a struct which has:

+ +
+
Task
A task which fires a + ToggleEvent.
+ +
Old state
+
A string which represents the task's event's + value for the oldState attribute.
+
+

The following attribute change steps are used for all HTML elements:

@@ -81237,10 +81249,10 @@ dictionary DragEventInit : MouseEventInit { document's top layer.

  • If the result of firing an event named beforetoggle, using PopoverToggleEvent, with the - cancelable attribute initialized to true, the currentState attribute initialized to "closed", and the newState + data-x="event-beforetoggle">beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", and the newState attribute initialized to "open" at element is false, then return.

  • @@ -81326,12 +81338,41 @@ dictionary DragEventInit : MouseEventInit { data-x="attr-popover-none-state">no popover state, then set element's previously focused element to originallyFocusedElement.

    -
  • Queue an element task given the user interaction task source and - element to fire an event named toggle, using PopoverToggleEvent, with the currentState attribute initialized to "open", and the newState - attribute initialized to "open" at element.

  • +
  • Let oldState be "closed".

  • + +
  • +

    If element's popover toggle task is not null, then:

    + +
      +
    1. Set oldState to element's popover toggle task's + old state.

    2. + +
    3. Remove element's popover toggle task's task from its task queue.

    4. + +
    5. Set element's popover toggle task to null.

    6. +
    +
  • + +
  • +

    Queue an element task given the user interaction task source and + element to run the following steps:

    + +
      +
    1. fire an event named toggle, using ToggleEvent, with the oldState attribute initialized to oldState, + and the newState attribute initialized to "open" at element.

    2. + +
    3. Set element's popover toggle task to null.

    4. +
    +
  • + +
  • Set element's popover toggle task to a struct with task set to the just-queued task and old + state set to oldState.

  • The hidePopover() @@ -81396,11 +81437,10 @@ dictionary DragEventInit : MouseEventInit {

    1. Fire an event named beforetoggle, using PopoverToggleEvent, with - the currentState attribute - initialized to "open", and the newState attribute initialized to "closed" at element.

    2. + data-x="event-beforetoggle">beforetoggle, using ToggleEvent, with the oldState attribute initialized to "open", and the newState + attribute initialized to "closed" at element.

    3. If the result of running check popover validity given element and @@ -81426,14 +81466,47 @@ dictionary DragEventInit : MouseEventInit {

    4. Set element's popover visibility state to hidden.

    5. -
    6. If dontFireEvents is false, then queue an element task given the - user interaction task source and element to fire an event named toggle, - using PopoverToggleEvent, with the cancelable attribute initialized to false, the currentState attribute initialized to "closed", and the newState - attribute initialized to "closed" at element.

    7. +
    8. +

      If dontFireEvents is false, then:

      + +
        +
      1. Let oldState be "open".

      2. + +
      3. +

        If element's popover toggle task is not null, then:

        + +
          +
        1. Set oldState to element's popover toggle task's + old state.

        2. + +
        3. Remove element's popover toggle task's task from its task queue.

        4. + +
        5. Set element's popover toggle task to null.

        6. +
        +
      4. + +
      5. +

        Queue an element task given the user interaction task source and + element to run the following steps:

        + +
          +
        1. fire an event named toggle, using ToggleEvent, with the oldState attribute initialized to + oldState, and the newState + attribute initialized to "closed" at element.

        2. + +
        3. Set element's popover toggle task to null.

        4. +
        +
      6. + +
      7. Set element's popover toggle task to a struct with task set to the just-queued task and old + state set to oldState.

      8. +
      +
    9. Let previouslyFocusedElement be element's previously focused element.

    10. @@ -81996,23 +82069,23 @@ dictionary DragEventInit : MouseEventInit {
    -

    The PopoverToggleEvent interface

    +

    The ToggleEvent interface

    [Exposed=Window]
    -interface PopoverToggleEvent : Event {
    -  constructor(DOMString type, optional PopoverToggleEventInit eventInitDict = {});
    -  readonly attribute DOMString currentState;
    +interface ToggleEvent : Event {
    +  constructor(DOMString type, optional ToggleEventInit eventInitDict = {});
    +  readonly attribute DOMString oldState;
       readonly attribute DOMString newState;
     };
     
    -dictionary PopoverToggleEventInit : EventInit {
    -  DOMString currentState = "";
    +dictionary ToggleEventInit : EventInit {
    +  DOMString oldState = "";
       DOMString newState = "";
     };
    event.currentState
    + data-x="dom-ToggleEvent-oldState">oldState

    Set to "closed" when transitioning from closed to open, or set to @@ -82020,7 +82093,7 @@ dictionary PopoverToggleEventInit : EventInit

    event.newState
    + data-x="dom-ToggleEvent-newState">newState

    Set to "open" when transitioning from closed to open, or set to "PopoverToggleEventInit : EventInit

    -

    The currentState attribute must return the - value it was initialized to. It is initialized to "open" if the element - with the popover attribute's popover visibility - state is showing; otherwise "The oldState attribute must return the value it + was initialized to. It is initialized to "open" if the element with the + popover attribute's popover visibility state is + showing; otherwise "closed".

    -

    The newState attribute must return the value it - was initialized to. It is initialized to "closed" if the element with the - popover attribute's popover visibility state is - showing; otherwise "open".

    +

    The newState attribute must return the value it was + initialized to. It is initialized to "closed" if the element with the popover attribute's popover visibility state is showing; otherwise "open".

    Loading web pages