@y14e/portal 1.0.2 → 1.0.3
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/dist/index.cjs +10 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -275,8 +275,8 @@ function createPortal(host, container = document.body) {
|
|
|
275
275
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
276
276
|
container = document.body;
|
|
277
277
|
}
|
|
278
|
-
if (
|
|
279
|
-
throw new Error("
|
|
278
|
+
if (containsComposed2(host, container)) {
|
|
279
|
+
throw new Error("Host element cannot contain container");
|
|
280
280
|
}
|
|
281
281
|
const portal = new Portal(host, container);
|
|
282
282
|
return () => portal.destroy();
|
|
@@ -290,6 +290,10 @@ var Portal = class {
|
|
|
290
290
|
#controller = null;
|
|
291
291
|
#isDestroyed = false;
|
|
292
292
|
constructor(host, container) {
|
|
293
|
+
if (host.hasAttribute("data-portaled")) {
|
|
294
|
+
console.warn("Already portaled");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
293
297
|
this.#host = host;
|
|
294
298
|
this.#container = container;
|
|
295
299
|
this.#entranceSentinel = this.#createSentinel();
|
|
@@ -317,7 +321,7 @@ var Portal = class {
|
|
|
317
321
|
this.#exitSentinel.after(this.#host);
|
|
318
322
|
this.#entranceSentinel.remove();
|
|
319
323
|
this.#exitSentinel.remove();
|
|
320
|
-
this.#host.removeAttribute("data-
|
|
324
|
+
this.#host.removeAttribute("data-portaled");
|
|
321
325
|
}
|
|
322
326
|
#initialize() {
|
|
323
327
|
this.#host.before(this.#entranceSentinel);
|
|
@@ -337,7 +341,7 @@ var Portal = class {
|
|
|
337
341
|
capture: true,
|
|
338
342
|
signal
|
|
339
343
|
});
|
|
340
|
-
this.#host.setAttribute("data-
|
|
344
|
+
this.#host.setAttribute("data-portaled", "");
|
|
341
345
|
}
|
|
342
346
|
#onFocusIn = (event) => {
|
|
343
347
|
const current = event.target;
|
|
@@ -391,6 +395,7 @@ var Portal = class {
|
|
|
391
395
|
#createSentinel() {
|
|
392
396
|
const sentinel = document.createElement("span");
|
|
393
397
|
sentinel.setAttribute("aria-hidden", "true");
|
|
398
|
+
sentinel.setAttribute("data-portal-sentinel", "");
|
|
394
399
|
sentinel.setAttribute("tabindex", "0");
|
|
395
400
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
396
401
|
return sentinel;
|
|
@@ -435,7 +440,7 @@ function getActiveElement2() {
|
|
|
435
440
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
436
441
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
437
442
|
*
|
|
438
|
-
* @version 1.0.
|
|
443
|
+
* @version 1.0.3
|
|
439
444
|
* @author Yusuke Kamiyamane
|
|
440
445
|
* @license MIT
|
|
441
446
|
* @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.0.
|
|
6
|
+
* @version 1.0.3
|
|
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.0.
|
|
6
|
+
* @version 1.0.3
|
|
7
7
|
* @author Yusuke Kamiyamane
|
|
8
8
|
* @license MIT
|
|
9
9
|
* @copyright Copyright (c) Yusuke Kamiyamane
|
package/dist/index.js
CHANGED
|
@@ -273,8 +273,8 @@ function createPortal(host, container = document.body) {
|
|
|
273
273
|
console.warn("Invalid container element. Fallback: <body> element.");
|
|
274
274
|
container = document.body;
|
|
275
275
|
}
|
|
276
|
-
if (
|
|
277
|
-
throw new Error("
|
|
276
|
+
if (containsComposed2(host, container)) {
|
|
277
|
+
throw new Error("Host element cannot contain container");
|
|
278
278
|
}
|
|
279
279
|
const portal = new Portal(host, container);
|
|
280
280
|
return () => portal.destroy();
|
|
@@ -288,6 +288,10 @@ var Portal = class {
|
|
|
288
288
|
#controller = null;
|
|
289
289
|
#isDestroyed = false;
|
|
290
290
|
constructor(host, container) {
|
|
291
|
+
if (host.hasAttribute("data-portaled")) {
|
|
292
|
+
console.warn("Already portaled");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
291
295
|
this.#host = host;
|
|
292
296
|
this.#container = container;
|
|
293
297
|
this.#entranceSentinel = this.#createSentinel();
|
|
@@ -315,7 +319,7 @@ var Portal = class {
|
|
|
315
319
|
this.#exitSentinel.after(this.#host);
|
|
316
320
|
this.#entranceSentinel.remove();
|
|
317
321
|
this.#exitSentinel.remove();
|
|
318
|
-
this.#host.removeAttribute("data-
|
|
322
|
+
this.#host.removeAttribute("data-portaled");
|
|
319
323
|
}
|
|
320
324
|
#initialize() {
|
|
321
325
|
this.#host.before(this.#entranceSentinel);
|
|
@@ -335,7 +339,7 @@ var Portal = class {
|
|
|
335
339
|
capture: true,
|
|
336
340
|
signal
|
|
337
341
|
});
|
|
338
|
-
this.#host.setAttribute("data-
|
|
342
|
+
this.#host.setAttribute("data-portaled", "");
|
|
339
343
|
}
|
|
340
344
|
#onFocusIn = (event) => {
|
|
341
345
|
const current = event.target;
|
|
@@ -389,6 +393,7 @@ var Portal = class {
|
|
|
389
393
|
#createSentinel() {
|
|
390
394
|
const sentinel = document.createElement("span");
|
|
391
395
|
sentinel.setAttribute("aria-hidden", "true");
|
|
396
|
+
sentinel.setAttribute("data-portal-sentinel", "");
|
|
392
397
|
sentinel.setAttribute("tabindex", "0");
|
|
393
398
|
sentinel.style.cssText += VISUALLY_HIDDEN_CSS;
|
|
394
399
|
return sentinel;
|
|
@@ -433,7 +438,7 @@ function getActiveElement2() {
|
|
|
433
438
|
* Lightweight DOM portal (teleport) utility with fully focus management.
|
|
434
439
|
* Designed for accessible dialogs, menus, overlays, popovers.
|
|
435
440
|
*
|
|
436
|
-
* @version 1.0.
|
|
441
|
+
* @version 1.0.3
|
|
437
442
|
* @author Yusuke Kamiyamane
|
|
438
443
|
* @license MIT
|
|
439
444
|
* @copyright Copyright (c) Yusuke Kamiyamane
|