@y14e/roving-tabindex 3.1.5 → 3.1.7

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.5';
16
+ import { createRovingTabIndex } from 'https://esm.sh/@y14e/roving-tabindex@3.1.7';
17
17
  // or
18
- import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.5/+esm';
18
+ import { createRovingTabIndex } from 'https://cdn.jsdelivr.net/npm/@y14e/roving-tabindex@3.1.7/+esm';
19
19
  // or
20
- import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.5';
20
+ import { createRovingTabIndex } from 'https://esm.unpkg.com/@y14e/roving-tabindex@3.1.7';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -4,12 +4,12 @@
4
4
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
5
5
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
6
6
  function addTokenToAttribute(element, attribute, token, options = {}) {
7
+ const value = element.getAttribute(attribute)?.trim();
7
8
  const {
8
9
  caseInsensitive = false,
9
10
  parse = DEFAULT_PARSER,
10
11
  serialize = DEFAULT_SERIALIZER
11
12
  } = options;
12
- const value = element.getAttribute(attribute)?.trim();
13
13
  const tokens = value ? parse(value).filter(Boolean) : [];
14
14
  if (caseInsensitive) {
15
15
  const lower = token.toLowerCase();
@@ -372,24 +372,32 @@ var RovingTabIndex = class _RovingTabIndex {
372
372
  }
373
373
  #initialize() {
374
374
  this.#update(getActiveElement());
375
- if (!(this.#container instanceof HTMLElement)) {
376
- return;
377
- }
378
375
  this.#controller = new AbortController();
379
376
  const { signal } = this.#controller;
380
377
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
381
- this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
378
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, {
379
+ signal
380
+ });
382
381
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
383
382
  }
384
383
  #onFocusIn = (event) => {
384
+ if (!(event instanceof FocusEvent)) {
385
+ return;
386
+ }
385
387
  const { target } = event;
386
388
  target instanceof Element && this.#update(target);
387
389
  };
388
390
  #onFocusOut = (event) => {
391
+ if (!(event instanceof FocusEvent)) {
392
+ return;
393
+ }
389
394
  const target = event.relatedTarget;
390
395
  (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
391
396
  };
392
397
  #onKeyDown = (event) => {
398
+ if (!(event instanceof KeyboardEvent)) {
399
+ return;
400
+ }
393
401
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
394
402
  if (altKey || ctrlKey || metaKey || shiftKey) {
395
403
  return;
@@ -526,7 +534,7 @@ var RovingTabIndex = class _RovingTabIndex {
526
534
  * Lightweight roving tabindex utility with fully focus management.
527
535
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
528
536
  *
529
- * @version 3.1.5
537
+ * @version 3.1.7
530
538
  * @author Yusuke Kamiyamane
531
539
  * @license MIT
532
540
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -538,7 +546,7 @@ var RovingTabIndex = class _RovingTabIndex {
538
546
  (**
539
547
  * Attributes Utils
540
548
  *
541
- * @version 1.1.2
549
+ * @version 1.1.3
542
550
  * @author Yusuke Kamiyamane
543
551
  * @license MIT
544
552
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -551,7 +559,7 @@ power-focusable/dist/index.js:
551
559
  * High-precision focus management utility with full composed tree support.
552
560
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
553
561
  *
554
- * @version 4.3.6
562
+ * @version 4.3.8
555
563
  * @author Yusuke Kamiyamane
556
564
  * @license MIT
557
565
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -2,12 +2,12 @@
2
2
  var DEFAULT_PARSER = (value) => value.split(/\s+/);
3
3
  var DEFAULT_SERIALIZER = (tokens) => tokens.join(" ");
4
4
  function addTokenToAttribute(element, attribute, token, options = {}) {
5
+ const value = element.getAttribute(attribute)?.trim();
5
6
  const {
6
7
  caseInsensitive = false,
7
8
  parse = DEFAULT_PARSER,
8
9
  serialize = DEFAULT_SERIALIZER
9
10
  } = options;
10
- const value = element.getAttribute(attribute)?.trim();
11
11
  const tokens = value ? parse(value).filter(Boolean) : [];
12
12
  if (caseInsensitive) {
13
13
  const lower = token.toLowerCase();
@@ -370,24 +370,32 @@ var RovingTabIndex = class _RovingTabIndex {
370
370
  }
371
371
  #initialize() {
372
372
  this.#update(getActiveElement());
373
- if (!(this.#container instanceof HTMLElement)) {
374
- return;
375
- }
376
373
  this.#controller = new AbortController();
377
374
  const { signal } = this.#controller;
378
375
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
379
- this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
376
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, {
377
+ signal
378
+ });
380
379
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
381
380
  }
382
381
  #onFocusIn = (event) => {
382
+ if (!(event instanceof FocusEvent)) {
383
+ return;
384
+ }
383
385
  const { target } = event;
384
386
  target instanceof Element && this.#update(target);
385
387
  };
386
388
  #onFocusOut = (event) => {
389
+ if (!(event instanceof FocusEvent)) {
390
+ return;
391
+ }
387
392
  const target = event.relatedTarget;
388
393
  (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
389
394
  };
390
395
  #onKeyDown = (event) => {
396
+ if (!(event instanceof KeyboardEvent)) {
397
+ return;
398
+ }
391
399
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
392
400
  if (altKey || ctrlKey || metaKey || shiftKey) {
393
401
  return;
@@ -524,7 +532,7 @@ var RovingTabIndex = class _RovingTabIndex {
524
532
  * Lightweight roving tabindex utility with fully focus management.
525
533
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
526
534
  *
527
- * @version 3.1.5
535
+ * @version 3.1.7
528
536
  * @author Yusuke Kamiyamane
529
537
  * @license MIT
530
538
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -536,7 +544,7 @@ var RovingTabIndex = class _RovingTabIndex {
536
544
  (**
537
545
  * Attributes Utils
538
546
  *
539
- * @version 1.1.2
547
+ * @version 1.1.3
540
548
  * @author Yusuke Kamiyamane
541
549
  * @license MIT
542
550
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -549,7 +557,7 @@ power-focusable/dist/index.js:
549
557
  * High-precision focus management utility with full composed tree support.
550
558
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
551
559
  *
552
- * @version 4.3.6
560
+ * @version 4.3.8
553
561
  * @author Yusuke Kamiyamane
554
562
  * @license MIT
555
563
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -88,24 +88,32 @@ var RovingTabIndex = class _RovingTabIndex {
88
88
  }
89
89
  #initialize() {
90
90
  this.#update(powerFocusable.getActiveElement());
91
- if (!(this.#container instanceof HTMLElement)) {
92
- return;
93
- }
94
91
  this.#controller = new AbortController();
95
92
  const { signal } = this.#controller;
96
93
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
97
- this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
94
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, {
95
+ signal
96
+ });
98
97
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
99
98
  }
100
99
  #onFocusIn = (event) => {
100
+ if (!(event instanceof FocusEvent)) {
101
+ return;
102
+ }
101
103
  const { target } = event;
102
104
  target instanceof Element && this.#update(target);
103
105
  };
104
106
  #onFocusOut = (event) => {
107
+ if (!(event instanceof FocusEvent)) {
108
+ return;
109
+ }
105
110
  const target = event.relatedTarget;
106
111
  (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
107
112
  };
108
113
  #onKeyDown = (event) => {
114
+ if (!(event instanceof KeyboardEvent)) {
115
+ return;
116
+ }
109
117
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
110
118
  if (altKey || ctrlKey || metaKey || shiftKey) {
111
119
  return;
@@ -242,7 +250,7 @@ var RovingTabIndex = class _RovingTabIndex {
242
250
  * Lightweight roving tabindex utility with fully focus management.
243
251
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
244
252
  *
245
- * @version 3.1.5
253
+ * @version 3.1.7
246
254
  * @author Yusuke Kamiyamane
247
255
  * @license MIT
248
256
  * @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.5
6
+ * @version 3.1.7
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.5
6
+ * @version 3.1.7
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -86,24 +86,32 @@ var RovingTabIndex = class _RovingTabIndex {
86
86
  }
87
87
  #initialize() {
88
88
  this.#update(getActiveElement());
89
- if (!(this.#container instanceof HTMLElement)) {
90
- return;
91
- }
92
89
  this.#controller = new AbortController();
93
90
  const { signal } = this.#controller;
94
91
  this.#container.addEventListener("focusin", this.#onFocusIn, { signal });
95
- this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, { signal });
92
+ this.#settings.noMemory && this.#container.addEventListener("focusout", this.#onFocusOut, {
93
+ signal
94
+ });
96
95
  this.#container.addEventListener("keydown", this.#onKeyDown, { signal });
97
96
  }
98
97
  #onFocusIn = (event) => {
98
+ if (!(event instanceof FocusEvent)) {
99
+ return;
100
+ }
99
101
  const { target } = event;
100
102
  target instanceof Element && this.#update(target);
101
103
  };
102
104
  #onFocusOut = (event) => {
105
+ if (!(event instanceof FocusEvent)) {
106
+ return;
107
+ }
103
108
  const target = event.relatedTarget;
104
109
  (!(target instanceof Element) || !this.#focusables.has(target)) && this.#update();
105
110
  };
106
111
  #onKeyDown = (event) => {
112
+ if (!(event instanceof KeyboardEvent)) {
113
+ return;
114
+ }
107
115
  const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
108
116
  if (altKey || ctrlKey || metaKey || shiftKey) {
109
117
  return;
@@ -240,7 +248,7 @@ var RovingTabIndex = class _RovingTabIndex {
240
248
  * Lightweight roving tabindex utility with fully focus management.
241
249
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
242
250
  *
243
- * @version 3.1.5
251
+ * @version 3.1.7
244
252
  * @author Yusuke Kamiyamane
245
253
  * @license MIT
246
254
  * @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.5",
3
+ "version": "3.1.7",
4
4
  "description": "Lightweight roving tabindex utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -56,7 +56,7 @@
56
56
  "node": ">=18"
57
57
  },
58
58
  "dependencies": {
59
- "@y14e/attributes-utils": "^1.1.2",
60
- "power-focusable": "^4.3.6"
59
+ "@y14e/attributes-utils": "^1.1.3",
60
+ "power-focusable": "^4.3.8"
61
61
  }
62
62
  }