Skip to content

Commit 4d3beac

Browse files
committed
feat(material/radio,material/checkbox): Avoid nested divs in labels by changing to span instead.
1 parent d686290 commit 4d3beac

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/material/checkbox/checkbox.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<label [attr.for]="inputId" class="mat-checkbox-layout" #label>
2-
<div class="mat-checkbox-inner-container"
2+
<span class="mat-checkbox-inner-container"
33
[class.mat-checkbox-inner-container-no-side-margin]="!checkboxLabel.textContent || !checkboxLabel.textContent.trim()">
44
<input #input
55
class="mat-checkbox-input cdk-visually-hidden" type="checkbox"
@@ -16,16 +16,16 @@
1616
[attr.aria-describedby]="ariaDescribedby"
1717
(change)="_onInteractionEvent($event)"
1818
(click)="_onInputClick($event)">
19-
<div matRipple class="mat-checkbox-ripple mat-focus-indicator"
19+
<span matRipple class="mat-checkbox-ripple mat-focus-indicator"
2020
[matRippleTrigger]="label"
2121
[matRippleDisabled]="_isRippleDisabled()"
2222
[matRippleRadius]="20"
2323
[matRippleCentered]="true"
2424
[matRippleAnimation]="{enterDuration: 150}">
25-
<div class="mat-ripple-element mat-checkbox-persistent-ripple"></div>
26-
</div>
27-
<div class="mat-checkbox-frame"></div>
28-
<div class="mat-checkbox-background">
25+
<span class="mat-ripple-element mat-checkbox-persistent-ripple"></span>
26+
</span>
27+
<span class="mat-checkbox-frame"></span>
28+
<span class="mat-checkbox-background">
2929
<svg version="1.1"
3030
focusable="false"
3131
class="mat-checkbox-checkmark"
@@ -37,9 +37,9 @@
3737
d="M4.1,12.7 9,17.6 20.3,6.3"/>
3838
</svg>
3939
<!-- Element for rendering the indeterminate state checkbox. -->
40-
<div class="mat-checkbox-mixedmark"></div>
41-
</div>
42-
</div>
40+
<span class="mat-checkbox-mixedmark"></span>
41+
</span>
42+
</span>
4343
<span class="mat-checkbox-label" #checkboxLabel (cdkObserveContent)="_onLabelTextChange()">
4444
<!-- Add an invisible span so JAWS can read the label -->
4545
<span style="display:none">&nbsp;</span>

src/material/radio/radio.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->
33
<label [attr.for]="inputId" class="mat-radio-label" #label>
44
<!-- The actual 'radio' part of the control. -->
5-
<div class="mat-radio-container">
6-
<div class="mat-radio-outer-circle"></div>
7-
<div class="mat-radio-inner-circle"></div>
5+
<span class="mat-radio-container">
6+
<span class="mat-radio-outer-circle"></span>
7+
<span class="mat-radio-inner-circle"></span>
88
<input #input class="mat-radio-input cdk-visually-hidden" type="radio"
99
[id]="inputId"
1010
[checked]="checked"
@@ -21,21 +21,21 @@
2121

2222
<!-- The ripple comes after the input so that we can target it with a CSS
2323
sibling selector when the input is focused. -->
24-
<div mat-ripple class="mat-radio-ripple mat-focus-indicator"
24+
<span mat-ripple class="mat-radio-ripple mat-focus-indicator"
2525
[matRippleTrigger]="label"
2626
[matRippleDisabled]="_isRippleDisabled()"
2727
[matRippleCentered]="true"
2828
[matRippleRadius]="20"
2929
[matRippleAnimation]="{enterDuration: 150}">
3030

31-
<div class="mat-ripple-element mat-radio-persistent-ripple"></div>
32-
</div>
33-
</div>
31+
<span class="mat-ripple-element mat-radio-persistent-ripple"></span>
32+
</span>
33+
</span>
3434

3535
<!-- The label content for radio control. -->
36-
<div class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
36+
<span class="mat-radio-label-content" [class.mat-radio-label-before]="labelPosition == 'before'">
3737
<!-- Add an invisible span so JAWS can read the label -->
3838
<span style="display:none">&nbsp;</span>
3939
<ng-content></ng-content>
40-
</div>
40+
</span>
4141
</label>

0 commit comments

Comments
 (0)