MCPcopy Create free account
hub / github.com/angular/components / closestTableSection

Function closestTableSection

src/cdk/table/table.ts:1683–1700  ·  view source on GitHub ↗

* Finds the closest table section to an outlet. We can't use `HTMLElement.closest` for this, * because the node representing the outlet is a comment.

(outlet: RowOutlet, section: string)

Source from the content-addressed store, hash-verified

1681 * because the node representing the outlet is a comment.
1682 */
1683function closestTableSection(outlet: RowOutlet, section: string): HTMLElement | null {
1684 const uppercaseSection = section.toUpperCase();
1685 let current: Node | null = outlet.viewContainer.element.nativeElement;
1686
1687 while (current) {
1688 // 1 is an element node.
1689 const nodeName = current.nodeType === 1 ? (current as HTMLElement).nodeName : null;
1690 if (nodeName === uppercaseSection) {
1691 return current as HTMLElement;
1692 } else if (nodeName === 'TABLE') {
1693 // Stop traversing past the `table` node.
1694 break;
1695 }
1696 current = current.parentNode;
1697 }
1698
1699 return null;
1700}

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected