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

Function closestTableSection

src/cdk/table/table.ts:1665–1682  ·  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

1663 * because the node representing the outlet is a comment.
1664 */
1665function closestTableSection(outlet: RowOutlet, section: string): HTMLElement | null {
1666 const uppercaseSection = section.toUpperCase();
1667 let current: Node | null = outlet.viewContainer.element.nativeElement;
1668
1669 while (current) {
1670 // 1 is an element node.
1671 const nodeName = current.nodeType === 1 ? (current as HTMLElement).nodeName : null;
1672 if (nodeName === uppercaseSection) {
1673 return current as HTMLElement;
1674 } else if (nodeName === 'TABLE') {
1675 // Stop traversing past the `table` node.
1676 break;
1677 }
1678 current = current.parentNode;
1679 }
1680
1681 return null;
1682}

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected