@@ -337,8 +337,7 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy {
337
337
}
338
338
339
339
/**
340
- * The role of the node should be 'group' if it's an internal node,
341
- * and 'treeitem' if it's a leaf node.
340
+ * The role of the node should always be 'treeitem'.
342
341
*/
343
342
@Input ( ) role : 'treeitem' | 'group' = 'treeitem' ;
344
343
@@ -365,23 +364,19 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy {
365
364
}
366
365
367
366
protected _setRoleFromData ( ) : void {
368
- if ( this . _tree . treeControl . isExpandable ) {
369
- this . role = this . _tree . treeControl . isExpandable ( this . _data ) ? 'group' : 'treeitem' ;
370
- } else {
371
- if ( ! this . _tree . treeControl . getChildren ) {
372
- throw getTreeControlFunctionsMissingError ( ) ;
373
- }
374
- const childrenNodes = this . _tree . treeControl . getChildren ( this . _data ) ;
375
- if ( Array . isArray ( childrenNodes ) ) {
376
- this . _setRoleFromChildren ( childrenNodes as T [ ] ) ;
377
- } else if ( isObservable ( childrenNodes ) ) {
378
- childrenNodes . pipe ( takeUntil ( this . _destroyed ) )
379
- . subscribe ( children => this . _setRoleFromChildren ( children ) ) ;
380
- }
367
+ if ( this . _tree . treeControl . isExpandable && ! this . _tree . treeControl . getChildren ) {
368
+ throw getTreeControlFunctionsMissingError ( ) ;
369
+ }
370
+ const childrenNodes = this . _tree . treeControl . getChildren ( this . _data ) ;
371
+ if ( Array . isArray ( childrenNodes ) ) {
372
+ this . _setRoleFromChildren ( childrenNodes as T [ ] ) ;
373
+ } else if ( isObservable ( childrenNodes ) ) {
374
+ childrenNodes . pipe ( takeUntil ( this . _destroyed ) )
375
+ . subscribe ( children => this . _setRoleFromChildren ( children ) ) ;
381
376
}
382
377
}
383
378
384
379
protected _setRoleFromChildren ( children : T [ ] ) {
385
- this . role = children && children . length ? 'group' : 'treeitem' ;
380
+ this . role = 'treeitem' ;
386
381
}
387
382
}
0 commit comments