Skip to content
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

Closed
Gozala opened this issue Aug 17, 2015 · 8 comments
Closed

Support custom non-standard DOM events #4645

Gozala opened this issue Aug 17, 2015 · 8 comments

Comments

@Gozala
Copy link

Gozala commented Aug 17, 2015

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

@daukantas
Copy link

I hereby add my support to custom non-standard DOM events.

@louisremi
Copy link

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).

@Gozala
Copy link
Author

Gozala commented Sep 11, 2015

Is there any chance to get any kind of feedback on this ?

@rpominov
Copy link
Contributor

This may be related #4751

@sebmarkbage
Copy link
Collaborator

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.

@Gozala
Copy link
Author

Gozala commented Sep 14, 2015

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
})

@nhunzaker
Copy link
Contributor

nhunzaker commented Oct 23, 2016

@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:
nhunzaker#2

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 SimpleEventPlugin as you'd suggested.

Does this feel like the right track?

@nhunzaker
Copy link
Contributor

We have a few duplicates of this issue, so I'm closing it out. This should land with #7311

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

No branches or pull requests

6 participants