Skip to content

perf(material/checkbox): Optimize css selectors #30386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/material/checkbox/_checkbox-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,15 @@ $_fallback-size: 40px;
// MDC expects `.mdc-checkbox__ripple::before` to be the state layer, but we use
// `.mdc-checkbox__ripple` instead, so we emit the state layer slots ourselves.
&:hover {
.mdc-checkbox__ripple {
> .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, unselected-hover-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
unselected-hover-state-layer-color
);
}

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

.mdc-checkbox__native-control:focus {
& ~ .mdc-checkbox__ripple {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, unselected-focus-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -490,8 +490,8 @@ $_fallback-size: 40px;
}
}

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

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

.mdc-checkbox__native-control:focus:checked {
& ~ .mdc-checkbox__ripple {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, selected-focus-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -541,8 +541,8 @@ $_fallback-size: 40px;
}
}

&:active .mdc-checkbox__native-control:checked {
& ~ .mdc-checkbox__ripple {
&:active > .mdc-checkbox__native-control:checked {
& + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(opacity, selected-pressed-state-layer-opacity);
@include token-utils.create-token-slot(
background-color,
Expand All @@ -561,7 +561,7 @@ $_fallback-size: 40px;
// Needs extra specificity to override the focus, hover, active states.
.mdc-checkbox--disabled.mat-mdc-checkbox-disabled-interactive & {
.mdc-checkbox__native-control ~ .mat-mdc-checkbox-ripple .mat-ripple-element,
.mdc-checkbox__native-control ~ .mdc-checkbox__ripple {
.mdc-checkbox__native-control + .mdc-checkbox__ripple {
@include token-utils.create-token-slot(
background-color,
unselected-hover-state-layer-color
Expand Down
Loading