I am currently updating an Angular project from v8 to v9, and I have discovered an issue with using CSS class attributes together with Angular Material components. I have also updated to Material v9.
With this simplified HTML,
// Example List 1
<mat-nav-list class="example-list-1">
<mat-list-item> SOME HTML.. </mat-list-item>
</mat-nav-list>
// Example List 2
<div class="example-list-2">
<mat-list-item> SOME HTML.. </mat-list-item>
</div>
the following SCSS,
[class^="example-list"] {
mat-list-item {
SOME SCSS..
}
}
is only adding style to the <mat-list-item>
in Example List 2, where <div>
is being used.
It works fine if I, for example, use id instead of class in both HTML and SCSS, but I would prefer not to have to do a lot of tinkering with the code.
Update
I have also found out it works fine if I disable Ivy.
"angularCompilerOptions": {
"enableIvy": false
}
Why is it not working with Ivy? Is this expected behavior?