* Get the list of the experimental APIs * @function getExperimentalAPI
()
| 1595 | * @function getExperimentalAPI |
| 1596 | */ |
| 1597 | function getExperimentalAPI() { |
| 1598 | function canScroll(container, dir) { |
| 1599 | return (isScrollable(container, dir) && !isScrollBoundary(container, dir)) || |
| 1600 | (!container.parentElement && !isHTMLScrollBoundary(container, dir)); |
| 1601 | } |
| 1602 | |
| 1603 | function findTarget(findCandidate, element, dir, option) { |
| 1604 | let eventTarget = element; |
| 1605 | let bestNextTarget = null; |
| 1606 | |
| 1607 | // 4 |
| 1608 | if (eventTarget === document || eventTarget === document.documentElement) { |
| 1609 | eventTarget = document.body || document.documentElement; |
| 1610 | } |
| 1611 | |
| 1612 | // 5 |
| 1613 | // At this point, spatialNavigationSearch can be applied. |
| 1614 | // If startingPoint is either a scroll container or the document, |
| 1615 | // find the best candidate within startingPoint |
| 1616 | if ((isContainer(eventTarget) || eventTarget.nodeName === 'BODY') && !(eventTarget.nodeName === 'INPUT')) { |
| 1617 | if (eventTarget.nodeName === 'IFRAME') |
| 1618 | eventTarget = eventTarget.contentDocument.body; |
| 1619 | |
| 1620 | const candidates = getSpatialNavigationCandidates(eventTarget, option); |
| 1621 | |
| 1622 | // 5-2 |
| 1623 | if (Array.isArray(candidates) && candidates.length > 0) { |
| 1624 | return findCandidate ? getFilteredSpatialNavigationCandidates(eventTarget, dir, candidates) : eventTarget.spatialNavigationSearch(dir, {candidates}); |
| 1625 | } |
| 1626 | if (canScroll(eventTarget, dir)) { |
| 1627 | return findCandidate ? [] : eventTarget; |
| 1628 | } |
| 1629 | } |
| 1630 | |
| 1631 | // 6 |
| 1632 | // Let container be the nearest ancestor of eventTarget |
| 1633 | let container = eventTarget.getSpatialNavigationContainer(); |
| 1634 | let parentContainer = (container.parentElement) ? container.getSpatialNavigationContainer() : null; |
| 1635 | |
| 1636 | // When the container is the viewport of a browsing context |
| 1637 | if (!parentContainer && ( window.location !== window.parent.location)) { |
| 1638 | parentContainer = window.parent.document.documentElement; |
| 1639 | } |
| 1640 | |
| 1641 | // 7 |
| 1642 | while (parentContainer) { |
| 1643 | const candidates = filteredCandidates(eventTarget, getSpatialNavigationCandidates(container, option), dir, container); |
| 1644 | |
| 1645 | if (Array.isArray(candidates) && candidates.length > 0) { |
| 1646 | bestNextTarget = eventTarget.spatialNavigationSearch(dir, {candidates, container}); |
| 1647 | if (bestNextTarget) { |
| 1648 | return findCandidate ? candidates : bestNextTarget; |
| 1649 | } |
| 1650 | } |
| 1651 | |
| 1652 | // If there isn't any candidate and the best candidate among candidate: |
| 1653 | // 1) Scroll or 2) Find candidates of the ancestor container |
| 1654 | // 8 - if |
no test coverage detected