-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(ngClass): add/remove classes which are properties of Object.prototype #11814
Conversation
Mind rewriting the commit message to clearly explain what the problem is/was and what the patch is fixing? There's a lot of domain-specific stuff in here that is hard to understand. |
@matsko PTAL, I've made the commit message more thorough and refactored it a bit. |
for (key in obj) { | ||
iterator.call(context, obj[key], key, obj); | ||
} | ||
} else if (typeof obj.hasOwnProperty === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't care, but shadowing hasOwnProperty
with a function will not be handled correctly.
Just saying...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on how it's shadowed --- I don't think we care, common case is a custom hasOwnProperty method won't be used
huh --- I guess this patch discovered a new IE quirk :< ( |
70da3aa
to
40356e7
Compare
…type Previously, ngClass and ngAnimate would track the status of classes using an ordinary object. This causes problems when class names match names of properties in Object.prototype, including non-standard Object.prototype properties such as 'watch' and 'unwatch' in Firefox. Because of this shadowing, ngClass and ngAnimate were unable to correctly determine the changed status of these classes. In orderto accomodate this patch, some changes have been necessary elsewhere in the codebase, in order to facilitate iterating, comparingand copying objects with a null prototype, or which shadow the `hasOwnProperty` method Summary: - fast paths for various internal functions when createMap() is used - Make createMap() safe for internal functions like copy/equals/forEach - Use createMap() in more places to avoid needing hasOwnProperty() Closes angular#11813
ping |
pong |
LGTM. Excellent work. |
thanks |
…type Previously, ngClass and ngAnimate would track the status of classes using an ordinary object. This causes problems when class names match names of properties in Object.prototype, including non-standard Object.prototype properties such as 'watch' and 'unwatch' in Firefox. Because of this shadowing, ngClass and ngAnimate were unable to correctly determine the changed status of these classes. In orderto accomodate this patch, some changes have been necessary elsewhere in the codebase, in order to facilitate iterating, comparingand copying objects with a null prototype, or which shadow the `hasOwnProperty` method Summary: - fast paths for various internal functions when createMap() is used - Make createMap() safe for internal functions like copy/equals/forEach - Use createMap() in more places to avoid needing hasOwnProperty() R=@matsko Closes angular#11813 Closes angular#11814
Closes #11813