Skip to content

Commit a275dc1

Browse files
crisbetoandrewseguin
authored andcommitted
fix(tree): remove invalid aria attribute (#10935)
Currently we always add an `aria-level` to the tree nodes, however the attribute is only [valid when the node has a role of `treeitem`](https://www.w3.org/TR/wai-aria-1.1/#aria-level). This was being caught by aXe as well. With the following changes the `aria-level` will only be added if the node is a `treeitem`.
1 parent ad657bb commit a275dc1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/cdk/tree/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
exportAs: 'cdkTreeNode',
4747
host: {
4848
'[attr.aria-expanded]': 'isExpanded',
49-
'[attr.aria-level]': 'level',
49+
'[attr.aria-level]': 'role === "treeitem" ? level : null',
5050
'[attr.role]': 'role',
5151
'class': 'cdk-tree-node',
5252
},

src/lib/tree/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const _MatNestedTreeNodeMixinBase = mixinTabIndex(mixinDisabled(CdkNested
3737
inputs: ['disabled', 'tabIndex'],
3838
host: {
3939
'[attr.aria-expanded]': 'isExpanded',
40-
'[attr.aria-level]': 'level',
40+
'[attr.aria-level]': 'role === "treeitem" ? level : null',
4141
'[attr.role]': 'role',
4242
'class': 'mat-tree-node'
4343
},

0 commit comments

Comments
 (0)