MCPcopy Index your code
hub / github.com/angular/components / _getDescendants

Method _getDescendants

src/cdk/tree/tree.ts:904–926  ·  view source on GitHub ↗

Gets all nested descendants of a given node.

(dataNode: T)

Source from the content-addressed store, hash-verified

902
903 /** Gets all nested descendants of a given node. */
904 private _getDescendants(dataNode: T): Observable<T[]> {
905 if (this.treeControl) {
906 return observableOf(this.treeControl.getDescendants(dataNode));
907 }
908 if (this.levelAccessor) {
909 const results = this._findChildrenByLevel(
910 this.levelAccessor,
911 this._flattenedNodes.value,
912 dataNode,
913 Infinity,
914 );
915 return observableOf(results);
916 }
917 if (this.childrenAccessor) {
918 return this._getAllChildrenRecursively(dataNode).pipe(
919 reduce((allChildren: T[], nextChildren) => {
920 allChildren.push(...nextChildren);
921 return allChildren;
922 }, []),
923 );
924 }
925 throw getTreeControlMissingError();
926 }
927
928 /**
929 * Gets all children and sub-children of the provided node.

Callers 3

expandDescendantsMethod · 0.95
collapseDescendantsMethod · 0.95
_forEachExpansionKeyMethod · 0.95

Calls 5

_findChildrenByLevelMethod · 0.95
getDescendantsMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected