33 * High-precision focus management utility with full composed tree support.
44 * Handles complex focus rules including tabindex ordering, radio groups, inert.
55 *
6- * @version 4.3.18
6+ * @version 4.3.19
77 * @author Yusuke Kamiyamane
88 * @license MIT
99 * @copyright Copyright (c) Yusuke Kamiyamane
@@ -154,7 +154,7 @@ export function getFocusables(
154154 skipVisibilityCheck = false ;
155155 }
156156
157- const elements : Element [ ] = [ ] ;
157+ const candidates : Element [ ] = [ ] ;
158158
159159 if ( composed || include ) {
160160 function traverse ( node : Element ) : void {
@@ -165,7 +165,7 @@ export function getFocusables(
165165 } ) ||
166166 include ?.( node )
167167 ) {
168- elements [ elements . length ] = node ;
168+ candidates [ candidates . length ] = node ;
169169 }
170170
171171 const children = composed ? getComposedChildren ( node ) : getChildren ( node ) ;
@@ -185,29 +185,30 @@ export function getFocusables(
185185 child && traverse ( child ) ;
186186 }
187187 } else {
188- const candidates = container . querySelectorAll (
188+ const matches = container . querySelectorAll (
189189 skipNegativeTabIndexCheck
190190 ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX
191191 : FOCUSABLE_SELECTOR ,
192192 ) ;
193193
194- for ( let i = 0 , l = candidates . length ; i < l ; i ++ ) {
195- const candidate = candidates [ i ] ;
194+ for ( let i = 0 , l = matches . length ; i < l ; i ++ ) {
195+ const matched = matches [ i ] ;
196196
197197 if (
198- candidate &&
199- isFocusable ( candidate , {
198+ matched &&
199+ isFocusable ( matched , {
200200 skipNegativeTabIndexCheck,
201201 skipVisibilityCheck,
202202 } )
203203 ) {
204- elements [ elements . length ] = candidate ;
204+ candidates [ candidates . length ] = matched ;
205205 }
206206 }
207207 }
208208
209- const filtered = filter ? elements . filter ( filter ) : elements ;
210- return normalizeRadioGroup ( sortByTabIndex ( filtered ) ) ;
209+ return normalizeRadioGroup (
210+ sortByTabIndex ( filter ? candidates . filter ( filter ) : candidates ) ,
211+ ) ;
211212}
212213
213214export function getNextFocusable (
@@ -404,14 +405,14 @@ function getRelativeFocusable(
404405 skipNegativeTabIndexCheck,
405406 skipVisibilityCheck,
406407 } ;
407- const candidates = getFocusables ( container , settings ) ;
408- const { length } = candidates ;
408+ const focusables = getFocusables ( container , settings ) ;
409+ const { length } = focusables ;
409410
410411 if ( ! length ) {
411412 return null ;
412413 }
413414
414- const anchorIndex = candidates . indexOf ( anchor ) ;
415+ const anchorIndex = focusables . indexOf ( anchor ) ;
415416
416417 if ( anchorIndex === - 1 ) {
417418 return null ;
@@ -423,7 +424,7 @@ function getRelativeFocusable(
423424 return null ;
424425 }
425426
426- return candidates [ ( offsetIndex + length ) % length ] ?? null ;
427+ return focusables [ ( offsetIndex + length ) % length ] ?? null ;
427428}
428429
429430function isDisabledDeep ( element : Element ) : boolean {
0 commit comments