power-focusable 2.1.11 → 2.1.12

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 CHANGED
@@ -24,14 +24,22 @@ function getFocusables(container = document.body, options = {}) {
24
24
  const assigneds = node.assignedElements({ flatten: true });
25
25
  if (assigneds.length) {
26
26
  for (let i = 0, l = assigneds.length; i < l; i++) {
27
- traverse2(assigneds[i]);
27
+ const assigned = assigneds[i];
28
+ if (!assigned) {
29
+ continue;
30
+ }
31
+ traverse2(assigned);
28
32
  }
29
33
  return;
30
34
  }
31
35
  }
32
36
  const children = node.childNodes;
33
37
  for (let i = 0, l = children.length; i < l; i++) {
34
- traverse2(children[i]);
38
+ const child = children[i];
39
+ if (!child) {
40
+ continue;
41
+ }
42
+ traverse2(child);
35
43
  }
36
44
  };
37
45
  traverse2(container);
@@ -39,6 +47,9 @@ function getFocusables(container = document.body, options = {}) {
39
47
  const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
40
48
  for (let i = 0, l = candidates.length; i < l; i++) {
41
49
  const candidate = candidates[i];
50
+ if (!(candidate instanceof HTMLElement)) {
51
+ continue;
52
+ }
42
53
  if (isFocusable(candidate)) {
43
54
  elements[elements.length] = candidate;
44
55
  }
@@ -107,6 +118,9 @@ function getRelativeFocusable(container, offset, options) {
107
118
  if (!active || !containsDeep(container, active)) {
108
119
  return null;
109
120
  }
121
+ if (!(active instanceof HTMLElement)) {
122
+ return null;
123
+ }
110
124
  const currentIndex = focusables.indexOf(active);
111
125
  if (currentIndex === -1) {
112
126
  return null;
@@ -177,6 +191,9 @@ function normalizeRadioGroup(elements) {
177
191
  let map = null;
178
192
  for (let i = 0, l = elements.length; i < l; i++) {
179
193
  const element = elements[i];
194
+ if (!(element instanceof HTMLInputElement)) {
195
+ continue;
196
+ }
180
197
  if (!isUngroupedRadio(element)) {
181
198
  continue;
182
199
  }
@@ -208,6 +225,9 @@ function sortByTabIndex(elements) {
208
225
  const natural = [];
209
226
  for (let i = 0, l = elements.length; i < l; i++) {
210
227
  const element = elements[i];
228
+ if (!element) {
229
+ continue;
230
+ }
211
231
  const target = element.tabIndex > 0 ? ordered : natural;
212
232
  target[target.length] = element;
213
233
  }
@@ -227,7 +247,7 @@ function sortByTabIndex(elements) {
227
247
  * High-precision focus management utility with shadow DOM support.
228
248
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
229
249
  *
230
- * @version 2.1.11
250
+ * @version 2.1.12
231
251
  * @author Yusuke Kamiyamane
232
252
  * @license MIT
233
253
  * @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.11
6
+ * @version 2.1.12
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.11
6
+ * @version 2.1.12
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -22,14 +22,22 @@ function getFocusables(container = document.body, options = {}) {
22
22
  const assigneds = node.assignedElements({ flatten: true });
23
23
  if (assigneds.length) {
24
24
  for (let i = 0, l = assigneds.length; i < l; i++) {
25
- traverse2(assigneds[i]);
25
+ const assigned = assigneds[i];
26
+ if (!assigned) {
27
+ continue;
28
+ }
29
+ traverse2(assigned);
26
30
  }
27
31
  return;
28
32
  }
29
33
  }
30
34
  const children = node.childNodes;
31
35
  for (let i = 0, l = children.length; i < l; i++) {
32
- traverse2(children[i]);
36
+ const child = children[i];
37
+ if (!child) {
38
+ continue;
39
+ }
40
+ traverse2(child);
33
41
  }
34
42
  };
35
43
  traverse2(container);
@@ -37,6 +45,9 @@ function getFocusables(container = document.body, options = {}) {
37
45
  const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
38
46
  for (let i = 0, l = candidates.length; i < l; i++) {
39
47
  const candidate = candidates[i];
48
+ if (!(candidate instanceof HTMLElement)) {
49
+ continue;
50
+ }
40
51
  if (isFocusable(candidate)) {
41
52
  elements[elements.length] = candidate;
42
53
  }
@@ -105,6 +116,9 @@ function getRelativeFocusable(container, offset, options) {
105
116
  if (!active || !containsDeep(container, active)) {
106
117
  return null;
107
118
  }
119
+ if (!(active instanceof HTMLElement)) {
120
+ return null;
121
+ }
108
122
  const currentIndex = focusables.indexOf(active);
109
123
  if (currentIndex === -1) {
110
124
  return null;
@@ -175,6 +189,9 @@ function normalizeRadioGroup(elements) {
175
189
  let map = null;
176
190
  for (let i = 0, l = elements.length; i < l; i++) {
177
191
  const element = elements[i];
192
+ if (!(element instanceof HTMLInputElement)) {
193
+ continue;
194
+ }
178
195
  if (!isUngroupedRadio(element)) {
179
196
  continue;
180
197
  }
@@ -206,6 +223,9 @@ function sortByTabIndex(elements) {
206
223
  const natural = [];
207
224
  for (let i = 0, l = elements.length; i < l; i++) {
208
225
  const element = elements[i];
226
+ if (!element) {
227
+ continue;
228
+ }
209
229
  const target = element.tabIndex > 0 ? ordered : natural;
210
230
  target[target.length] = element;
211
231
  }
@@ -225,7 +245,7 @@ function sortByTabIndex(elements) {
225
245
  * High-precision focus management utility with shadow DOM support.
226
246
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
227
247
  *
228
- * @version 2.1.11
248
+ * @version 2.1.12
229
249
  * @author Yusuke Kamiyamane
230
250
  * @license MIT
231
251
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "2.1.11",
3
+ "version": "2.1.12",
4
4
  "description": "High-precision focus management utility with shadow DOM support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",