3 ms·
"Events passed to your event handers are the 'real' browser DOM events." This is a real deal-breaker for me. One of the absolute best things about jQuery is ho
by kemayo 15y ago
"Events passed to your event handers are the 'real' browser DOM events."
This is a real deal-breaker for me. One of the absolute best things about jQuery is how it normalizes events, so you don't have to care that, e.g., the source element is event.target in some browsers and event.srcElement in others.
- mythz 15y agoThe source element is also bounded to the 'this' context. I'm curious where the other breakages are, I've normalized the events where I see that it's needed, e.g. like in the custom `$.key()` function. I think the better approach is to opt-in to receive the cross-browser normalized event in this way, i.e. via another plugin. There are a lot of cases where it doesn't matter and you don't even use the passed in jQuery event and such the overhead is otherwise not welcome.
- mythz 15y agoNote: jquery is also removing copying unifid props from the events, instead needing to access it in future via $.originalEvent.srcElement, etc http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/ http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/
- shadowfiend 15y agoI don't think that means it's removing unified properties. I think that means that srcElement won't be copied in, but target will still refer to the right thing (i.e., to srcElement if that's what the current browser is providing). It's just not also providing a copy of srcElement for the user.
- netghost 15y agoIf you're only targeting a subset of browsers, like say ones released in the last 4 years, it's usually fine. Though if you need to handle older versions (not just IE, all the browsers have some oddities), then it's quite helpful to have jQuery normalize them.