-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(rootScope, ngRepeat): add support for objects created with Object.create(null) for ngRepeat and $watchCollection #9964
fix(rootScope, ngRepeat): add support for objects created with Object.create(null) for ngRepeat and $watchCollection #9964
Conversation
… order not to inherit from Object
…it does not inherit from Object
…ich does not inherit from Object
@petebacondarwin do we want this? I feel like we should be steering people away from using non-arrays with ngRepeat. Otherwise, it looks like a good patch. Except for the fact that it's missing tests and is doing a ton of crazy style changes that will probably fail jscs |
I got an old version of the parse file. I'm updating it right away
|
The reason i proposed this fix is because the application i'm currently working on, is embedded on an external webapp, which mangles around Object.prototype. Because of this, we create all our objects with Object.create(null) so that we don't inherit anything that might break things. |
I guess this is fine, but please add a test case for this, alright? |
Sure! I'll add them as soon as i'm home
|
I added some tests and landed this for 1.4.x. |
…ich does not inherit from Object Closes #9964
I guess @HeberLZ never made it home :( |
@ocombe, I think the man just fine according to his GitHub activity 😌 |
I'm really sorry about this, completely forgot about this pr because at the company i used to work at, we stopped using Object.create(null) |
Basically, the hasOwnProperty method was being called from an object gotten from the user. When that object was initially created with Object.create(null), it didn't inherit from Object so it didn't have the hasOwnProperty method throwing an "undefined is not a function" error.
This was fixed by executing hasOwnProperty.call(object, key) instead of object.hasOwnProperty(key)