Contact emails
dtap...@chromium.org, rby...@chromium.org
Spec
https://github.com/whatwg/dom/pull/82
https://github.com/RByers/EventListenerOptions
Summary
Add the ability to set different options when adding event listeners via add a dictionary to addEventListener API.
ie: add addEventListener(DOMString, EventListener, EventListenerOptions);
Motivation
Currently other platforms (Gecko) add additional booleans to the argument list to modify the behavior of the added event listeners. We'd like to turn this into a dictionary (EventListenerOptions) so that is a more flexible API for future work. The specifications above were largely targeted to be able to support passive listeners and we wish to implement this. (a separate Intent to Implement will follow later) I think EventListenerOptions as an API stands by itself since there have been requests to add additional booleans to addEventListener.
Compatibility Risk
Low risk; it is an additional API that would need to be called.
Ongoing technical constraints
None.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes
OWP launch tracking bug
crbug.com/543685Link to entry on the feature dashboard
https://www.chromestatus.com/features/5718574840676352
Requesting approval to ship?
No; will be behind experimental flag.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
How would you feature detect it?addEventListener("click", function () { }, {a: 1}) does not throw.Developers should avoid using this API in browsers that do not support it, because it will make useCapture be true even if that flag is not specified.
Honestly, I prefer a whole new method for that (thus, easier to feature detect) and that can be shorter, a la jQuery even, element.on("click", function () { }); and an overload, element.on({handler: function () { }, type: "click", otherOption: 1}). addEventListener was always too long. This follows the way the new DOM chose with remove(), append(), closest() and the rest.
Can we add a UseCounter to detect when a non-boolean is passed as the third argument as a first step?
Recently we've found some crazy stuff like people calling removeEventListener() without any arguments, or calling addEventListener without a second argument far more often than we expected.This should be easy to measure the impact of how much content will possibly break.
On Thu, Oct 15, 2015 at 5:24 PM, Elliott Sprehn <esp...@chromium.org> wrote:Can we add a UseCounter to detect when a non-boolean is passed as the third argument as a first step?
Recently we've found some crazy stuff like people calling removeEventListener() without any arguments, or calling addEventListener without a second argument far more often than we expected.This should be easy to measure the impact of how much content will possibly break.I'm fine with that, but note that it will only be an upper bound on the possible breakage. In many cases an accidentally-capturing listener switching to be a non-capturing listener won't necessarily cause any problems (and is arguably more likely to be what the developer intended, perhaps fixing a problem). So even if we get a non-trivial amount of usage, we might still need to do something else (eg. attempt shipping) to better determine the real compat risk.
- E