MCPcopy
hub / github.com/reisxd/TizenTube / getSpatialNavigationCandidates

Function getSpatialNavigationCandidates

mods/spatial-navigation-polyfill.js:303–326  ·  view source on GitHub ↗

* Find the candidates within a spatial navigation container include delegable container. * This function does not search inside delegable container or focusable container. * In other words, this return candidates set is not included focusable elements inside delegable container or focusable co

(container, option = {mode: 'visible'})

Source from the content-addressed store, hash-verified

301 * @returns {sequence<Node>} candidate elements within the container
302 */
303 function getSpatialNavigationCandidates (container, option = {mode: 'visible'}) {
304 let candidates = [];
305
306 if (container.childElementCount > 0) {
307 if (!container.parentElement) {
308 container = container.getElementsByTagName('body')[0] || document.body;
309 }
310 const children = container.children;
311 for (const elem of children) {
312 if (isDelegableContainer(elem)) {
313 candidates.push(elem);
314 } else if (isFocusable(elem)) {
315 candidates.push(elem);
316
317 if (!isContainer(elem) && elem.childElementCount) {
318 candidates = candidates.concat(getSpatialNavigationCandidates(elem, {mode: 'all'}));
319 }
320 } else if (elem.childElementCount) {
321 candidates = candidates.concat(getSpatialNavigationCandidates(elem, {mode: 'all'}));
322 }
323 }
324 }
325 return (option.mode === 'all') ? candidates : candidates.filter(isVisible);
326 }
327
328 /**
329 * Find the candidates among focusable elements within a spatial navigation container from the search origin (currently focused element)

Callers 6

navigateFunction · 0.85
spatialNavigationSearchFunction · 0.85
navigateChainFunction · 0.85
findTargetFunction · 0.85
getExperimentalAPIFunction · 0.85

Calls 3

isDelegableContainerFunction · 0.85
isFocusableFunction · 0.85
isContainerFunction · 0.85

Tested by

no test coverage detected