Skip to content
This repository has been archived by the owner on Mar 19, 2018. It is now read-only.

should addEventListener throw on invalid requireCancelable value? #4

Closed
RByers opened this issue Jul 3, 2015 · 3 comments
Closed
Labels

Comments

@RByers
Copy link
Member

RByers commented Jul 3, 2015

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?

@RByers RByers added the spec label Jul 3, 2015
@tdresser
Copy link
Collaborator

tdresser commented Jul 3, 2015

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
Copy link
Member Author

RByers commented Jul 3, 2015

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
Copy link
Member Author

RByers commented Jul 3, 2015

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants