@y14e/accordion 1.4.10 → 1.4.11

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
@@ -10,14 +10,14 @@ npm i @y14e/accordion
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import Accordion from '@y14e/accordion@1.4.10';
13
+ import Accordion from '@y14e/accordion@1.4.11';
14
14
 
15
15
  // CDNs
16
- import Accordion from 'https://esm.sh/@y14e/accordion@1.4.10';
16
+ import Accordion from 'https://esm.sh/@y14e/accordion@1.4.11';
17
17
  // or
18
- import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.10/+esm';
18
+ import Accordion from 'https://cdn.jsdelivr.net/npm/@y14e/accordion@1.4.11/+esm';
19
19
  // or
20
- import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.10';
20
+ import Accordion from 'https://esm.unpkg.com/@y14e/accordion@1.4.11';
21
21
  ```
22
22
 
23
23
  ## Usage
package/dist/index.cjs CHANGED
@@ -90,10 +90,11 @@ var Button = class {
90
90
  return;
91
91
  }
92
92
  const active = getActiveElement();
93
- if (active instanceof HTMLElement) {
94
- event.preventDefault();
95
- active.click();
93
+ if (!(active instanceof HTMLElement)) {
94
+ return;
96
95
  }
96
+ event.preventDefault();
97
+ active.click();
97
98
  };
98
99
  };
99
100
  function getActiveElement() {
@@ -477,10 +478,11 @@ var RovingTabIndex = class {
477
478
  }
478
479
  #onFocusIn = (event) => {
479
480
  const { target } = event;
480
- if (target instanceof Element) {
481
- const isFocusable22 = this.#focusables.has(target);
482
- this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
481
+ if (!(target instanceof Element)) {
482
+ return;
483
483
  }
484
+ const isFocusable22 = this.#focusables.has(target);
485
+ this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
484
486
  };
485
487
  #onKeyDown = (event) => {
486
488
  if (!event.composedPath().includes(this.#container)) {
@@ -690,11 +692,11 @@ var Accordion = class _Accordion {
690
692
  if (this.#isDestroyed) {
691
693
  return;
692
694
  }
693
- if (trigger instanceof HTMLElement && this.#bindings.has(trigger)) {
694
- this.#toggle(trigger, false);
695
- } else {
695
+ if (!(trigger instanceof HTMLElement)) {
696
696
  console.warn("Invalid trigger element");
697
+ return;
697
698
  }
699
+ this.#bindings.has(trigger) && this.#toggle(trigger, false);
698
700
  }
699
701
  async destroy(force = false) {
700
702
  if (this.#isDestroyed) {
@@ -725,11 +727,11 @@ var Accordion = class _Accordion {
725
727
  if (this.#isDestroyed) {
726
728
  return;
727
729
  }
728
- if (trigger instanceof HTMLElement && this.#bindings.has(trigger)) {
729
- this.#toggle(trigger, true);
730
- } else {
730
+ if (!(trigger instanceof HTMLElement)) {
731
731
  console.warn("Invalid trigger element");
732
+ return;
732
733
  }
734
+ this.#bindings.has(trigger) && this.#toggle(trigger, true);
733
735
  }
734
736
  #initialize() {
735
737
  saveAttributes(this.#triggerElements, [
@@ -780,16 +782,18 @@ var Accordion = class _Accordion {
780
782
  #onTriggerClick = (event) => {
781
783
  event.preventDefault();
782
784
  const trigger = event.currentTarget;
783
- if (trigger instanceof HTMLElement) {
784
- this.#toggle(trigger, trigger.ariaExpanded === "false");
785
+ if (!(trigger instanceof HTMLElement)) {
786
+ return;
785
787
  }
788
+ this.#toggle(trigger, trigger.ariaExpanded === "false");
786
789
  };
787
790
  #onContentBeforeMatch = (event) => {
788
791
  const content = event.currentTarget;
789
- if (content instanceof HTMLElement) {
790
- const binding = this.#bindings.get(content);
791
- binding && binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
792
+ if (!(content instanceof HTMLElement)) {
793
+ return;
792
794
  }
795
+ const binding = this.#bindings.get(content);
796
+ binding && binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
793
797
  };
794
798
  #toggle(trigger, isOpen, isMatch = false) {
795
799
  if (trigger.ariaExpanded === String(isOpen)) {
@@ -889,7 +893,7 @@ function waitAnimationFinish(animation) {
889
893
  * Accordion
890
894
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
891
895
  *
892
- * @version 1.4.10
896
+ * @version 1.4.11
893
897
  * @author Yusuke Kamiyamane
894
898
  * @license MIT
895
899
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -912,7 +916,7 @@ function waitAnimationFinish(animation) {
912
916
  (**
913
917
  * Button
914
918
  *
915
- * @version 1.0.1
919
+ * @version 1.0.2
916
920
  * @author Yusuke Kamiyamane
917
921
  * @license MIT
918
922
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -925,7 +929,7 @@ function waitAnimationFinish(animation) {
925
929
  * Lightweight roving tabindex utility with fully focus management.
926
930
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
927
931
  *
928
- * @version 3.0.4
932
+ * @version 3.0.5
929
933
  * @author Yusuke Kamiyamane
930
934
  * @license MIT
931
935
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.4.10
5
+ * @version 1.4.11
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Accordion
3
3
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
4
4
  *
5
- * @version 1.4.10
5
+ * @version 1.4.11
6
6
  * @author Yusuke Kamiyamane
7
7
  * @license MIT
8
8
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -88,10 +88,11 @@ var Button = class {
88
88
  return;
89
89
  }
90
90
  const active = getActiveElement();
91
- if (active instanceof HTMLElement) {
92
- event.preventDefault();
93
- active.click();
91
+ if (!(active instanceof HTMLElement)) {
92
+ return;
94
93
  }
94
+ event.preventDefault();
95
+ active.click();
95
96
  };
96
97
  };
97
98
  function getActiveElement() {
@@ -475,10 +476,11 @@ var RovingTabIndex = class {
475
476
  }
476
477
  #onFocusIn = (event) => {
477
478
  const { target } = event;
478
- if (target instanceof Element) {
479
- const isFocusable22 = this.#focusables.has(target);
480
- this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
479
+ if (!(target instanceof Element)) {
480
+ return;
481
481
  }
482
+ const isFocusable22 = this.#focusables.has(target);
483
+ this.#options.noMemory && !isFocusable22 ? this.#update(null) : isFocusable22 && this.#update(target);
482
484
  };
483
485
  #onKeyDown = (event) => {
484
486
  if (!event.composedPath().includes(this.#container)) {
@@ -688,11 +690,11 @@ var Accordion = class _Accordion {
688
690
  if (this.#isDestroyed) {
689
691
  return;
690
692
  }
691
- if (trigger instanceof HTMLElement && this.#bindings.has(trigger)) {
692
- this.#toggle(trigger, false);
693
- } else {
693
+ if (!(trigger instanceof HTMLElement)) {
694
694
  console.warn("Invalid trigger element");
695
+ return;
695
696
  }
697
+ this.#bindings.has(trigger) && this.#toggle(trigger, false);
696
698
  }
697
699
  async destroy(force = false) {
698
700
  if (this.#isDestroyed) {
@@ -723,11 +725,11 @@ var Accordion = class _Accordion {
723
725
  if (this.#isDestroyed) {
724
726
  return;
725
727
  }
726
- if (trigger instanceof HTMLElement && this.#bindings.has(trigger)) {
727
- this.#toggle(trigger, true);
728
- } else {
728
+ if (!(trigger instanceof HTMLElement)) {
729
729
  console.warn("Invalid trigger element");
730
+ return;
730
731
  }
732
+ this.#bindings.has(trigger) && this.#toggle(trigger, true);
731
733
  }
732
734
  #initialize() {
733
735
  saveAttributes(this.#triggerElements, [
@@ -778,16 +780,18 @@ var Accordion = class _Accordion {
778
780
  #onTriggerClick = (event) => {
779
781
  event.preventDefault();
780
782
  const trigger = event.currentTarget;
781
- if (trigger instanceof HTMLElement) {
782
- this.#toggle(trigger, trigger.ariaExpanded === "false");
783
+ if (!(trigger instanceof HTMLElement)) {
784
+ return;
783
785
  }
786
+ this.#toggle(trigger, trigger.ariaExpanded === "false");
784
787
  };
785
788
  #onContentBeforeMatch = (event) => {
786
789
  const content = event.currentTarget;
787
- if (content instanceof HTMLElement) {
788
- const binding = this.#bindings.get(content);
789
- binding && binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
790
+ if (!(content instanceof HTMLElement)) {
791
+ return;
790
792
  }
793
+ const binding = this.#bindings.get(content);
794
+ binding && binding.trigger.ariaExpanded === "false" && this.#toggle(binding.trigger, true, true);
791
795
  };
792
796
  #toggle(trigger, isOpen, isMatch = false) {
793
797
  if (trigger.ariaExpanded === String(isOpen)) {
@@ -887,7 +891,7 @@ function waitAnimationFinish(animation) {
887
891
  * Accordion
888
892
  * WAI-ARIA compliant accordion pattern implementation in TypeScript.
889
893
  *
890
- * @version 1.4.10
894
+ * @version 1.4.11
891
895
  * @author Yusuke Kamiyamane
892
896
  * @license MIT
893
897
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -910,7 +914,7 @@ function waitAnimationFinish(animation) {
910
914
  (**
911
915
  * Button
912
916
  *
913
- * @version 1.0.1
917
+ * @version 1.0.2
914
918
  * @author Yusuke Kamiyamane
915
919
  * @license MIT
916
920
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -923,7 +927,7 @@ function waitAnimationFinish(animation) {
923
927
  * Lightweight roving tabindex utility with fully focus management.
924
928
  * Designed for accessible menus, tabs, toolbars, and composite widgets.
925
929
  *
926
- * @version 3.0.4
930
+ * @version 3.0.5
927
931
  * @author Yusuke Kamiyamane
928
932
  * @license MIT
929
933
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/accordion",
3
- "version": "1.4.10",
3
+ "version": "1.4.11",
4
4
  "description": "WAI-ARIA compliant accordion pattern implementation in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -44,8 +44,8 @@
44
44
  "homepage": "https://github.com/y14e/accordion#readme",
45
45
  "devDependencies": {
46
46
  "@y14e/attributes-utils": "^1.1.2",
47
- "@y14e/button": "^1.0.1",
48
- "@y14e/roving-tabindex": "^3.0.4",
47
+ "@y14e/button": "^1.0.2",
48
+ "@y14e/roving-tabindex": "^3.0.5",
49
49
  "bun-types": "latest",
50
50
  "tsup": "^8.0.0",
51
51
  "typescript": "^5.6.0",