diff --git a/dom.bs b/dom.bs index ea0828c68..b1565101b 100644 --- a/dom.bs +++ b/dom.bs @@ -53,8 +53,8 @@ urlPrefix: https://w3c.github.io/ServiceWorker/#; spec: SERVICE-WORKERS text: script resource; for: service worker text: has ever been evaluated flag; for: service worker urlPrefix: https://tc39.github.io/ecma262/#; spec: ECMASCRIPT - text: Construct; url: sec-construct; type: abstract-op text: Realm; url: realm; type: dfn + text: SameValueZero; url: sec-samevaluezero; type: abstract-op @@ -913,6 +935,8 @@ when something has occurred.
  • capture (a boolean, initially false)
  • passive (a boolean, initially false)
  • once (a boolean, initially false) +
  • is grouped (a boolean, initially false) +
  • group (any Web IDL value, initially null)
  • removed (a boolean for bookkeeping purposes, initially false) @@ -952,32 +976,42 @@ are not to be used for anything else. [[!HTML]] The options argument sets listener-specific options. For compatibility this can be just a boolean, in which case the method behaves exactly as if the value was specified as - options' capture member. + options's {{EventListenerOptions/capture}} member. - When set to true, options' capture member prevents callback from - being invoked when the event's {{Event/eventPhase}} attribute value is + When set to true, options's {{EventListenerOptions/capture}} member prevents + callback from being invoked when the event's {{Event/eventPhase}} attribute value is {{Event/BUBBLING_PHASE}}. When false (or not present), callback will not be invoked when event's {{Event/eventPhase}} attribute value is {{Event/CAPTURING_PHASE}}. Either way, callback will be invoked if event's {{Event/eventPhase}} attribute value is {{Event/AT_TARGET}}. - When set to true, options' passive member indicates that the - callback will not cancel the event by invoking {{Event/preventDefault()}}. This is used to - enable performance optimizations described in [[#observing-event-listeners]]. + When set to true, options' {{AddEventListenerOptions/passive}} member indicates that + the callback will not cancel the event by invoking {{Event/preventDefault()}}. This is used + to enable performance optimizations described in [[#observing-event-listeners]]. + + When set to true, options's {{AddEventListenerOptions/once}} member indicates that the + callback will only be invoked once after which the event listener will be removed. - When set to true, options's once member indicates that the callback - will only be invoked once after which the event listener will be removed. + When provided, options's {{AddEventListenerOptions/group}} member is stored so that + later calls to {{EventTarget/removeEventListener(type, options)}} or + {{EventTarget/removeEventListener(options)}} can remove all event listeners that provided the same + group value. The event listener is appended to target's list of event listeners and is not appended if it is a duplicate, i.e., having the same type, callback, and capture values. -
    target . removeEventListener(type, callback [, options]) -
    Remove the event listener - in target's list of - event listeners with the same - type, callback, and - options. +
    target . removeEventListener(type, callback [, options]) +
    Remove the event listener in target's list of event listeners with the + same type, callback, and options. + +
    target . removeEventListener(type, { group }) +
    Remove all event listeners in target's list of event listeners with + the same type and group. + +
    target . removeEventListener({ group }) +
    Remove all event listeners in target's list of event listeners with + the same group (regardless of their type).
    target . dispatchEvent(event)
    Dispatches a synthetic event event to target and returns @@ -993,8 +1027,8 @@ steps:
  • If options is a boolean, set capture to options. -

  • If options is a dictionary, then set capture to options's - {{EventListenerOptions/capture}}. +

  • If options is a dictionary, then set capture to + options["{{EventListenerOptions/capture}}"].

  • Return capture. @@ -1005,52 +1039,64 @@ steps:

    1. Let capture be the result of flattening options. -

    2. Let once and passive be false. +

    3. Let once, passive, and is grouped be false, and let group be null. -

    4. If options is a dictionary, then set passive to options's - {{AddEventListenerOptions/passive}} and once to options's - {{AddEventListenerOptions/once}}. +

    5. +

      If options is a dictionary, then: +

        +
      1. Set passive to options["{{AddEventListenerOptions/passive}}"] and + once to options["{{AddEventListenerOptions/once}}"]. + +

      2. If {{AddEventListenerOptions/group}} is present in options, set + is grouped to true and set group to + options["{{AddEventListenerOptions/group}}"]. +

      -
    6. Return capture, passive, and once. +

    7. Return the tuple (capture, passive, once, is grouped, + group).

    +

    To perform a service worker check on eventTarget, +throw a {{TypeError}} if eventTarget's relevant global object is a +{{ServiceWorkerGlobalScope}} object and its associated service worker's +script resource's +has ever been evaluated flag is set. [[!SERVICE-WORKERS]] + +

    To optimize storing the event types allowed for the service worker and to +avoid non-deterministic changes to the event listeners, invocation of certain {{EventTarget}} +methods is allowed only during the very first evaluation of the service worker script. + +

    Two Web IDL values are equal for grouping purposes if, when +converted to ECMAScript values, the results are equivalent according to +SameValueZero. [[!ECMASCRIPT]] +

    The addEventListener(type, callback, options) method, when invoked, must run these steps:

      -
    1. -

      If context object's relevant global object is a {{ServiceWorkerGlobalScope}} - object and its associated service worker's script resource's - has ever been evaluated flag is set, then throw a - TypeError. - [[!SERVICE-WORKERS]] - -

      To optimize storing the event types allowed for the service worker and - to avoid non-deterministic changes to the event listeners, invocation of the method is allowed - only during the very first evaluation of the service worker script. +

    2. Perform a service worker check on context object.

    3. If callback is null, then return. -

    4. Let capture, passive, and once be the result of - flattening more options. +

    5. Let (capture, passive, once, is grouped, + group) be the result of flattening more options.

    6. If context object's associated list of event listener does not contain an event listener whose type is type, callback is callback, - and capture is capture, then append a new event listener to it, whose + capture is capture, is grouped is is grouped, and group + is equal to group, then append a new event listener to it, whose type is type, callback is callback, capture is - capture, passive is passive, and once is once. + capture, passive is passive, once is once, + is grouped is is grouped, and group is group.

    The removeEventListener(type, callback, options) -method, when invoked, must, run these steps +method overload, when invoked, must run these steps

      -
    1. If context object's relevant global object is a {{ServiceWorkerGlobalScope}} - object and its associated service worker's script resource's - has ever been evaluated flag is set, then throw a - TypeError. [[!SERVICE-WORKERS]] +

    2. Perform a service worker check on context object.

    3. Let capture be the result of flattening options. @@ -1060,6 +1106,31 @@ method, when invoked, must, run these steps the associated list of event listeners.

    +

    The +removeEventListener(type, options) +method overload, when invoked, must run these steps + +

      +
    1. Perform a service worker check on context object. + +

    2. Remove all event listeners in the associated list of event listeners whose + type is type, is grouped is true, and group is + equal for grouping purposes to + options["{{RemoveEventListenerGroupOptions/group}}"]. +

    + +

    The +removeEventListener(options) +method overload, when invoked, must run these steps + +

      +
    1. Perform a service worker check on context object. + +

    2. Remove all event listeners in the associated list of event listeners whose + is grouped is true and group is equal for grouping purposes to + options["{{RemoveEventListenerGroupOptions/group}}"]. +

    +

    The dispatchEvent(event) method, when invoked, must run these steps: