From 03357df2b9d309414cf7d500d29c3aa716fa0697 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 14 Dec 2023 15:07:02 +0100 Subject: [PATCH] Editorial: mark up algorithms about Events Also fix a typo that Bikeshed was able to find thanks to this. --- dom.bs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/dom.bs b/dom.bs index 37a5ee7b..b583aeb3 100644 --- a/dom.bs +++ b/dom.bs @@ -510,6 +510,7 @@ string.

The currentTarget attribute must return the value it was initialized to. When an event is created the attribute must be initialized to null. +

The composedPath() method steps are:

    @@ -608,6 +609,7 @@ was initialized to. When an event is created the attribute must be initia
  1. Return composedPath.

+

The eventPhase attribute must return the value it was initialized to, which must be one of the following: @@ -703,6 +705,7 @@ initialized to.


+

To initialize an event, with type, bubbles, and cancelable, run these steps: @@ -722,7 +725,9 @@ initialized to.

  • Set event's {{Event/cancelable}} attribute to cancelable. +

  • +

    The initEvent(type, bubbles, cancelable) method steps are: @@ -733,6 +738,7 @@ method steps are:

  • Initialize this with type, bubbles, and cancelable. +

  • {{Event/initEvent()}} is redundant with event constructors and incapable of setting {{Event/composed}}. It has to be supported for legacy content. @@ -792,6 +798,7 @@ dictionary CustomEventInit : EventInit {

    The detail attribute must return the value it was initialized to. +

    The initCustomEvent(type, bubbles, cancelable, detail) method steps are: @@ -804,6 +811,7 @@ method steps are:

  • Set this's {{CustomEvent/detail}} attribute to detail. +

  • Constructing events

    @@ -816,6 +824,7 @@ method steps are:

    This construct can be used by {{Event}} subclasses that have a more complex structure than a simple 1:1 mapping between their initializing dictionary members and IDL attributes. +

    When a constructor of the {{Event}} interface, or of an interface that inherits from the {{Event}} interface, is invoked, these steps must be run, given the arguments type and eventInitDict: @@ -828,7 +837,9 @@ must be run, given the arguments type and eventInitDict:

  • Return event. +

  • +

    To create an event using eventInterface, which must be either {{Event}} or an interface that inherits from @@ -858,13 +869,15 @@ it, and optionally given a realm realm, run these steps:

  • Return event. +

  • Create an event is meant to be used by other specifications which need to separately create and dispatch events, instead of simply firing them. It ensures the event's attributes are initialized to the correct defaults.

    -

    The inner event creation steps, given an interface, +

    +

    The inner event creation steps, given an eventInterface, realm, time, and dictionary, are as follows:

      @@ -890,6 +903,7 @@ correct defaults.

    1. Return event.

    +

    Defining event interfaces

    @@ -1246,6 +1260,7 @@ property of the event being dispatched.

    Ideally, any new event APIs are defined such that they do not need this property. (Use whatwg/dom for discussion.) +

    To legacy-obtain service worker fetch event listener callbacks given a {{ServiceWorkerGlobalScope}} global, run these steps. They return a list of {{EventListener}} objects. @@ -1265,10 +1280,12 @@ property of the event being dispatched.

  • Return callbacks. +

  • Dispatching events

    +

    To dispatch an event to a target, with an optional legacy target override flag and an optional legacyOutputDidListenersThrowFlag, run these steps: @@ -1468,7 +1485,9 @@ property of the event being dispatched.

  • Return false if event's canceled flag is set; otherwise true. +

  • +

    To append to an event path, given an event, invocationTarget, shadowAdjustedTarget, relatedTarget, touchTargets, and a slot-in-closed-tree, run these @@ -1494,7 +1513,9 @@ steps:

    root-of-closed-tree is root-of-closed-tree, and slot-in-closed-tree is slot-in-closed-tree. +
    +

    To invoke, given a struct, event, phase, and an optional legacyOutputDidListenersThrowFlag, run these steps: @@ -1559,7 +1580,9 @@ run these steps:

  • Set event's {{Event/type}} attribute value to originalEventType. +

  • +

    To inner invoke, given an event, listeners, phase, invocationTargetInShadowTree, and an optional legacyOutputDidListenersThrowFlag, run these steps: @@ -1633,10 +1656,12 @@ and an optional legacyOutputDidListenersThrowFlag, run these steps:

  • Return found. +

  • Firing events

    +

    To fire an event named e at target, optionally using an eventConstructor, with a description of how IDL attributes are to be initialized, and a legacy target override flag, run these steps: @@ -1659,6 +1684,7 @@ initialized, and a legacy target override flag, run these steps:

  • Return the result of dispatching event at target, with legacy target override flag set if set. +

  • Fire in the context of DOM is short for creating, initializing, and dispatching an event.