(parentId: number, descendantId: number)
| 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. |
no test coverage detected