MCPcopy Index your code
hub / github.com/adobe/react-spectrum / acceptNode

Function acceptNode

packages/react-aria/src/focus/FocusScope.tsx:852–886  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

850 // Create a TreeWalker, ensuring the root is an Element or Document
851 let walker = createShadowTreeWalker(doc, root || doc, NodeFilter.SHOW_ELEMENT, {
852 acceptNode(node) {
853 // Skip nodes inside the starting node.
854 if (nodeContains(opts?.from, node)) {
855 return NodeFilter.FILTER_REJECT;
856 }
857
858 if (
859 opts?.tabbable &&
860 (node as Element).tagName === 'INPUT' &&
861 (node as HTMLInputElement).getAttribute('type') === 'radio'
862 ) {
863 // If the radio is in a form, we can get all the other radios by name
864 if (!isTabbableRadio(node as HTMLInputElement)) {
865 return NodeFilter.FILTER_REJECT;
866 }
867 // If the radio is in the same group as the current node and none are selected, we can skip it
868 if (
869 (walker.currentNode as Element).tagName === 'INPUT' &&
870 (walker.currentNode as HTMLInputElement).type === 'radio' &&
871 (walker.currentNode as HTMLInputElement).name === (node as HTMLInputElement).name
872 ) {
873 return NodeFilter.FILTER_REJECT;
874 }
875 }
876
877 if (
878 filter(node as Element) &&
879 (!scope || isElementInScope(node as Element, scope)) &&
880 (!opts?.accept || opts.accept(node as Element))
881 ) {
882 return NodeFilter.FILTER_ACCEPT;
883 }
884
885 return NodeFilter.FILTER_SKIP;
886 }
887 });
888
889 if (opts?.from) {

Callers

nothing calls this directly

Calls 4

nodeContainsFunction · 0.90
isTabbableRadioFunction · 0.85
isElementInScopeFunction · 0.85
filterFunction · 0.50

Tested by

no test coverage detected