Skip to content

Commit 0477022

Browse files
crisbetommalerba
authored andcommittedJan 25, 2022
fix(material/slide-toggle): remove divs nested inside label (#21224)
We made similar adjustments to other components that had `div` elements inside the control `label` (#20990, #20986), but we never fixed it for the slide toggle. (cherry picked from commit d1cd928)
1 parent ebf1580 commit 0477022

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
 

‎src/material/slide-toggle/slide-toggle.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<label [attr.for]="inputId" class="mat-slide-toggle-label" #label>
2-
<div #toggleBar class="mat-slide-toggle-bar"
2+
<span #toggleBar class="mat-slide-toggle-bar"
33
[class.mat-slide-toggle-bar-no-side-margin]="!labelContent.textContent || !labelContent.textContent.trim()">
44

55
<input #input class="mat-slide-toggle-input cdk-visually-hidden" type="checkbox"
@@ -10,27 +10,27 @@
1010
[checked]="checked"
1111
[disabled]="disabled"
1212
[attr.name]="name"
13-
[attr.aria-checked]="checked.toString()"
13+
[attr.aria-checked]="checked"
1414
[attr.aria-label]="ariaLabel"
1515
[attr.aria-labelledby]="ariaLabelledby"
1616
[attr.aria-describedby]="ariaDescribedby"
1717
(change)="_onChangeEvent($event)"
1818
(click)="_onInputClick($event)">
1919

20-
<div class="mat-slide-toggle-thumb-container" #thumbContainer>
21-
<div class="mat-slide-toggle-thumb"></div>
22-
<div class="mat-slide-toggle-ripple mat-focus-indicator" mat-ripple
20+
<span class="mat-slide-toggle-thumb-container" #thumbContainer>
21+
<span class="mat-slide-toggle-thumb"></span>
22+
<span class="mat-slide-toggle-ripple mat-focus-indicator" mat-ripple
2323
[matRippleTrigger]="label"
2424
[matRippleDisabled]="disableRipple || disabled"
2525
[matRippleCentered]="true"
2626
[matRippleRadius]="20"
2727
[matRippleAnimation]="{enterDuration: _noopAnimations ? 0 : 150}">
2828

29-
<div class="mat-ripple-element mat-slide-toggle-persistent-ripple"></div>
30-
</div>
31-
</div>
29+
<span class="mat-ripple-element mat-slide-toggle-persistent-ripple"></span>
30+
</span>
31+
</span>
3232

33-
</div>
33+
</span>
3434

3535
<span class="mat-slide-toggle-content" #labelContent (cdkObserveContent)="_onLabelTextChange()">
3636
<!-- Add an invisible span so JAWS can read the label -->

‎src/material/slide-toggle/slide-toggle.scss

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ $bar-track-width: $bar-width - $thumb-size;
121121
height: $thumb-size;
122122
width: $thumb-size;
123123
border-radius: 50%;
124+
display: block;
124125
}
125126

126127
// Horizontal bar for the slide-toggle.

0 commit comments

Comments
 (0)
Please sign in to comment.