power-focusable 2.1.7 → 2.1.9

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
@@ -21,23 +21,17 @@ function getFocusables(container = document.body, options = {}) {
21
21
  }
22
22
  }
23
23
  if (node instanceof HTMLSlotElement) {
24
- const assigned = node.assignedElements({ flatten: true });
25
- if (assigned.length) {
26
- for (let i = 0, l = assigned.length; i < l; i++) {
27
- const a = assigned[i];
28
- if (a) {
29
- traverse2(a);
30
- }
24
+ const assigneds = node.assignedElements({ flatten: true });
25
+ if (assigneds.length) {
26
+ for (let i = 0, l = assigneds.length; i < l; i++) {
27
+ traverse2(assigneds[i]);
31
28
  }
32
29
  return;
33
30
  }
34
31
  }
35
32
  const children = node.childNodes;
36
33
  for (let i = 0, l = children.length; i < l; i++) {
37
- const child = children[i];
38
- if (child) {
39
- traverse2(child);
40
- }
34
+ traverse2(children[i]);
41
35
  }
42
36
  };
43
37
  traverse2(container);
@@ -45,7 +39,7 @@ function getFocusables(container = document.body, options = {}) {
45
39
  const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
46
40
  for (let i = 0, l = candidates.length; i < l; i++) {
47
41
  const candidate = candidates[i];
48
- if (candidate && isFocusable(candidate)) {
42
+ if (isFocusable(candidate)) {
49
43
  elements[elements.length] = candidate;
50
44
  }
51
45
  }
@@ -114,9 +108,6 @@ function getRelativeFocusable(container, offset, options) {
114
108
  if (!active || !containsDeep(container, active)) {
115
109
  return null;
116
110
  }
117
- if (!(active instanceof HTMLElement)) {
118
- throw new Error("Unreachable");
119
- }
120
111
  const currentIndex = focusables.indexOf(active);
121
112
  if (currentIndex === -1) {
122
113
  return null;
@@ -197,7 +188,7 @@ function normalizeRadioGroup(elements) {
197
188
  let map = null;
198
189
  for (let i = 0, l = elements.length; i < l; i++) {
199
190
  const element = elements[i];
200
- if (!(element instanceof HTMLInputElement) || !isUngroupedRadio(element)) {
191
+ if (!isUngroupedRadio(element)) {
201
192
  continue;
202
193
  }
203
194
  if (!map) {
@@ -228,9 +219,6 @@ function sortByTabIndex(elements) {
228
219
  const natural = [];
229
220
  for (let i = 0, l = elements.length; i < l; i++) {
230
221
  const element = elements[i];
231
- if (!element) {
232
- throw new Error("Unreachable");
233
- }
234
222
  const target = getTabIndex(element) > 0 ? ordered : natural;
235
223
  target[target.length] = element;
236
224
  }
@@ -250,7 +238,7 @@ function sortByTabIndex(elements) {
250
238
  * High-precision focus management utility with shadow DOM support.
251
239
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
252
240
  *
253
- * @version 2.1.7
241
+ * @version 2.1.9
254
242
  * @author Yusuke Kamiyamane
255
243
  * @license MIT
256
244
  * @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.7
6
+ * @version 2.1.9
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.7
6
+ * @version 2.1.9
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -19,23 +19,17 @@ function getFocusables(container = document.body, options = {}) {
19
19
  }
20
20
  }
21
21
  if (node instanceof HTMLSlotElement) {
22
- const assigned = node.assignedElements({ flatten: true });
23
- if (assigned.length) {
24
- for (let i = 0, l = assigned.length; i < l; i++) {
25
- const a = assigned[i];
26
- if (a) {
27
- traverse2(a);
28
- }
22
+ const assigneds = node.assignedElements({ flatten: true });
23
+ if (assigneds.length) {
24
+ for (let i = 0, l = assigneds.length; i < l; i++) {
25
+ traverse2(assigneds[i]);
29
26
  }
30
27
  return;
31
28
  }
32
29
  }
33
30
  const children = node.childNodes;
34
31
  for (let i = 0, l = children.length; i < l; i++) {
35
- const child = children[i];
36
- if (child) {
37
- traverse2(child);
38
- }
32
+ traverse2(children[i]);
39
33
  }
40
34
  };
41
35
  traverse2(container);
@@ -43,7 +37,7 @@ function getFocusables(container = document.body, options = {}) {
43
37
  const candidates = container.querySelectorAll(FOCUSABLE_SELECTOR);
44
38
  for (let i = 0, l = candidates.length; i < l; i++) {
45
39
  const candidate = candidates[i];
46
- if (candidate && isFocusable(candidate)) {
40
+ if (isFocusable(candidate)) {
47
41
  elements[elements.length] = candidate;
48
42
  }
49
43
  }
@@ -112,9 +106,6 @@ function getRelativeFocusable(container, offset, options) {
112
106
  if (!active || !containsDeep(container, active)) {
113
107
  return null;
114
108
  }
115
- if (!(active instanceof HTMLElement)) {
116
- throw new Error("Unreachable");
117
- }
118
109
  const currentIndex = focusables.indexOf(active);
119
110
  if (currentIndex === -1) {
120
111
  return null;
@@ -195,7 +186,7 @@ function normalizeRadioGroup(elements) {
195
186
  let map = null;
196
187
  for (let i = 0, l = elements.length; i < l; i++) {
197
188
  const element = elements[i];
198
- if (!(element instanceof HTMLInputElement) || !isUngroupedRadio(element)) {
189
+ if (!isUngroupedRadio(element)) {
199
190
  continue;
200
191
  }
201
192
  if (!map) {
@@ -226,9 +217,6 @@ function sortByTabIndex(elements) {
226
217
  const natural = [];
227
218
  for (let i = 0, l = elements.length; i < l; i++) {
228
219
  const element = elements[i];
229
- if (!element) {
230
- throw new Error("Unreachable");
231
- }
232
220
  const target = getTabIndex(element) > 0 ? ordered : natural;
233
221
  target[target.length] = element;
234
222
  }
@@ -248,7 +236,7 @@ function sortByTabIndex(elements) {
248
236
  * High-precision focus management utility with shadow DOM support.
249
237
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
250
238
  *
251
- * @version 2.1.7
239
+ * @version 2.1.9
252
240
  * @author Yusuke Kamiyamane
253
241
  * @license MIT
254
242
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "High-precision focus management utility with shadow DOM support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",