You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ngClass causes unnecessary CSS class mutation even if computed classes are unchanged #25518
open DevTools "Elements" tab and inspect the <div> with the I'm red content
click on the I'm just triggering CD button and observe that the red CSS class gets removed and added just after.
Current behavior
CSS class is removed and added just after, even if a set of CSS classes doesn't change based on the model provided.
Expected behavior
There are no unnecessary CSS class mutations.
What is the motivation / use case for changing the behavior?
Current behaviour causes unnecessary DOM access impacting overall performance.
It can also tip off people using mutation observers as reported in ng-bootstrap/ng-bootstrap#2582 (comment)
Environment
Angular version: ALL
Browser: ALL
Additional info
This happens because I'm giving ngClass a new object on each CD. NgClass / differs assume that a new object might have different shape and removes classes from the old object. We should probably be smarter about it...
Reacted by Tsvetomir Tsonev, Laurens von Assel, Lars Gyrup Brink Nielsen, Kirill, nifiro and Alex
changed the title [-]ngCLass causes unnecessary CSS class mutation in some cases[/-][+]ngClass causes unnecessary CSS class mutation even if computed classes are unchanged[/+]on May 28, 2020
Activity
fix(timepicker): avoid unnecessary CSS class mutation in the DOM
[-]ngCLass causes unnecessary CSS class mutation in some cases[/-][+]ngClass causes unnecessary CSS class mutation even if computed classes are unchanged[/+]9 remaining items
perf(common): avoid excessive DOM mutation in NgClass (#48433)
perf(docs-infra): remove usage of the NgClass directive (angular#48312)
perf(common): avoid excessive DOM mutation in NgClass (angular#48433)
angular-automatic-lock-bot commentedon Feb 13, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.