@y14e/roving-tabindex 3.1.3 → 3.1.5

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
@@ -13,11 +13,11 @@ npm i @y14e/roving-tabindex
13
13
  import { createRovingTabIndex } from '@y14e/roving-tabindex';
14
14
 
15
15
  // CDNs
16
- import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.3';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.5';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.3/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.5/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.3';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.5';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -377,22 +377,17 @@ var RovingTabIndex = class _RovingTabIndex {
377
377
  }
378
378
  this.#controller = new AbortController();
379
379
  const { signal } = this.#controller;
380
- document.addEventListener("focusin", this.#onFocusIn, { signal });
381
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
380
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
381
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
382
382
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
383
383
  }
384
384
  #onFocusIn = (event) => {
385
385
  const { target } = event;
386
- if (!(target instanceof Element)) {
387
- return;
388
- }
389
- const isFocusable2 = this.#focusables.has(target);
390
- this.#settings.noMemory && !isFocusable2 ? this.#update() : isFocusable2 && this.#update(target);
386
+ target instanceof Element && this.#update(target);
391
387
  };
392
388
  #onFocusOut = (event) => {
393
- if (!event.relatedTarget) {
394
- this.#update();
395
- }
389
+ const target = event.relatedTarget;
390
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
396
391
  };
397
392
  #onKeyDown = (event) => {
398
393
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -413,7 +408,7 @@ var RovingTabIndex = class _RovingTabIndex {
413
408
  }
414
409
  }
415
410
  const active = getActiveElement();
416
- if (!(active instanceof HTMLElement)) {
411
+ if (!(active instanceof Element)) {
417
412
  return;
418
413
  }
419
414
  const current = this.#getFocusables();
@@ -531,7 +526,7 @@ var RovingTabIndex = class _RovingTabIndex {
531
526
  * Lightweight roving tabindex utility with fully focus management.
532
527
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
533
528
  *
534
- * @version 3.1.3
529
+ * @version 3.1.5
535
530
  * @author Yusuke Kamiyamane
536
531
  * @license MIT
537
532
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -556,7 +551,7 @@ power-focusable/dist/index.js:
556
551
  * High-precision focus management utility with full composed tree support.
557
552
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
558
553
  *
559
- * @version 4.3.3
554
+ * @version 4.3.6
560
555
  * @author Yusuke Kamiyamane
561
556
  * @license MIT
562
557
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -375,22 +375,17 @@ var RovingTabIndex = class _RovingTabIndex {
375
375
  }
376
376
  this.#controller = new AbortController();
377
377
  const { signal } = this.#controller;
378
- document.addEventListener("focusin", this.#onFocusIn, { signal });
379
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
378
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
379
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
380
380
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
381
381
  }
382
382
  #onFocusIn = (event) => {
383
383
  const { target } = event;
384
- if (!(target instanceof Element)) {
385
- return;
386
- }
387
- const isFocusable2 = this.#focusables.has(target);
388
- this.#settings.noMemory && !isFocusable2 ? this.#update() : isFocusable2 && this.#update(target);
384
+ target instanceof Element && this.#update(target);
389
385
  };
390
386
  #onFocusOut = (event) => {
391
- if (!event.relatedTarget) {
392
- this.#update();
393
- }
387
+ const target = event.relatedTarget;
388
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
394
389
  };
395
390
  #onKeyDown = (event) => {
396
391
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -411,7 +406,7 @@ var RovingTabIndex = class _RovingTabIndex {
411
406
  }
412
407
  }
413
408
  const active = getActiveElement();
414
- if (!(active instanceof HTMLElement)) {
409
+ if (!(active instanceof Element)) {
415
410
  return;
416
411
  }
417
412
  const current = this.#getFocusables();
@@ -529,7 +524,7 @@ var RovingTabIndex = class _RovingTabIndex {
529
524
  * Lightweight roving tabindex utility with fully focus management.
530
525
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
531
526
  *
532
- * @version 3.1.3
527
+ * @version 3.1.5
533
528
  * @author Yusuke Kamiyamane
534
529
  * @license MIT
535
530
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -554,7 +549,7 @@ power-focusable/dist/index.js:
554
549
  * High-precision focus management utility with full composed tree support.
555
550
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
556
551
  *
557
- * @version 4.3.3
552
+ * @version 4.3.6
558
553
  * @author Yusuke Kamiyamane
559
554
  * @license MIT
560
555
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -93,22 +93,17 @@ var RovingTabIndex = class _RovingTabIndex {
93
93
  }
94
94
  this.#controller = new AbortController();
95
95
  const { signal } = this.#controller;
96
- document.addEventListener("focusin", this.#onFocusIn, { signal });
97
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
96
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
97
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
98
98
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
99
99
  }
100
100
  #onFocusIn = (event) => {
101
101
  const { target } = event;
102
- if (!(target instanceof Element)) {
103
- return;
104
- }
105
- const isFocusable = this.#focusables.has(target);
106
- this.#settings.noMemory && !isFocusable ? this.#update() : isFocusable && this.#update(target);
102
+ target instanceof Element && this.#update(target);
107
103
  };
108
104
  #onFocusOut = (event) => {
109
- if (!event.relatedTarget) {
110
- this.#update();
111
- }
105
+ const target = event.relatedTarget;
106
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
112
107
  };
113
108
  #onKeyDown = (event) => {
114
109
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -129,7 +124,7 @@ var RovingTabIndex = class _RovingTabIndex {
129
124
  }
130
125
  }
131
126
  const active = powerFocusable.getActiveElement();
132
- if (!(active instanceof HTMLElement)) {
127
+ if (!(active instanceof Element)) {
133
128
  return;
134
129
  }
135
130
  const current = this.#getFocusables();
@@ -247,7 +242,7 @@ var RovingTabIndex = class _RovingTabIndex {
247
242
  * Lightweight roving tabindex utility with fully focus management.
248
243
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
249
244
  *
250
- * @version 3.1.3
245
+ * @version 3.1.5
251
246
  * @author Yusuke Kamiyamane
252
247
  * @license MIT
253
248
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight roving tabindex utility with fully focus management.
4
4
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
5
5
  *
6
- * @version 3.1.3
6
+ * @version 3.1.5
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
  * Lightweight roving tabindex utility with fully focus management.
4
4
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
5
5
  *
6
- * @version 3.1.3
6
+ * @version 3.1.5
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -91,22 +91,17 @@ var RovingTabIndex = class _RovingTabIndex {
91
91
  }
92
92
  this.#controller = new AbortController();
93
93
  const { signal } = this.#controller;
94
- document.addEventListener("focusin", this.#onFocusIn, { signal });
95
- this.#settings.noMemory && document.addEventListener("focusout", this.#onFocusOut, { signal });
94
+ this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
95
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
96
96
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
97
97
  }
98
98
  #onFocusIn = (event) => {
99
99
  const { target } = event;
100
- if (!(target instanceof Element)) {
101
- return;
102
- }
103
- const isFocusable = this.#focusables.has(target);
104
- this.#settings.noMemory && !isFocusable ? this.#update() : isFocusable && this.#update(target);
100
+ target instanceof Element && this.#update(target);
105
101
  };
106
102
  #onFocusOut = (event) => {
107
- if (!event.relatedTarget) {
108
- this.#update();
109
- }
103
+ const target = event.relatedTarget;
104
+ (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
110
105
  };
111
106
  #onKeyDown = (event) => {
112
107
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
@@ -127,7 +122,7 @@ var RovingTabIndex = class _RovingTabIndex {
127
122
  }
128
123
  }
129
124
  const active = getActiveElement();
130
- if (!(active instanceof HTMLElement)) {
125
+ if (!(active instanceof Element)) {
131
126
  return;
132
127
  }
133
128
  const current = this.#getFocusables();
@@ -245,7 +240,7 @@ var RovingTabIndex = class _RovingTabIndex {
245
240
  * Lightweight roving tabindex utility with fully focus management.
246
241
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
247
242
  *
248
- * @version 3.1.3
243
+ * @version 3.1.5
249
244
  * @author Yusuke Kamiyamane
250
245
  * @license MIT
251
246
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/roving-tabindex",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -57,6 +57,6 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@y14e/attributes-utils": "^1.1.2",
60
- "power-focusable": "^4.3.4"
60
+ "power-focusable": "^4.3.6"
61
61
  }
62
62
  }