Skip to content

Commit 5d6d25f

Browse files
kseamonandrewseguin
authored andcommitted
perf(material/checkbox): Optimize css selectors (#30386)
(cherry picked from commit e4388c6)
1 parent 4a96a25 commit 5d6d25f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/material/checkbox/_checkbox-common.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -457,15 +457,15 @@ $_fallback-size: 40px;
457457
// MDC expects `.mdc-checkbox__ripple::before` to be the state layer, but we use
458458
// `.mdc-checkbox__ripple` instead, so we emit the state layer slots ourselves.
459459
&:hover {
460-
.mdc-checkbox__ripple {
460+
> .mdc-checkbox__ripple {
461461
@include token-utils.create-token-slot(opacity, unselected-hover-state-layer-opacity);
462462
@include token-utils.create-token-slot(
463463
background-color,
464464
unselected-hover-state-layer-color
465465
);
466466
}
467467

468-
.mat-mdc-checkbox-ripple .mat-ripple-element {
468+
> .mat-mdc-checkbox-ripple .mat-ripple-element {
469469
@include token-utils.create-token-slot(
470470
background-color,
471471
unselected-hover-state-layer-color
@@ -474,7 +474,7 @@ $_fallback-size: 40px;
474474
}
475475

476476
.mdc-checkbox__native-control:focus {
477-
& ~ .mdc-checkbox__ripple {
477+
& + .mdc-checkbox__ripple {
478478
@include token-utils.create-token-slot(opacity, unselected-focus-state-layer-opacity);
479479
@include token-utils.create-token-slot(
480480
background-color,
@@ -490,8 +490,8 @@ $_fallback-size: 40px;
490490
}
491491
}
492492

493-
&:active .mdc-checkbox__native-control {
494-
& ~ .mdc-checkbox__ripple {
493+
&:active > .mdc-checkbox__native-control {
494+
& + .mdc-checkbox__ripple {
495495
@include token-utils.create-token-slot(opacity, unselected-pressed-state-layer-opacity);
496496
@include token-utils.create-token-slot(
497497
background-color,
@@ -508,7 +508,7 @@ $_fallback-size: 40px;
508508
}
509509

510510
&:hover .mdc-checkbox__native-control:checked {
511-
& ~ .mdc-checkbox__ripple {
511+
& + .mdc-checkbox__ripple {
512512
@include token-utils.create-token-slot(opacity, selected-hover-state-layer-opacity);
513513
@include token-utils.create-token-slot(
514514
background-color,
@@ -525,7 +525,7 @@ $_fallback-size: 40px;
525525
}
526526

527527
.mdc-checkbox__native-control:focus:checked {
528-
& ~ .mdc-checkbox__ripple {
528+
& + .mdc-checkbox__ripple {
529529
@include token-utils.create-token-slot(opacity, selected-focus-state-layer-opacity);
530530
@include token-utils.create-token-slot(
531531
background-color,
@@ -541,8 +541,8 @@ $_fallback-size: 40px;
541541
}
542542
}
543543

544-
&:active .mdc-checkbox__native-control:checked {
545-
& ~ .mdc-checkbox__ripple {
544+
&:active > .mdc-checkbox__native-control:checked {
545+
& + .mdc-checkbox__ripple {
546546
@include token-utils.create-token-slot(opacity, selected-pressed-state-layer-opacity);
547547
@include token-utils.create-token-slot(
548548
background-color,
@@ -561,7 +561,7 @@ $_fallback-size: 40px;
561561
// Needs extra specificity to override the focus, hover, active states.
562562
.mdc-checkbox--disabled.mat-mdc-checkbox-disabled-interactive & {
563563
.mdc-checkbox__native-control ~ .mat-mdc-checkbox-ripple .mat-ripple-element,
564-
.mdc-checkbox__native-control ~ .mdc-checkbox__ripple {
564+
.mdc-checkbox__native-control + .mdc-checkbox__ripple {
565565
@include token-utils.create-token-slot(
566566
background-color,
567567
unselected-hover-state-layer-color

0 commit comments

Comments
 (0)