@y14e/portal 1.2.15 → 1.2.17

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.15';
13
+ import { createPortal } from '@y14e/portal@1.2.17';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.15';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.2.17';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.15/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.2.17/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.15';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.2.17';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
package/dist/index.cjs CHANGED
@@ -370,10 +370,6 @@ function createPortal(host, container = document.body) {
370
370
  return () => {
371
371
  };
372
372
  }
373
- if (!(container instanceof Element)) {
374
- console.warn("Invalid container element. Fallback: <body> element.");
375
- container = document.body;
376
- }
377
373
  if (containsComposed2(host, container)) {
378
374
  console.warn("Host element cannot contain the container element");
379
375
  return () => {
@@ -393,6 +389,10 @@ var Portal = class {
393
389
  #isDestroyed = false;
394
390
  constructor(host, container) {
395
391
  this.#host = host;
392
+ if (!(container instanceof Element)) {
393
+ console.warn("Invalid container element. Fallback: <body> element.");
394
+ container = document.body;
395
+ }
396
396
  this.#container = container;
397
397
  this.#entranceSentinel = this.#createSentinel();
398
398
  this.#exitSentinel = this.#createSentinel();
@@ -455,9 +455,7 @@ var Portal = class {
455
455
  });
456
456
  next && focusElement(next);
457
457
  }
458
- return;
459
- }
460
- if (current === this.#exitSentinel) {
458
+ } else if (current === this.#exitSentinel) {
461
459
  if (this.#host.contains(before)) {
462
460
  this.#moveFocus("next");
463
461
  return;
@@ -473,7 +471,6 @@ var Portal = class {
473
471
  });
474
472
  previous && focusElement(previous);
475
473
  }
476
- return;
477
474
  }
478
475
  };
479
476
  #onKeyDown = (event) => {
@@ -575,7 +572,7 @@ function getActiveElement2() {
575
572
  * Lightweight DOM portal (teleport) utility with fully focus management.
576
573
  * Designed for accessible dialogs, menus, overlays, popovers.
577
574
  *
578
- * @version 1.2.15
575
+ * @version 1.2.17
579
576
  * @author Yusuke Kamiyamane
580
577
  * @license MIT
581
578
  * @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.15
6
+ * @version 1.2.17
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.15
6
+ * @version 1.2.17
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -368,10 +368,6 @@ function createPortal(host, container = document.body) {
368
368
  return () => {
369
369
  };
370
370
  }
371
- if (!(container instanceof Element)) {
372
- console.warn("Invalid container element. Fallback: <body> element.");
373
- container = document.body;
374
- }
375
371
  if (containsComposed2(host, container)) {
376
372
  console.warn("Host element cannot contain the container element");
377
373
  return () => {
@@ -391,6 +387,10 @@ var Portal = class {
391
387
  #isDestroyed = false;
392
388
  constructor(host, container) {
393
389
  this.#host = host;
390
+ if (!(container instanceof Element)) {
391
+ console.warn("Invalid container element. Fallback: <body> element.");
392
+ container = document.body;
393
+ }
394
394
  this.#container = container;
395
395
  this.#entranceSentinel = this.#createSentinel();
396
396
  this.#exitSentinel = this.#createSentinel();
@@ -453,9 +453,7 @@ var Portal = class {
453
453
  });
454
454
  next && focusElement(next);
455
455
  }
456
- return;
457
- }
458
- if (current === this.#exitSentinel) {
456
+ } else if (current === this.#exitSentinel) {
459
457
  if (this.#host.contains(before)) {
460
458
  this.#moveFocus("next");
461
459
  return;
@@ -471,7 +469,6 @@ var Portal = class {
471
469
  });
472
470
  previous && focusElement(previous);
473
471
  }
474
- return;
475
472
  }
476
473
  };
477
474
  #onKeyDown = (event) => {
@@ -573,7 +570,7 @@ function getActiveElement2() {
573
570
  * Lightweight DOM portal (teleport) utility with fully focus management.
574
571
  * Designed for accessible dialogs, menus, overlays, popovers.
575
572
  *
576
- * @version 1.2.15
573
+ * @version 1.2.17
577
574
  * @author Yusuke Kamiyamane
578
575
  * @license MIT
579
576
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",