power-focusable 4.3.30 → 4.3.31

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/README.md CHANGED
@@ -24,11 +24,11 @@ import {
24
24
  } from 'power-focusable';
25
25
 
26
26
  // CDNs
27
- import { ... } 'https://esm.sh/power-focusable@4.3.30';
27
+ import { ... } 'https://esm.sh/power-focusable@4.3.31';
28
28
  // or
29
- import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.30/+esm';
29
+ import { ... } 'https://cdn.jsdelivr.net/npm/power-focusable@4.3.31/+esm';
30
30
  // or
31
- import { ... } 'https://esm.unpkg.com/power-focusable@4.3.30';
31
+ import { ... } 'https://esm.unpkg.com/power-focusable@4.3.31';
32
32
  ```
33
33
 
34
34
  ## 🪄 Options
package/dist/index.cjs CHANGED
@@ -78,21 +78,21 @@ function getFocusables(container = document.body, options = {}) {
78
78
  skipNegativeTabIndexCheck,
79
79
  skipVisibilityCheck
80
80
  }) || include?.(node)) {
81
- candidates[candidates.length] = node;
81
+ candidates.push(node);
82
82
  }
83
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
83
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
84
84
  };
85
- (composed ? getComposedChildren(container) : getChildren(container)).map(
85
+ (composed ? getComposedChildren(container) : [...container.children]).map(
86
86
  traverse2
87
87
  );
88
88
  } else {
89
- for (const match of container.querySelectorAll(
89
+ for (const m of container.querySelectorAll(
90
90
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
91
91
  )) {
92
- match && isFocusable(match, {
92
+ m && isFocusable(m, {
93
93
  skipNegativeTabIndexCheck,
94
94
  skipVisibilityCheck
95
- }) && candidates.push(match);
95
+ }) && candidates.push(m);
96
96
  }
97
97
  }
98
98
  return normalizeRadioGroup(
@@ -228,58 +228,58 @@ function isDisabledDeep(element) {
228
228
  }
229
229
  function normalizeRadioGroup(elements) {
230
230
  let map = null;
231
- for (const element of elements) {
232
- if (!(element instanceof HTMLInputElement)) {
231
+ for (const e of elements) {
232
+ if (!(e instanceof HTMLInputElement)) {
233
233
  continue;
234
234
  }
235
- if (!isUngroupedRadio(element)) {
235
+ if (!isUngroupedRadio(e)) {
236
236
  continue;
237
237
  }
238
238
  if (!map) {
239
239
  map = /* @__PURE__ */ new Map();
240
240
  }
241
- const root = element.getRootNode();
242
- let value = map.get(root);
243
- if (!value) {
244
- value = /* @__PURE__ */ new Map();
245
- map.set(root, value);
241
+ const root = e.getRootNode();
242
+ let groups = map.get(root);
243
+ if (!groups) {
244
+ groups = /* @__PURE__ */ new Map();
245
+ map.set(root, groups);
246
246
  }
247
- let v = value.get(element.form);
248
- if (!v) {
249
- v = /* @__PURE__ */ new Map();
250
- value.set(element.form, v);
247
+ let group = groups.get(e.form);
248
+ if (!group) {
249
+ group = /* @__PURE__ */ new Map();
250
+ groups.set(e.form, group);
251
251
  }
252
- let vv = v.get(element.name);
253
- if (!vv) {
254
- vv = [];
255
- v.set(element.name, vv);
252
+ let radios = group.get(e.name);
253
+ if (!radios) {
254
+ radios = [];
255
+ group.set(e.name, radios);
256
256
  }
257
- vv[vv.length] = element;
257
+ radios.push(e);
258
258
  }
259
259
  if (!map) {
260
260
  return elements;
261
261
  }
262
262
  const placeholder = /* @__PURE__ */ new Set();
263
- for (const value of map.values()) {
264
- for (const v of value.values()) {
265
- for (const vv of v.values()) {
266
- const radio = vv.find((element) => element.checked) ?? vv[0];
263
+ for (const v of map.values()) {
264
+ for (const w of v.values()) {
265
+ for (const x of w.values()) {
266
+ const radio = x.find((r) => r.checked) ?? x[0];
267
267
  radio && placeholder.add(radio);
268
268
  }
269
269
  }
270
270
  }
271
- return elements.filter((element) => {
272
- if (!(element instanceof HTMLInputElement)) {
271
+ return elements.filter((e) => {
272
+ if (!(e instanceof HTMLInputElement)) {
273
273
  return true;
274
274
  }
275
- return !isUngroupedRadio(element) || placeholder.has(element);
275
+ return !isUngroupedRadio(e) || placeholder.has(e);
276
276
  });
277
277
  }
278
278
  function sortByTabIndex(elements) {
279
279
  const ordered = [];
280
280
  const natural = [];
281
- for (const element of elements) {
282
- (getTabIndex(element) > 0 ? ordered : natural).push(element);
281
+ for (const e of elements) {
282
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
283
283
  }
284
284
  return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
285
285
  }
@@ -296,7 +296,7 @@ function containsComposed(container, element) {
296
296
  }
297
297
  function getComposedChildren(node) {
298
298
  if (node instanceof ShadowRoot) {
299
- return getChildren(node);
299
+ return [...node.children];
300
300
  }
301
301
  if (!(node instanceof Element)) {
302
302
  return [];
@@ -308,9 +308,9 @@ function getComposedChildren(node) {
308
308
  }
309
309
  }
310
310
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
311
- return getChildren(node.shadowRoot);
311
+ return [...node.shadowRoot.children];
312
312
  }
313
- return getChildren(node);
313
+ return [...node.children];
314
314
  }
315
315
  function getComposedParent(node) {
316
316
  if (node instanceof Element && node.assignedSlot) {
@@ -326,8 +326,8 @@ function getComposedSiblings(node) {
326
326
  return [];
327
327
  }
328
328
  const filtered = [];
329
- for (const sibling of (parent instanceof HTMLSlotElement ? parent.assignedElements({ flatten: true }) : getComposedChildren(parent)).filter((sibling2) => sibling2 !== node)) {
330
- filtered.push(sibling);
329
+ for (const s of (parent instanceof HTMLSlotElement ? parent.assignedElements({ flatten: true }) : getComposedChildren(parent)).filter((s2) => s2 !== node)) {
330
+ filtered.push(s);
331
331
  }
332
332
  return filtered;
333
333
  }
@@ -364,13 +364,6 @@ function getActiveElement() {
364
364
  }
365
365
  return current;
366
366
  }
367
- function getChildren(node) {
368
- const elements = [];
369
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
370
- elements[elements.length] = child;
371
- }
372
- return elements;
373
- }
374
367
  function getTabIndex(element) {
375
368
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
376
369
  }
@@ -447,7 +440,7 @@ function resolveOptions(options) {
447
440
  * High-precision focus management utility with full composed tree support.
448
441
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
449
442
  *
450
- * @version 4.3.30
443
+ * @version 4.3.31
451
444
  * @author Yusuke Kamiyamane
452
445
  * @license MIT
453
446
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with full composed tree support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
5
5
  *
6
- * @version 4.3.30
6
+ * @version 4.3.31
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 full composed tree support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
5
5
  *
6
- * @version 4.3.30
6
+ * @version 4.3.31
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -76,21 +76,21 @@ function getFocusables(container = document.body, options = {}) {
76
76
  skipNegativeTabIndexCheck,
77
77
  skipVisibilityCheck
78
78
  }) || include?.(node)) {
79
- candidates[candidates.length] = node;
79
+ candidates.push(node);
80
80
  }
81
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
81
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
82
82
  };
83
- (composed ? getComposedChildren(container) : getChildren(container)).map(
83
+ (composed ? getComposedChildren(container) : [...container.children]).map(
84
84
  traverse2
85
85
  );
86
86
  } else {
87
- for (const match of container.querySelectorAll(
87
+ for (const m of container.querySelectorAll(
88
88
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
89
89
  )) {
90
- match && isFocusable(match, {
90
+ m && isFocusable(m, {
91
91
  skipNegativeTabIndexCheck,
92
92
  skipVisibilityCheck
93
- }) && candidates.push(match);
93
+ }) && candidates.push(m);
94
94
  }
95
95
  }
96
96
  return normalizeRadioGroup(
@@ -226,58 +226,58 @@ function isDisabledDeep(element) {
226
226
  }
227
227
  function normalizeRadioGroup(elements) {
228
228
  let map = null;
229
- for (const element of elements) {
230
- if (!(element instanceof HTMLInputElement)) {
229
+ for (const e of elements) {
230
+ if (!(e instanceof HTMLInputElement)) {
231
231
  continue;
232
232
  }
233
- if (!isUngroupedRadio(element)) {
233
+ if (!isUngroupedRadio(e)) {
234
234
  continue;
235
235
  }
236
236
  if (!map) {
237
237
  map = /* @__PURE__ */ new Map();
238
238
  }
239
- const root = element.getRootNode();
240
- let value = map.get(root);
241
- if (!value) {
242
- value = /* @__PURE__ */ new Map();
243
- map.set(root, value);
239
+ const root = e.getRootNode();
240
+ let groups = map.get(root);
241
+ if (!groups) {
242
+ groups = /* @__PURE__ */ new Map();
243
+ map.set(root, groups);
244
244
  }
245
- let v = value.get(element.form);
246
- if (!v) {
247
- v = /* @__PURE__ */ new Map();
248
- value.set(element.form, v);
245
+ let group = groups.get(e.form);
246
+ if (!group) {
247
+ group = /* @__PURE__ */ new Map();
248
+ groups.set(e.form, group);
249
249
  }
250
- let vv = v.get(element.name);
251
- if (!vv) {
252
- vv = [];
253
- v.set(element.name, vv);
250
+ let radios = group.get(e.name);
251
+ if (!radios) {
252
+ radios = [];
253
+ group.set(e.name, radios);
254
254
  }
255
- vv[vv.length] = element;
255
+ radios.push(e);
256
256
  }
257
257
  if (!map) {
258
258
  return elements;
259
259
  }
260
260
  const placeholder = /* @__PURE__ */ new Set();
261
- for (const value of map.values()) {
262
- for (const v of value.values()) {
263
- for (const vv of v.values()) {
264
- const radio = vv.find((element) => element.checked) ?? vv[0];
261
+ for (const v of map.values()) {
262
+ for (const w of v.values()) {
263
+ for (const x of w.values()) {
264
+ const radio = x.find((r) => r.checked) ?? x[0];
265
265
  radio && placeholder.add(radio);
266
266
  }
267
267
  }
268
268
  }
269
- return elements.filter((element) => {
270
- if (!(element instanceof HTMLInputElement)) {
269
+ return elements.filter((e) => {
270
+ if (!(e instanceof HTMLInputElement)) {
271
271
  return true;
272
272
  }
273
- return !isUngroupedRadio(element) || placeholder.has(element);
273
+ return !isUngroupedRadio(e) || placeholder.has(e);
274
274
  });
275
275
  }
276
276
  function sortByTabIndex(elements) {
277
277
  const ordered = [];
278
278
  const natural = [];
279
- for (const element of elements) {
280
- (getTabIndex(element) > 0 ? ordered : natural).push(element);
279
+ for (const e of elements) {
280
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
281
281
  }
282
282
  return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
283
283
  }
@@ -294,7 +294,7 @@ function containsComposed(container, element) {
294
294
  }
295
295
  function getComposedChildren(node) {
296
296
  if (node instanceof ShadowRoot) {
297
- return getChildren(node);
297
+ return [...node.children];
298
298
  }
299
299
  if (!(node instanceof Element)) {
300
300
  return [];
@@ -306,9 +306,9 @@ function getComposedChildren(node) {
306
306
  }
307
307
  }
308
308
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
309
- return getChildren(node.shadowRoot);
309
+ return [...node.shadowRoot.children];
310
310
  }
311
- return getChildren(node);
311
+ return [...node.children];
312
312
  }
313
313
  function getComposedParent(node) {
314
314
  if (node instanceof Element && node.assignedSlot) {
@@ -324,8 +324,8 @@ function getComposedSiblings(node) {
324
324
  return [];
325
325
  }
326
326
  const filtered = [];
327
- for (const sibling of (parent instanceof HTMLSlotElement ? parent.assignedElements({ flatten: true }) : getComposedChildren(parent)).filter((sibling2) => sibling2 !== node)) {
328
- filtered.push(sibling);
327
+ for (const s of (parent instanceof HTMLSlotElement ? parent.assignedElements({ flatten: true }) : getComposedChildren(parent)).filter((s2) => s2 !== node)) {
328
+ filtered.push(s);
329
329
  }
330
330
  return filtered;
331
331
  }
@@ -362,13 +362,6 @@ function getActiveElement() {
362
362
  }
363
363
  return current;
364
364
  }
365
- function getChildren(node) {
366
- const elements = [];
367
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
368
- elements[elements.length] = child;
369
- }
370
- return elements;
371
- }
372
365
  function getTabIndex(element) {
373
366
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
374
367
  }
@@ -445,7 +438,7 @@ function resolveOptions(options) {
445
438
  * High-precision focus management utility with full composed tree support.
446
439
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
447
440
  *
448
- * @version 4.3.30
441
+ * @version 4.3.31
449
442
  * @author Yusuke Kamiyamane
450
443
  * @license MIT
451
444
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "4.3.30",
3
+ "version": "4.3.31",
4
4
  "description": "High-precision focus management utility with full composed tree support",
5
5
  "keywords": [
6
6
  "a11y",