* Gets the direct children of a node; used for compatibility between the old tree and the * new tree.
(dataNode: T)
| 742 | * new tree. |
| 743 | */ |
| 744 | _getDirectChildren(dataNode: T): Observable<T[]> { |
| 745 | const levelAccessor = this._getLevelAccessor(); |
| 746 | const expansionModel = this._expansionModel ?? this.treeControl?.expansionModel; |
| 747 | if (!expansionModel) { |
| 748 | return observableOf([]); |
| 749 | } |
| 750 | |
| 751 | const key = this._getExpansionKey(dataNode); |
| 752 | |
| 753 | const isExpanded = expansionModel.changed.pipe( |
| 754 | switchMap(changes => { |
| 755 | if (changes.added.includes(key)) { |
| 756 | return observableOf(true); |
| 757 | } else if (changes.removed.includes(key)) { |
| 758 | return observableOf(false); |
| 759 | } |
| 760 | return EMPTY; |
| 761 | }), |
| 762 | startWith(this.isExpanded(dataNode)), |
| 763 | ); |
| 764 | |
| 765 | if (levelAccessor) { |
| 766 | return combineLatest([isExpanded, this._flattenedNodes]).pipe( |
| 767 | map(([expanded, flattenedNodes]) => { |
| 768 | if (!expanded) { |
| 769 | return []; |
| 770 | } |
| 771 | return this._findChildrenByLevel(levelAccessor, flattenedNodes, dataNode, 1); |
| 772 | }), |
| 773 | ); |
| 774 | } |
| 775 | const childrenAccessor = this._getChildrenAccessor(); |
| 776 | if (childrenAccessor) { |
| 777 | return coerceObservable(childrenAccessor(dataNode) ?? []); |
| 778 | } |
| 779 | throw getTreeControlMissingError(); |
| 780 | } |
| 781 | |
| 782 | /** |
| 783 | * Given the list of flattened nodes, the level accessor, and the level range within |
no test coverage detected