From fd1817812e5f90a3f5462e2812951cfb5be81f19 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 22 Nov 2022 15:52:11 -0800 Subject: [PATCH 1/6] Add popover light dismiss integration I am adding a new HTML attribute called "popover" in https://github.com/whatwg/html/pull/8221 Part of this feature involves "light dismiss", where clicking outside of an element with the popover attribute causes it to be closed. This functionality was originally implemented by changing the event dispatching system of the DOM, but it was recommended to move it here instead: https://github.com/whatwg/dom/pull/1117#issuecomment-1311928234 https://chromium-review.googlesource.com/c/chromium/src/+/4023021 --- index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.html b/index.html index f42b23b..9b37574 100644 --- a/index.html +++ b/index.html @@ -409,6 +409,8 @@

Firing events using the PointerEvent interface

If the event is {{GlobalEventHandlers/pointerdown}}, the associated device is a direct manipulation device, and the target is an {{Element}}, then set pointer capture for this pointerId to the target element as described in implicit pointer capture. +

Run light dismiss open popovers given the event and target.

+

Fire the event to the determined target. The user agent SHOULD treat the target as if the pointing device has moved over it for the purpose of ensuring event ordering [[UIEVENTS]].

Using the pointer capture target override as the target instead of the normal hit-test result may fire some boundary events, as defined by [[UIEVENTS]]. This is the same as the pointer leaving its previous target and entering this new capturing target. When the capture is released, the same scenario may happen, as the pointer is leaving the capturing target and entering the hit-test target.
From 2286d6679aa8c7f79f8a9db1d8188564b5ddbe5b Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 27 Jan 2023 09:07:39 -0800 Subject: [PATCH 2/6] remove target parameter --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 9b37574..d48e8e1 100644 --- a/index.html +++ b/index.html @@ -409,7 +409,7 @@

Firing events using the PointerEvent interface

If the event is {{GlobalEventHandlers/pointerdown}}, the associated device is a direct manipulation device, and the target is an {{Element}}, then set pointer capture for this pointerId to the target element as described in implicit pointer capture. -

Run light dismiss open popovers given the event and target.

+

Run light dismiss open popovers given the event.

Fire the event to the determined target. The user agent SHOULD treat the target as if the pointing device has moved over it for the purpose of ensuring event ordering [[UIEVENTS]].

From 146efd04819d5ca24aa2ec054249f4cf470e2356 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 22 Jul 2025 14:17:40 -0700 Subject: [PATCH 3/6] use click event instead of pointerdown and pointerup --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index b44e65c..d1815da 100644 --- a/index.html +++ b/index.html @@ -461,8 +461,6 @@

Firing events using the PointerEvent interface

If the event is {{GlobalEventHandlers/pointerdown}}, the associated device is a direct manipulation device, and the target is an {{Element}}, then set pointer capture for this {{PointerEvent/pointerId}} to the target element as described in implicit pointer capture.

-

Run light dismiss open popovers given the event.

-

Before firing this event, the [=user agent=] SHOULD treat the target as if the pointing device has moved over it from the |previousTarget| for the purpose of ensuring event ordering [[UIEVENTS]]. If the |needsOverEvent| flag is set, a {{GlobalEventHandlers/pointerover}} event is needed even if the target element is the same.

Fire the event to the determined target.

@@ -906,6 +904,8 @@

Event dispatch

If |userEvent| was captured, |event| is dispatched to the capturing target of |userEvent| even though the {{GlobalEventHandlers/lostpointercapture}} event with the same {{PointerEvent/pointerId}} has been dispatched already.
+ +

Before a |click| event is dispatched, the light dismiss open popovers algorithm MUST be run given the target of the corresponding pointerdown event and the target of the corresponding pointerup event.

From 5013123f1b3c7a70a45cf922f2521b008233802c Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Tue, 5 Aug 2025 13:55:43 -0700 Subject: [PATCH 4/6] reorder to use new algorithm --- index.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d1815da..31d7876 100644 --- a/index.html +++ b/index.html @@ -899,13 +899,15 @@

Event dispatch

Otherwise (|event| is a click or auxclick event for which |userEvent| is a pointerup event that was dispatched uncaptured) let |target| be the nearest common inclusive ancestor of the corresponding pointerdown and pointerup targets in the DOM at the moment |event| is being dispatched.

+
  • +

    If |event| is a click event, then run light dismiss activities given |event|.

    +
  • +
  • Dispatch |event| to |target| following the [[UIEVENTS]] spec.

    If |userEvent| was captured, |event| is dispatched to the capturing target of |userEvent| even though the {{GlobalEventHandlers/lostpointercapture}} event with the same {{PointerEvent/pointerId}} has been dispatched already.
  • - -

    Before a |click| event is dispatched, the light dismiss open popovers algorithm MUST be run given the target of the corresponding pointerdown event and the target of the corresponding pointerup event.

    From 9a1419462de358c596e163aacd3a478c30402645 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 12 Dec 2025 11:04:38 -0800 Subject: [PATCH 5/6] pass more arguments to html --- index.html | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 31d7876..62cf6f0 100644 --- a/index.html +++ b/index.html @@ -900,7 +900,60 @@

    Event dispatch

  • -

    If |event| is a click event, then run light dismiss activities given |event|.

    +

    If |event| is a click event, then:

    +
      +
    1. +

      Let |pointerDownTarget|, |pointerDownX|, |pointerDownY|, |pointerUpTarget|, |pointerUpX|, and |pointerUpY| each be null.

      +
    2. + +
    3. +

      If |event| had corresponding pointerdown and pointerup events preceding it, then:

      +
        +
      1. +

        Set |pointerDownTarget| to the corresponding pointerdown event's event target.

        +
      2. + +
      3. +

        Set |pointerDownX| to the corresponding pointerdown event's clientX.

        +
      4. + +
      5. +

        Set |pointerDownY| to the corresponding pointerdown event's clientY.

        +
      6. + +
      7. +

        Set |pointerUpTarget| to the corresponding pointerup event's event target.

        +
      8. + +
      9. +

        Set |pointerUpX| to the corresponding pointerup event's clientX.

        +
      10. + +
      11. +

        Set |pointerUpY| to the corresponding pointerup event's clientY.

        +
      12. +
      +
    4. + +
    5. +

      Otherwise:

      +
        +
      1. +

        Set |pointerDownTarget| and |pointerUpTarget| to |event|'s event target.

        +
      2. + +
      3. +

        Set |pointerDownX| and |pointerUpX| to |event|'s clientX.

        +
      4. + +
      5. +

        Set |pointerDownY| and |pointerUpY| to |event|'s clientY.

        +
      6. +
      +
    6. +
    + +

    Run light dismiss activities given |pointerDownTarget|, |pointerDownX|, |pointerDownY|, |pointerUpTarget|, |pointerUpX|, and |pointerUpY|.

  • From fbc7da7a2ebbc7cd7cc9b6df41c942f4b10d49de Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Fri, 13 Feb 2026 12:50:04 -0800 Subject: [PATCH 6/6] move light dismiss step into click handling --- index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 62cf6f0..1b0d819 100644 --- a/index.html +++ b/index.html @@ -951,9 +951,12 @@

    Event dispatch

  • + +
  • +

    Run light dismiss activities given |pointerDownTarget|, |pointerDownX|, |pointerDownY|, |pointerUpTarget|, |pointerUpX|, and |pointerUpY|.

    +
  • -

    Run light dismiss activities given |pointerDownTarget|, |pointerDownX|, |pointerDownY|, |pointerUpTarget|, |pointerUpX|, and |pointerUpY|.