-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e.preventDefault on custom events does not carry into base event #23
Comments
Can you give me an idea of what the expected behavior should be? I'm not sure what you mean, as there is no true default for the custom events, as they are just expressions of when other events and conditions occur. Let's talk more, and example would be helpful to see what you have in mind. |
Basically, something similar to jQuery's approach, such that e.preventDefault is interpreted as meaning "I want to preventDefault the event that got auto-wrapped into a custom event under the hood". |
If we want to offer the behavior you describe (relaying the preventDefault down), I feel we should introduce a separate, or combined method to enable it. |
But in what use case would someone want to preventDefault a custom event without preventDefaulting the base event? The point of this issue is to simplify the API usage and make the event manipulation as close to native as possible (which is what jQuery does), and introducing a separate method defeats the purpose. |
The new longtap event is a good example - while a user may want to prevent the longtap progression, they may not want to stop the underlying touchend. Another thing to consider: if you block the underlying observed delegate, you could be affecting the operation of other events as well. There are many reasons you just want to prevent one or the other, I believe we should add methods for both. |
I'll try to take a look at providing a solution for this next week |
@csuwildcat What's the status of this ? |
It can be done, but needs to be coded into core. If implemented, it should
|
I can get this in sometime this week. |
Week ? |
Haven't seen this for a long time, sorry about that. I can do this if it's
|
it can be handy in some situations |
people don't use what we want is a shorter version of
|
opened a pull request didn't test it tho |
The issue that comes to mind with the pull request's code is that events can inherit from other events., so the preventDefault call would need to cascade down to the next in the chain. For example: if you called prevent default on a custom composite event called As I see it we have two options:
|
When I have a listener function for a custom event such as "tapstart",
e.preventDefault
does not work as intended, and users must explicitly call e.baseEvent.preventDefault.This could easily be a point of confusion, and also breaks backwards compatibility with older code.
The text was updated successfully, but these errors were encountered: