power-focusable 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -8
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -21,17 +21,23 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
if (node instanceof HTMLSlotElement) {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
for (let i = 0, l =
|
|
27
|
-
|
|
24
|
+
const assigneds = node.assignedElements({ flatten: true });
|
|
25
|
+
if (assigneds.length) {
|
|
26
|
+
for (let i = 0, l = assigneds.length; i < l; i++) {
|
|
27
|
+
const assigned = assigneds[i];
|
|
28
|
+
if (assigned) {
|
|
29
|
+
traverse2(assigned);
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
const children = node.childNodes;
|
|
33
36
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
34
|
-
|
|
37
|
+
const child = children[i];
|
|
38
|
+
if (child) {
|
|
39
|
+
traverse2(child);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
};
|
|
37
43
|
traverse2(container);
|
|
@@ -39,7 +45,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
39
45
|
const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
40
46
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
41
47
|
const candidate = candidates[i];
|
|
42
|
-
if (isFocusable(candidate)) {
|
|
48
|
+
if (candidate && isFocusable(candidate)) {
|
|
43
49
|
elements[elements.length] = candidate;
|
|
44
50
|
}
|
|
45
51
|
}
|
|
@@ -196,7 +202,9 @@ function normalizeRadioGroup(elements) {
|
|
|
196
202
|
}
|
|
197
203
|
const key = `${element.form?.id ?? "no-form"}::${element.name}`;
|
|
198
204
|
const group = map.get(key) ?? map.set(key, []).get(key);
|
|
199
|
-
group
|
|
205
|
+
if (group) {
|
|
206
|
+
group[group.length] = element;
|
|
207
|
+
}
|
|
200
208
|
}
|
|
201
209
|
if (!map) {
|
|
202
210
|
return elements;
|
|
@@ -236,7 +244,7 @@ function sortByTabIndex(elements) {
|
|
|
236
244
|
* High-precision focus management utility with shadow DOM support.
|
|
237
245
|
* Handles complex focus rules including tabindex ordering, radio groups, etc.
|
|
238
246
|
*
|
|
239
|
-
* @version 2.1.
|
|
247
|
+
* @version 2.1.8
|
|
240
248
|
* @author Yusuke Kamiyamane
|
|
241
249
|
* @license MIT
|
|
242
250
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-precision focus management utility with shadow DOM support.
|
|
4
4
|
* Handles complex focus rules including tabindex ordering, radio groups, etc.
|
|
5
5
|
*
|
|
6
|
-
* @version 2.1.
|
|
6
|
+
* @version 2.1.8
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* High-precision focus management utility with shadow DOM support.
|
|
4
4
|
* Handles complex focus rules including tabindex ordering, radio groups, etc.
|
|
5
5
|
*
|
|
6
|
-
* @version 2.1.
|
|
6
|
+
* @version 2.1.8
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -19,17 +19,23 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (node instanceof HTMLSlotElement) {
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
for (let i = 0, l =
|
|
25
|
-
|
|
22
|
+
const assigneds = node.assignedElements({ flatten: true });
|
|
23
|
+
if (assigneds.length) {
|
|
24
|
+
for (let i = 0, l = assigneds.length; i < l; i++) {
|
|
25
|
+
const assigned = assigneds[i];
|
|
26
|
+
if (assigned) {
|
|
27
|
+
traverse2(assigned);
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
const children = node.childNodes;
|
|
31
34
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
32
|
-
|
|
35
|
+
const child = children[i];
|
|
36
|
+
if (child) {
|
|
37
|
+
traverse2(child);
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
traverse2(container);
|
|
@@ -37,7 +43,7 @@ function getFocusables(container = document.body, options = {}) {
|
|
|
37
43
|
const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
38
44
|
for (let i = 0, l = candidates.length; i < l; i++) {
|
|
39
45
|
const candidate = candidates[i];
|
|
40
|
-
if (isFocusable(candidate)) {
|
|
46
|
+
if (candidate && isFocusable(candidate)) {
|
|
41
47
|
elements[elements.length] = candidate;
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -194,7 +200,9 @@ function normalizeRadioGroup(elements) {
|
|
|
194
200
|
}
|
|
195
201
|
const key = `${element.form?.id ?? "no-form"}::${element.name}`;
|
|
196
202
|
const group = map.get(key) ?? map.set(key, []).get(key);
|
|
197
|
-
group
|
|
203
|
+
if (group) {
|
|
204
|
+
group[group.length] = element;
|
|
205
|
+
}
|
|
198
206
|
}
|
|
199
207
|
if (!map) {
|
|
200
208
|
return elements;
|
|
@@ -234,7 +242,7 @@ function sortByTabIndex(elements) {
|
|
|
234
242
|
* High-precision focus management utility with shadow DOM support.
|
|
235
243
|
* Handles complex focus rules including tabindex ordering, radio groups, etc.
|
|
236
244
|
*
|
|
237
|
-
* @version 2.1.
|
|
245
|
+
* @version 2.1.8
|
|
238
246
|
* @author Yusuke Kamiyamane
|
|
239
247
|
* @license MIT
|
|
240
248
|
* @copyright Copyright (c) Yusuke Kamiyamane
|