@@ -314,7 +314,7 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy {
314
314
set data ( value : T ) {
315
315
if ( value !== this . _data ) {
316
316
this . _data = value ;
317
- this . _setRoleFromData ( ) ;
317
+ this . _setRole ( ) ;
318
318
this . _dataChanges . next ( ) ;
319
319
}
320
320
}
@@ -329,8 +329,7 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy {
329
329
}
330
330
331
331
/**
332
- * The role of the node should be 'group' if it's an internal node,
333
- * and 'treeitem' if it's a leaf node.
332
+ * The role of the node should always be 'treeitem'.
334
333
*/
335
334
@Input ( ) role : 'treeitem' | 'group' = 'treeitem' ;
336
335
@@ -356,24 +355,10 @@ export class CdkTreeNode<T> implements FocusableOption, OnDestroy {
356
355
this . _elementRef . nativeElement . focus ( ) ;
357
356
}
358
357
359
- protected _setRoleFromData ( ) : void {
360
- if ( this . _tree . treeControl . isExpandable ) {
361
- this . role = this . _tree . treeControl . isExpandable ( this . _data ) ? 'group' : 'treeitem' ;
362
- } else {
363
- if ( ! this . _tree . treeControl . getChildren ) {
364
- throw getTreeControlFunctionsMissingError ( ) ;
365
- }
366
- const childrenNodes = this . _tree . treeControl . getChildren ( this . _data ) ;
367
- if ( Array . isArray ( childrenNodes ) ) {
368
- this . _setRoleFromChildren ( childrenNodes as T [ ] ) ;
369
- } else if ( childrenNodes instanceof Observable ) {
370
- childrenNodes . pipe ( takeUntil ( this . _destroyed ) )
371
- . subscribe ( children => this . _setRoleFromChildren ( children ) ) ;
372
- }
358
+ protected _setRole ( ) : void {
359
+ if ( this . _tree . treeControl . isExpandable && ! this . _tree . treeControl . getChildren ) {
360
+ throw getTreeControlFunctionsMissingError ( ) ;
373
361
}
374
- }
375
-
376
- protected _setRoleFromChildren ( children : T [ ] ) {
377
- this . role = children && children . length ? 'group' : 'treeitem' ;
362
+ this . role = 'treeitem' ;
378
363
}
379
364
}
0 commit comments