From 9400bac89e77c529d1382994850392e2072e5f13 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 28 Jun 2017 16:50:27 -0400 Subject: [PATCH] Allow multiple groups; also fix removal --- dom.bs | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/dom.bs b/dom.bs index fd1f7b13..2acca874 100644 --- a/dom.bs +++ b/dom.bs @@ -334,7 +334,7 @@ to remove all event listeners in that group:
 oven.addEventListener("turnon", () => { … }, { group: "brownies" })
-oven.addEventListener("heat", () => { … }, { group: "brownies" })
+oven.addEventListener("heat", () => { … }, { group: ["brownies", "adjustments"] })
 oven.addEventListener("turnoff", () => { … }, { group: "brownies" })
 
 oven.removeEventListener({ group: "brownies" })
@@ -916,7 +916,7 @@ dictionary RemoveEventListenerGroupOptions {
 dictionary AddEventListenerOptions : EventListenerOptions {
   boolean passive = false;
   boolean once = false;
-  EventGroup group;
+  (EventGroup or sequence<EventGroup>) group;
 };
 
@@ -936,7 +936,7 @@ when something has occurred.
  • capture (a boolean, initially false)
  • passive (a boolean, initially false)
  • once (a boolean, initially false) -
  • group (an {{EventGroup}} or null) +
  • groups (a list of {{EventGroup}}s, initially empty)
  • removed (a boolean for bookkeeping purposes, initially false) @@ -995,7 +995,9 @@ are not to be used for anything else. [[!HTML]] 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. It can be either a string or a symbol. + group value. It can be either a string or a symbol. It can also be an iterable containing strings + or symbols, to attach multiple group values to the listener, any one of which can be used for + later removal. 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 @@ -1039,7 +1041,8 @@ steps:
    1. Let capture be the result of flattening options. -

    2. Let once and passive, and let group be null. +

    3. Let once and passive, and let groups be an empty + list.

    4. If options is a dictionary, then: @@ -1047,24 +1050,33 @@ steps:

    5. Set passive to options["{{AddEventListenerOptions/passive}}"] and once to options["{{AddEventListenerOptions/once}}"]. -

    6. If {{AddEventListenerOptions/group}} is present in options, set - group to options["{{AddEventListenerOptions/group}}"]. +

    7. If {{AddEventListenerOptions/group}} is present in options and is an + {{EventGroup}}, set groups to a list containing the single item given by + options["{{AddEventListenerOptions/group}}"]. + +

    8. Otherwise, if {{AddEventListenerOptions/group}} is present in options, + set groups to options["{{AddEventListenerOptions/group}}"].

  • Return the tuple (capture, passive, once, - group). + groups). -

    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 +

    To perform a service worker check on an {{EventTarget}} +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. +

    To remove an event listener +listener from an {{EventTarget}} eventTarget, set listener's +removed to true and remove it from eventTarget's associated list +of event listeners. +

    The addEventListener(type, callback, options) method, when invoked, must run these steps: @@ -1074,7 +1086,7 @@ method, when invoked, must run these steps:

  • If callback is null, then return. -

  • Let (capture, passive, once, group) be the +

  • Let (capture, passive, once, groups) be the result of flattening more options.

  • If context object's associated list of event listener does not contain an @@ -1082,7 +1094,7 @@ method, when invoked, must run these steps: and capture is capture, then append a new event listener to it, whose type is type, callback is callback, capture is capture, passive is passive, once is once, and - group is group. + groups is groups.

    The @@ -1096,8 +1108,7 @@ method overload, when invoked, must run these steps:

  • If there is an event listener in the associated list of event listeners whose type is type, callback is callback, and capture is - capture, then set that event listener's removed to true and remove it from - the associated list of event listeners. + capture, then remove it.

    The @@ -1107,8 +1118,8 @@ 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 and group is +

    3. Remove all event listeners whose type is + type and groups contains options["{{RemoveEventListenerGroupOptions/group}}"].

    @@ -1119,8 +1130,8 @@ 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 - group is options["{{RemoveEventListenerGroupOptions/group}}"]. +

    3. Remove all event listeners whose groups + contains options["{{RemoveEventListenerGroupOptions/group}}"].

    The dispatchEvent(event) method, when