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

Function getParentNodeAriaLevel

src/cdk/tree/tree.ts:1493–1510  ·  view source on GitHub ↗
(nodeElement: HTMLElement)

Source from the content-addressed store, hash-verified

1491}
1492
1493function getParentNodeAriaLevel(nodeElement: HTMLElement): number {
1494 let parent = nodeElement.parentElement;
1495 while (parent && !isNodeElement(parent)) {
1496 parent = parent.parentElement;
1497 }
1498 if (!parent) {
1499 if (typeof ngDevMode === 'undefined' || ngDevMode) {
1500 throw Error('Incorrect tree structure containing detached node.');
1501 } else {
1502 return -1;
1503 }
1504 } else if (parent.classList.contains('cdk-nested-tree-node')) {
1505 return numberAttribute(parent.getAttribute('aria-level')!);
1506 } else {
1507 // The ancestor element is the cdk-tree itself
1508 return 0;
1509 }
1510}
1511
1512function isNodeElement(element: HTMLElement) {
1513 const classList = element.classList;

Callers 1

ngOnInitMethod · 0.85

Calls 2

isNodeElementFunction · 0.85
getAttributeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…