Jquery: Event types colliding with Object prototype properties don't work

Created on 1 Aug 2016  路  9Comments  路  Source: jquery/jquery

We use event.type as a key to get the array of event handlers, which throws an exception when we instead receive an Object.prototype property and treat it like an array: https://jsfiddle.net/9t4kqaqr/

Our standard fix is appending a space (cf. delegated selector match tracking and Sizzle createCache), but we should also consider Map for such purposes (ponyfilling as needed), especially if Data.js can be updated accordingly鈥攐ne of @rwaldron's original goals when creating it.

Event Has Pull Request

Most helpful comment

In my opinion this is a breaking change that should not go into 3.5.0 minor upgrade version. It can break a lot of dependent projects, like this one: https://github.com/snapappointments/bootstrap-select/issues/2430

All 9 comments

but we should also consider Map for such purposes

Why not Object.create(null)? This one we wouldn't have to ponyfill.

Why not Object.create(null)?

I thought we still supported environments where that fails, but things look good! :+1:

Yup, and the changes required in that case will be smaller. :)

I'm only not sure if PhantomJS 1.x supports Object.create.

I've just rediscovered this bug. Is there a reason this hasn't been fixed yet?

No one has yet gotten around to it. But a pull request would be welcome!

I think we can implement the easy fix with spaces immediately, then consider using Map in 4.0.

PR: #4603. I also fixed similar issues in manipulation & data modules using Object.create(null).

In my opinion this is a breaking change that should not go into 3.5.0 minor upgrade version. It can break a lot of dependent projects, like this one: https://github.com/snapappointments/bootstrap-select/issues/2430

@rjaros Please submit a new issue with details.

Was this page helpful?
0 / 5 - 0 ratings