-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngClass is too greedy #4960
Comments
ngClass works by removing all the former classes and then adding all the new classes to the element during each watch change operation. This may cause transition animations to never render. The ngClass directive will now only add and remove the classes that change during each watch operation. Closes angular#4960
The problem is, there are many guys fighting to set the class:
There is IMHO no way to give everybody the power to "set" the value. Whoever is changing the class has to also pass its previous value (the previous value that this particular guy set before, not the actual class value at that time). I suggest It is basically splitting the shared memory (full class name) into chunks and every component only changes its chunk (set of classes). The only problem I can think of it when two components use the same class name. For instance, a directive set class to "a b" and interpolation sets the class to "b c". At that point, class is "a b c". Then, if the directive sets the class to "a", it will remove "b" class, even though the interpolation still expects it to be there. |
ngClass works by removing all the former classes and then adding all the new classes to the element during each watch change operation. This may cause transition animations to never render. The ngClass directive will now only add and remove the classes that change during each watch operation. Closes angular#4960 Closes angular#4944
ngClass works by removing all the former classes and then adding all the new classes to the element during each watch change operation. This may cause transition animations to never render. The ngClass directive will now only add and remove the classes that change during each watch operation. Closes angular#4960 Closes angular#4944
ngClass and {{ class }} are too greedy when dealing with class value changes.
For example:
If you set:
Then what will happen is it will remove all the classes first and then add back
.two
+.three
.This causes an issue with animations because if you have a transition on one of the classes (say
.two
) then the removeClass animation will be skipped since addClass happens right after cancelling out the removeClass animation, but this shouldn't happen in the first place since there should not be an addClass operation at all if only one ngClass value is set to false.The text was updated successfully, but these errors were encountered: