Skip to content

Commit 113256b

Browse files
committed
v4.3.19
1 parent 2927d1d commit 113256b

4 files changed

Lines changed: 22 additions & 21 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import {
2424
} from 'power-focusable';
2525

2626
// CDNs
27-
import { ... } 'https://esm.sh/power-focusable@4.3.18';
27+
import { ... } 'https://esm.sh/power-focusable@4.3.19';
2828
// or
29-
import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.18/+esm';
29+
import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.19/+esm';
3030
// or
31-
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.18';
31+
import { ... } 'https://esm.unpkg.com/power-focusable@4.3.19';
3232
```
3333
3434
## 🪄 Options

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "power-focusable",
3-
"version": "4.3.18",
3+
"version": "4.3.19",
44
"description": "High-precision focus management utility with full composed tree support",
55
"type": "module",
66
"main": "./dist/index.cjs",

src/index.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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

213214
export 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

429430
function isDisabledDeep(element: Element): boolean {

0 commit comments

Comments
 (0)