-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Support custom non-standard DOM events #4645
Comments
I hereby add my support to custom non-standard DOM events. |
I recommend taking inspiration from the battle-tested special event API of jQuery. It has allowed devs to both normalize events across browsers (wheel events for example), and support new kind of events such as triple click (not saying this one's a good idea). |
Is there any chance to get any kind of feedback on this ? |
This may be related #4751 |
This has been asked for many times before. See discussion in #4751. It might make sense to allow any function to pass through and become a "simple event plugin" by default. That way there is no whitelist necessarily. This would make it a breaking change if we ever added custom logic to that particular event. Which we likely will. However, that's the stance we've already taking with other attributes in general. |
You could require a specific "simple event plugin" to avoid breaking changes, which could be as simple as: html.div({ onClick: handleSyntheticClick, onNativeClick: handleNativeClick }) Or more complex but robust as: html.div({
onClick: handleSyntheticClick,
[React.on('click')]: handleNativeClick
}) |
@sebmarkbage Sort of spurred by #7901, but I've been wanting custom events for a while and had some prior work stripping out the attribute whitelist to support custom attributes (#7311). So I took a stab: I've PR'ed this to myself (against #7311). I'm hesitant to submit a PR against another PR, but I think I'm happy with it. There was a lot of event name munging already happening, I was able to lower that, move most of it to a central location, and lean on the existing Does this feel like the right track? |
We have a few duplicates of this issue, so I'm closing it out. This should land with #7311 |
Please add support for custom non-standard DOM events, ideally through a public API but if that's a "no go" at least some way that would not require forking the code base.
Here is my attempt of exposing non-standard events after getting some insights on IRC, unfortunately it still does not work (as event listeners are not registered) and I am not sure if there is more whitelists somewhere that skips those custom events:
https://gist.github.com/Gozala/a977973957fcee9c5671
P.S.: Any help in changing this snippet to make it work is also greatly appreciated
The text was updated successfully, but these errors were encountered: