MCPcopy
hub / github.com/microsoft/SandDance / getNextElement

Function getNextElement

docs/app/js/sanddance-app.js:24645–24661  ·  view source on GitHub ↗
(rootElement, currentElement, checkNode, suppressParentTraversal, suppressChildTraversal, includeElementsInFocusZones, allowFocusRoot, tabbable)

Source from the content-addressed store, hash-verified

24643 return null;
24644}
24645function getNextElement(rootElement, currentElement, checkNode, suppressParentTraversal, suppressChildTraversal, includeElementsInFocusZones, allowFocusRoot, tabbable) {
24646 if (!currentElement || currentElement === rootElement && suppressChildTraversal && !allowFocusRoot) return null;
24647 var isCurrentElementVisible = isElementVisible(currentElement);
24648 // Check the current node, if it's not the first traversal.
24649 if (checkNode && isCurrentElementVisible && isElementTabbable(currentElement, tabbable)) return currentElement;
24650 // Check its children.
24651 if (!suppressChildTraversal && isCurrentElementVisible && (includeElementsInFocusZones || !(isElementFocusZone(currentElement) || isElementFocusSubZone(currentElement)))) {
24652 var childMatch = getNextElement(rootElement, currentElement.firstElementChild, true, true, false, includeElementsInFocusZones, allowFocusRoot, tabbable);
24653 if (childMatch) return childMatch;
24654 }
24655 if (currentElement === rootElement) return null;
24656 // Check its sibling.
24657 var siblingMatch = getNextElement(rootElement, currentElement.nextElementSibling, true, true, false, includeElementsInFocusZones, allowFocusRoot, tabbable);
24658 if (siblingMatch) return siblingMatch;
24659 if (!suppressParentTraversal) return getNextElement(rootElement, currentElement.parentElement, false, false, true, includeElementsInFocusZones, allowFocusRoot, tabbable);
24660 return null;
24661}
24662function isElementVisible(element) {
24663 // If the element is not valid, return false.
24664 if (!element || !element.getAttribute) return false;

Callers 4

getFirstFocusableFunction · 0.85
getFirstTabbableFunction · 0.85
focusFirstChildFunction · 0.85
getFocusableByIndexPathFunction · 0.85

Calls 4

isElementVisibleFunction · 0.85
isElementTabbableFunction · 0.85
isElementFocusZoneFunction · 0.85
isElementFocusSubZoneFunction · 0.85

Tested by

no test coverage detected