Intent to Implement and Ship: addEventListener/removeEventListener non-optional arguments

60 views
Skip to first unread message

Philip Jägenstedt

unread,
Nov 20, 2015, 8:30:26 AM11/20/15
to blink-dev

Contact emails

phi...@opera.com


Spec

https://dom.spec.whatwg.org/#interface-eventtarget


Summary

Make the first two arguments (type and listener) of addEventListener and removeEventListener non-optional, matching the spec and other engines.


Motivation

That these have ever been optional is, as far as I can tell, an accident of WebKit history, it doesn't actually make sense, and it masks non-trivial programming errors.


In Gecko and Edge, these arguments are not optional, so emitting them will throw a TypeError.


Interoperability and Compatibility Risk

The change is motivated by interop concerns, although it's not on the interop hotlist and I'm not aware of specific problems in the wild.


As for compat, Edge has fortunately not copied this quirk, which is promising.


Something like addEventListener('foo') has been tickling the use counter for a while, and has been blocking this change. It has begun dropping, but it's not because of a new stable release. It's likely that making the change will reveal the source, and hopefully it's not in a library...


When trying to fix this I found internal uses of removeEventListener(listener), a form which looks sensible but doesn't actually do anything. I would also expect to see some of this in the wild.


All use counters:


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

https://crbug.com/353484


Link to entry on the feature dashboard

https://www.chromestatus.com/features/5640816202612736


Requesting approval to ship?

Yes. The problematic usage has begun to fall and we're right after a branch, so there's no time like now!

Rick Byers

unread,
Nov 20, 2015, 1:24:48 PM11/20/15
to Philip Jägenstedt, blink-dev
LGTM1

I think there is some compat risk here, and we should keep our eye out for breakage.  But I believe the interop and ergonomics benefit probably outweighs this risk.

Chris Harrelson

unread,
Nov 20, 2015, 2:29:16 PM11/20/15
to Rick Byers, Philip Jägenstedt, blink-dev
LGTM2

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Dave Tapuska

unread,
Nov 20, 2015, 3:43:06 PM11/20/15
to Chris Harrelson, Rick Byers, Philip Jägenstedt, blink-dev
Yeah! I've been wanting to do this too. 

TAMURA, Kent

unread,
Nov 23, 2015, 7:53:03 PM11/23/15
to Dave Tapuska, Chris Harrelson, Rick Byers, Philip Jägenstedt, blink-dev
LGTM3.

--
TAMURA Kent
Software Engineer, Google


Reply all
Reply to author
Forward
0 new messages