Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Polyfill for mouse{enter,leave}? #931

Closed
mbostock opened this Issue Nov 29, 2012 · 3 comments

Comments

3 participants
Owner

mbostock commented Nov 29, 2012

The W3C has standardized mouseenter and mouseleave events. However, they have not yet been adopted outside of IE9+. (Go figure!) I don't want D3 to be a compatibility layer, but at the same time, it might be nice to bend the rules a little bit given that it should be standardized in the future.

It's fairly easy to test for native support:

var supportsMouseenter = "onmouseenter" in window;

@shawnbot has a nice implementation in d3-bootstrap's d3-compat.js. I think it needs a tweak to support removing listeners, when callback is null, but otherwise it looks like an elegant and useful solution.

Just a note to say that I think standardizing now on APIs that you like and are confident will be implemented in future is definitely a good thing. It's served Cinder really well (everyone using Cinder got some good bits of C++11 over a year early).

Thanks for the heads up on the null callback condition. And yes, I agree with Tom that it's good to standardize on APIs that will be supported eventually. It's always nice to remove compatibility hacks when you no longer need them.

mbostock added a commit that referenced this issue Feb 19, 2013

Owner

mbostock commented Mar 11, 2013

Staged in #1120.

@mbostock mbostock closed this Mar 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment