WICG / EventListenerOptions

An extension to the DOM event pattern to allow authors to disable support for preventDefault
Other
1.17k stars 140 forks source link

should addEventListener throw on invalid requireCancelable value? #4

Closed RByers closed 9 years ago

RByers commented 9 years ago

Is it legitimate for addEventListener to know whether each type of event is cancelable and be able to throw when asking for a cancelable event of a type that is never cancelable? Perhaps that should just silently proceed with uncancelable events?

tdresser commented 9 years ago

At minimum, Chrome would need to provide a devtools warning in this case.

Are there cases where throwing would be useful for browser feature detection? For instance, if an event type is cancelable in some browsers but not others, then if addEventListener throws, you can test if the event type is cancelable on the current browser, and if not, use some alternative behavior.

RByers commented 9 years ago

Are there cases where throwing would be useful for browser feature detection?

I think relying on exceptions for feature detection is generally discouraged. I mentioned here that I could imagine us wanting to add an API like TouchEvent.supportsCancelation if we someday decide to revoke the ability for a poorly performing page to cancel any touch events.

Still, I agree the exception might be more useful than silently doing the wrong thing. Silently doing the wrong thing is more "webby" though :-)

RByers commented 9 years ago

BTW I filed #8 for the general issue of feature detection for this API.