-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Closed
Copy link
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: commonIssues related to APIs in the @angular/common packageIssues related to APIs in the @angular/common packagearea: performanceIssues related to performanceIssues related to performancefreq2: mediumstate: confirmedtype: bug/fixworkaround1: obvious
Milestone
Description
I'm submitting a...
[x] Bug report
Minimal reproduction of the problem with instructions
https://stackblitz.com/edit/angular-jxxkvh?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce:
- open DevTools "Elements" tab and inspect the
<div>with theI'm redcontent - click on the
I'm just triggering CDbutton and observe that theredCSS 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...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: commonIssues related to APIs in the @angular/common packageIssues related to APIs in the @angular/common packagearea: performanceIssues related to performanceIssues related to performancefreq2: mediumstate: confirmedtype: bug/fixworkaround1: obvious