MCPcopy
hub / github.com/facebook/react / isDescendantOf

Method isDescendantOf

packages/react-devtools-shared/src/devtools/store.js:743–763  ·  view source on GitHub ↗
(parentId: number, descendantId: number)

Source from the content-addressed store, hash-verified

741 }
742
743 isDescendantOf(parentId: number, descendantId: number): boolean {
744 if (descendantId === 0) {
745 return false;
746 }
747
748 const descendant = this.getElementByID(descendantId);
749 if (descendant === null) {
750 return false;
751 }
752
753 if (descendant.parentID === parentId) {
754 return true;
755 }
756
757 const parent = this.getElementByID(parentId);
758 if (!parent || parent.depth >= descendant.depth) {
759 return false;
760 }
761
762 return this.isDescendantOf(parentId, descendant.parentID);
763 }
764
765 /**
766 * Returns index of the lowest descendant element, if available.

Callers 1

Element.jsFile · 0.80

Calls 1

getElementByIDMethod · 0.95

Tested by

no test coverage detected