@y14e/portal 1.2.12 → 1.2.13

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/portal
10
10
 
11
11
  ```ts
12
12
  // npm
13
- import { createPortal } from '@y14e/portal@1.2.12';
13
+ import { createPortal } from '@y14e/portal@1.2.13';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.12';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.13';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.12/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.13/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.12';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.13';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -400,6 +400,7 @@ var Portal = class {
400
400
  #exitSentinel;
401
401
  #focusables = /* @__PURE__ */ new Set();
402
402
  #controller = null;
403
+ #timer;
403
404
  #isDestroyed = false;
404
405
  constructor(host, container) {
405
406
  this.#host = host;
@@ -415,6 +416,10 @@ var Portal = class {
415
416
  this.#isDestroyed = true;
416
417
  this.#controller?.abort();
417
418
  this.#controller = null;
419
+ if (this.#timer !== void 0) {
420
+ cancelAnimationFrame(this.#timer);
421
+ this.#timer = void 0;
422
+ }
418
423
  restoreAttributes([...this.#focusables]);
419
424
  this.#focusables.clear();
420
425
  this.#exitSentinel.after(this.#host);
@@ -523,7 +528,8 @@ var Portal = class {
523
528
  return sentinel;
524
529
  }
525
530
  #focusSentinel(isPrevious) {
526
- requestAnimationFrame(
531
+ this.#timer && cancelAnimationFrame(this.#timer);
532
+ this.#timer = requestAnimationFrame(
527
533
  () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
528
534
  );
529
535
  }
@@ -567,7 +573,7 @@ function getActiveElement2() {
567
573
  * Lightweight DOM portal (teleport) utility with fully focus management.
568
574
  * Designed for accessible dialogs, menus, overlays, popovers.
569
575
  *
570
- * @version 1.2.12
576
+ * @version 1.2.13
571
577
  * @author Yusuke Kamiyamane
572
578
  * @license MIT
573
579
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Lightweight DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.2.12
6
+ * @version 1.2.13
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 DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.2.12
6
+ * @version 1.2.13
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -398,6 +398,7 @@ var Portal = class {
398
398
  #exitSentinel;
399
399
  #focusables = /* @__PURE__ */ new Set();
400
400
  #controller = null;
401
+ #timer;
401
402
  #isDestroyed = false;
402
403
  constructor(host, container) {
403
404
  this.#host = host;
@@ -413,6 +414,10 @@ var Portal = class {
413
414
  this.#isDestroyed = true;
414
415
  this.#controller?.abort();
415
416
  this.#controller = null;
417
+ if (this.#timer !== void 0) {
418
+ cancelAnimationFrame(this.#timer);
419
+ this.#timer = void 0;
420
+ }
416
421
  restoreAttributes([...this.#focusables]);
417
422
  this.#focusables.clear();
418
423
  this.#exitSentinel.after(this.#host);
@@ -521,7 +526,8 @@ var Portal = class {
521
526
  return sentinel;
522
527
  }
523
528
  #focusSentinel(isPrevious) {
524
- requestAnimationFrame(
529
+ this.#timer && cancelAnimationFrame(this.#timer);
530
+ this.#timer = requestAnimationFrame(
525
531
  () => (isPrevious ? this.#entranceSentinel : this.#exitSentinel).focus()
526
532
  );
527
533
  }
@@ -565,7 +571,7 @@ function getActiveElement2() {
565
571
  * Lightweight DOM portal (teleport) utility with fully focus management.
566
572
  * Designed for accessible dialogs, menus, overlays, popovers.
567
573
  *
568
- * @version 1.2.12
574
+ * @version 1.2.13
569
575
  * @author Yusuke Kamiyamane
570
576
  * @license MIT
571
577
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",