@y14e/portal 1.3.6 → 1.3.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/portal
13
13
  import { createPortal } from '@y14e/portal';
14
14
 
15
15
  // CDNs
16
- import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.6';
16
+ import { createPortal } from 'https://esm.sh/@y14e/portal@1.3.7';
17
17
  // or
18
- import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.6/+esm';
18
+ import { createPortal } from 'https://cdn.jsdelivr.net/npm/@y14e/portal@1.3.7/+esm';
19
19
  // or
20
- import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.6';
20
+ import { createPortal } from 'https://esm.unpkg.com/@y14e/portal@1.3.7';
21
21
  ```
22
22
 
23
23
  ## 📦 APIs
@@ -3,27 +3,27 @@
3
3
  // node_modules/@y14e/attribute-utils/dist/index.js
4
4
  var snapshots = /* @__PURE__ */ new WeakMap();
5
5
  function restoreAttributes(element_or_elements) {
6
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
7
- const snapshot = snapshots.get(element);
6
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
7
+ const snapshot = snapshots.get(e);
8
8
  if (!snapshot) {
9
9
  continue;
10
10
  }
11
- for (const [name, value] of snapshot.entries()) {
12
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
11
+ for (const [n, v] of snapshot.entries()) {
12
+ v === null ? e.removeAttribute(n) : e.setAttribute(n, v);
13
13
  }
14
- snapshots.delete(element);
14
+ snapshots.delete(e);
15
15
  }
16
16
  }
17
17
  function saveAttributes(element_or_elements, name_or_names) {
18
18
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
19
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
20
- let snapshot = snapshots.get(element);
19
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
20
+ let snapshot = snapshots.get(e);
21
21
  if (!snapshot) {
22
22
  snapshot = /* @__PURE__ */ new Map();
23
- snapshots.set(element, snapshot);
23
+ snapshots.set(e, snapshot);
24
24
  }
25
- for (const name of names) {
26
- snapshot.set(name, element.getAttribute(name));
25
+ for (const n of names) {
26
+ snapshot.set(n, e.getAttribute(n));
27
27
  }
28
28
  }
29
29
  }
@@ -53,21 +53,21 @@ function getFocusables(container = document.body, options = {}) {
53
53
  skipNegativeTabIndexCheck,
54
54
  skipVisibilityCheck
55
55
  }) || include?.(node)) {
56
- candidates[candidates.length] = node;
56
+ candidates.push(node);
57
57
  }
58
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
58
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
59
59
  };
60
- (composed ? getComposedChildren(container) : getChildren(container)).map(
60
+ (composed ? getComposedChildren(container) : [...container.children]).map(
61
61
  traverse2
62
62
  );
63
63
  } else {
64
- for (const match of container.querySelectorAll(
64
+ for (const m of container.querySelectorAll(
65
65
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
66
66
  )) {
67
- match && isFocusable(match, {
67
+ m && isFocusable(m, {
68
68
  skipNegativeTabIndexCheck,
69
69
  skipVisibilityCheck
70
- }) && candidates.push(match);
70
+ }) && candidates.push(m);
71
71
  }
72
72
  }
73
73
  return normalizeRadioGroup(
@@ -183,58 +183,58 @@ function isDisabledDeep(element) {
183
183
  }
184
184
  function normalizeRadioGroup(elements) {
185
185
  let map = null;
186
- for (const element of elements) {
187
- if (!(element instanceof HTMLInputElement)) {
186
+ for (const e of elements) {
187
+ if (!(e instanceof HTMLInputElement)) {
188
188
  continue;
189
189
  }
190
- if (!isUngroupedRadio(element)) {
190
+ if (!isUngroupedRadio(e)) {
191
191
  continue;
192
192
  }
193
193
  if (!map) {
194
194
  map = /* @__PURE__ */ new Map();
195
195
  }
196
- const root = element.getRootNode();
197
- let value = map.get(root);
198
- if (!value) {
199
- value = /* @__PURE__ */ new Map();
200
- map.set(root, value);
196
+ const root = e.getRootNode();
197
+ let groups = map.get(root);
198
+ if (!groups) {
199
+ groups = /* @__PURE__ */ new Map();
200
+ map.set(root, groups);
201
201
  }
202
- let v = value.get(element.form);
203
- if (!v) {
204
- v = /* @__PURE__ */ new Map();
205
- value.set(element.form, v);
202
+ let group = groups.get(e.form);
203
+ if (!group) {
204
+ group = /* @__PURE__ */ new Map();
205
+ groups.set(e.form, group);
206
206
  }
207
- let vv = v.get(element.name);
208
- if (!vv) {
209
- vv = [];
210
- v.set(element.name, vv);
207
+ let radios = group.get(e.name);
208
+ if (!radios) {
209
+ radios = [];
210
+ group.set(e.name, radios);
211
211
  }
212
- vv[vv.length] = element;
212
+ radios.push(e);
213
213
  }
214
214
  if (!map) {
215
215
  return elements;
216
216
  }
217
217
  const placeholder = /* @__PURE__ */ new Set();
218
- for (const value of map.values()) {
219
- for (const v of value.values()) {
220
- for (const vv of v.values()) {
221
- const radio = vv.find((element) => element.checked) ?? vv[0];
218
+ for (const v of map.values()) {
219
+ for (const w of v.values()) {
220
+ for (const x of w.values()) {
221
+ const radio = x.find((r) => r.checked) ?? x[0];
222
222
  radio && placeholder.add(radio);
223
223
  }
224
224
  }
225
225
  }
226
- return elements.filter((element) => {
227
- if (!(element instanceof HTMLInputElement)) {
226
+ return elements.filter((e) => {
227
+ if (!(e instanceof HTMLInputElement)) {
228
228
  return true;
229
229
  }
230
- return !isUngroupedRadio(element) || placeholder.has(element);
230
+ return !isUngroupedRadio(e) || placeholder.has(e);
231
231
  });
232
232
  }
233
233
  function sortByTabIndex(elements) {
234
234
  const ordered = [];
235
235
  const natural = [];
236
- for (const element of elements) {
237
- (getTabIndex(element) > 0 ? ordered : natural).push(element);
236
+ for (const e of elements) {
237
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
238
238
  }
239
239
  return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
240
240
  }
@@ -251,7 +251,7 @@ function containsComposed(container, element) {
251
251
  }
252
252
  function getComposedChildren(node) {
253
253
  if (node instanceof ShadowRoot) {
254
- return getChildren(node);
254
+ return [...node.children];
255
255
  }
256
256
  if (!(node instanceof Element)) {
257
257
  return [];
@@ -263,9 +263,9 @@ function getComposedChildren(node) {
263
263
  }
264
264
  }
265
265
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
266
- return getChildren(node.shadowRoot);
266
+ return [...node.shadowRoot.children];
267
267
  }
268
- return getChildren(node);
268
+ return [...node.children];
269
269
  }
270
270
  function focusElement(element) {
271
271
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -277,13 +277,6 @@ function getActiveElement() {
277
277
  }
278
278
  return current;
279
279
  }
280
- function getChildren(node) {
281
- const elements = [];
282
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
283
- elements[elements.length] = child;
284
- }
285
- return elements;
286
- }
287
280
  function getTabIndex(element) {
288
281
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
289
282
  }
@@ -357,7 +350,7 @@ function resolveOptions(options) {
357
350
  }
358
351
 
359
352
  // src/index.ts
360
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
353
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
361
354
  function createPortal(host, container = document.body, options = {}) {
362
355
  if (!(host instanceof Element)) {
363
356
  console.warn("Invalid host element");
@@ -419,8 +412,8 @@ var Portal = class {
419
412
  this.#update();
420
413
  this.#controller = new AbortController();
421
414
  const { signal } = this.#controller;
422
- for (const sentinel of [this.#entranceSentinel, this.#exitSentinel]) {
423
- sentinel.addEventListener("focus", this.#onFocus, { signal });
415
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
416
+ s.addEventListener("focus", this.#onFocus, { signal });
424
417
  }
425
418
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
426
419
  this.#host.setAttribute("data-portaled", "");
@@ -479,17 +472,17 @@ var Portal = class {
479
472
  ...this.#getFocusables(),
480
473
  ...getFocusables(this.#host, { composed: true })
481
474
  ]);
482
- for (const focusable of this.#focusables) {
483
- if (!current.has(focusable)) {
484
- restoreAttributes(focusable);
485
- this.#focusables.delete(focusable);
475
+ for (const f of this.#focusables) {
476
+ if (!current.has(f)) {
477
+ restoreAttributes(f);
478
+ this.#focusables.delete(f);
486
479
  }
487
480
  }
488
- for (const focusable of current) {
489
- if (!this.#focusables.has(focusable)) {
490
- this.#focusables.add(focusable);
491
- saveAttributes(focusable, "tabindex");
492
- focusable.setAttribute("tabindex", "-1");
481
+ for (const f of current) {
482
+ if (!this.#focusables.has(f)) {
483
+ this.#focusables.add(f);
484
+ saveAttributes(f, "tabindex");
485
+ f.setAttribute("tabindex", "-1");
493
486
  }
494
487
  }
495
488
  }
@@ -544,7 +537,7 @@ function resolveOptions2(options) {
544
537
  * Lightweight DOM portal (teleport) utility with fully focus management.
545
538
  * Designed for accessible dialogs, menus, overlays, popovers.
546
539
  *
547
- * @version 1.3.6
540
+ * @version 1.3.7
548
541
  * @author Yusuke Kamiyamane
549
542
  * @license MIT
550
543
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -556,7 +549,7 @@ function resolveOptions2(options) {
556
549
  (**
557
550
  * Attribute Utils
558
551
  *
559
- * @version 2.0.10
552
+ * @version 2.0.11
560
553
  * @author Yusuke Kamiyamane
561
554
  * @license MIT
562
555
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -569,7 +562,7 @@ power-focusable/dist/index.js:
569
562
  * High-precision focus management utility with full composed tree support.
570
563
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
571
564
  *
572
- * @version 4.3.30
565
+ * @version 4.3.31
573
566
  * @author Yusuke Kamiyamane
574
567
  * @license MIT
575
568
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -1,27 +1,27 @@
1
1
  // node_modules/@y14e/attribute-utils/dist/index.js
2
2
  var snapshots = /* @__PURE__ */ new WeakMap();
3
3
  function restoreAttributes(element_or_elements) {
4
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
5
- const snapshot = snapshots.get(element);
4
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
5
+ const snapshot = snapshots.get(e);
6
6
  if (!snapshot) {
7
7
  continue;
8
8
  }
9
- for (const [name, value] of snapshot.entries()) {
10
- value === null ? element.removeAttribute(name) : element.setAttribute(name, value);
9
+ for (const [n, v] of snapshot.entries()) {
10
+ v === null ? e.removeAttribute(n) : e.setAttribute(n, v);
11
11
  }
12
- snapshots.delete(element);
12
+ snapshots.delete(e);
13
13
  }
14
14
  }
15
15
  function saveAttributes(element_or_elements, name_or_names) {
16
16
  const names = Array.isArray(name_or_names) ? name_or_names : [name_or_names];
17
- for (const element of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
18
- let snapshot = snapshots.get(element);
17
+ for (const e of Array.isArray(element_or_elements) ? element_or_elements : [element_or_elements]) {
18
+ let snapshot = snapshots.get(e);
19
19
  if (!snapshot) {
20
20
  snapshot = /* @__PURE__ */ new Map();
21
- snapshots.set(element, snapshot);
21
+ snapshots.set(e, snapshot);
22
22
  }
23
- for (const name of names) {
24
- snapshot.set(name, element.getAttribute(name));
23
+ for (const n of names) {
24
+ snapshot.set(n, e.getAttribute(n));
25
25
  }
26
26
  }
27
27
  }
@@ -51,21 +51,21 @@ function getFocusables(container = document.body, options = {}) {
51
51
  skipNegativeTabIndexCheck,
52
52
  skipVisibilityCheck
53
53
  }) || include?.(node)) {
54
- candidates[candidates.length] = node;
54
+ candidates.push(node);
55
55
  }
56
- (composed ? getComposedChildren(node) : getChildren(node)).map(traverse2);
56
+ (composed ? getComposedChildren(node) : [...node.children]).map(traverse2);
57
57
  };
58
- (composed ? getComposedChildren(container) : getChildren(container)).map(
58
+ (composed ? getComposedChildren(container) : [...container.children]).map(
59
59
  traverse2
60
60
  );
61
61
  } else {
62
- for (const match of container.querySelectorAll(
62
+ for (const m of container.querySelectorAll(
63
63
  skipNegativeTabIndexCheck ? FOCUSABLE_SELECTOR_WITH_NEGATIVE_TABINDEX : FOCUSABLE_SELECTOR
64
64
  )) {
65
- match && isFocusable(match, {
65
+ m && isFocusable(m, {
66
66
  skipNegativeTabIndexCheck,
67
67
  skipVisibilityCheck
68
- }) && candidates.push(match);
68
+ }) && candidates.push(m);
69
69
  }
70
70
  }
71
71
  return normalizeRadioGroup(
@@ -181,58 +181,58 @@ function isDisabledDeep(element) {
181
181
  }
182
182
  function normalizeRadioGroup(elements) {
183
183
  let map = null;
184
- for (const element of elements) {
185
- if (!(element instanceof HTMLInputElement)) {
184
+ for (const e of elements) {
185
+ if (!(e instanceof HTMLInputElement)) {
186
186
  continue;
187
187
  }
188
- if (!isUngroupedRadio(element)) {
188
+ if (!isUngroupedRadio(e)) {
189
189
  continue;
190
190
  }
191
191
  if (!map) {
192
192
  map = /* @__PURE__ */ new Map();
193
193
  }
194
- const root = element.getRootNode();
195
- let value = map.get(root);
196
- if (!value) {
197
- value = /* @__PURE__ */ new Map();
198
- map.set(root, value);
194
+ const root = e.getRootNode();
195
+ let groups = map.get(root);
196
+ if (!groups) {
197
+ groups = /* @__PURE__ */ new Map();
198
+ map.set(root, groups);
199
199
  }
200
- let v = value.get(element.form);
201
- if (!v) {
202
- v = /* @__PURE__ */ new Map();
203
- value.set(element.form, v);
200
+ let group = groups.get(e.form);
201
+ if (!group) {
202
+ group = /* @__PURE__ */ new Map();
203
+ groups.set(e.form, group);
204
204
  }
205
- let vv = v.get(element.name);
206
- if (!vv) {
207
- vv = [];
208
- v.set(element.name, vv);
205
+ let radios = group.get(e.name);
206
+ if (!radios) {
207
+ radios = [];
208
+ group.set(e.name, radios);
209
209
  }
210
- vv[vv.length] = element;
210
+ radios.push(e);
211
211
  }
212
212
  if (!map) {
213
213
  return elements;
214
214
  }
215
215
  const placeholder = /* @__PURE__ */ new Set();
216
- for (const value of map.values()) {
217
- for (const v of value.values()) {
218
- for (const vv of v.values()) {
219
- const radio = vv.find((element) => element.checked) ?? vv[0];
216
+ for (const v of map.values()) {
217
+ for (const w of v.values()) {
218
+ for (const x of w.values()) {
219
+ const radio = x.find((r) => r.checked) ?? x[0];
220
220
  radio && placeholder.add(radio);
221
221
  }
222
222
  }
223
223
  }
224
- return elements.filter((element) => {
225
- if (!(element instanceof HTMLInputElement)) {
224
+ return elements.filter((e) => {
225
+ if (!(e instanceof HTMLInputElement)) {
226
226
  return true;
227
227
  }
228
- return !isUngroupedRadio(element) || placeholder.has(element);
228
+ return !isUngroupedRadio(e) || placeholder.has(e);
229
229
  });
230
230
  }
231
231
  function sortByTabIndex(elements) {
232
232
  const ordered = [];
233
233
  const natural = [];
234
- for (const element of elements) {
235
- (getTabIndex(element) > 0 ? ordered : natural).push(element);
234
+ for (const e of elements) {
235
+ (getTabIndex(e) > 0 ? ordered : natural).push(e);
236
236
  }
237
237
  return ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b)).concat(natural);
238
238
  }
@@ -249,7 +249,7 @@ function containsComposed(container, element) {
249
249
  }
250
250
  function getComposedChildren(node) {
251
251
  if (node instanceof ShadowRoot) {
252
- return getChildren(node);
252
+ return [...node.children];
253
253
  }
254
254
  if (!(node instanceof Element)) {
255
255
  return [];
@@ -261,9 +261,9 @@ function getComposedChildren(node) {
261
261
  }
262
262
  }
263
263
  if (node instanceof HTMLElement && node.shadowRoot?.mode === "open") {
264
- return getChildren(node.shadowRoot);
264
+ return [...node.shadowRoot.children];
265
265
  }
266
- return getChildren(node);
266
+ return [...node.children];
267
267
  }
268
268
  function focusElement(element) {
269
269
  "focus" in element && typeof element.focus === "function" && element.focus();
@@ -275,13 +275,6 @@ function getActiveElement() {
275
275
  }
276
276
  return current;
277
277
  }
278
- function getChildren(node) {
279
- const elements = [];
280
- for (let child = node.firstElementChild; child; child = child.nextElementSibling) {
281
- elements[elements.length] = child;
282
- }
283
- return elements;
284
- }
285
278
  function getTabIndex(element) {
286
279
  return "tabIndex" in element ? Number(element.tabIndex) : 0;
287
280
  }
@@ -355,7 +348,7 @@ function resolveOptions(options) {
355
348
  }
356
349
 
357
350
  // src/index.ts
358
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
351
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
359
352
  function createPortal(host, container = document.body, options = {}) {
360
353
  if (!(host instanceof Element)) {
361
354
  console.warn("Invalid host element");
@@ -417,8 +410,8 @@ var Portal = class {
417
410
  this.#update();
418
411
  this.#controller = new AbortController();
419
412
  const { signal } = this.#controller;
420
- for (const sentinel of [this.#entranceSentinel, this.#exitSentinel]) {
421
- sentinel.addEventListener("focus", this.#onFocus, { signal });
413
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
414
+ s.addEventListener("focus", this.#onFocus, { signal });
422
415
  }
423
416
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
424
417
  this.#host.setAttribute("data-portaled", "");
@@ -477,17 +470,17 @@ var Portal = class {
477
470
  ...this.#getFocusables(),
478
471
  ...getFocusables(this.#host, { composed: true })
479
472
  ]);
480
- for (const focusable of this.#focusables) {
481
- if (!current.has(focusable)) {
482
- restoreAttributes(focusable);
483
- this.#focusables.delete(focusable);
473
+ for (const f of this.#focusables) {
474
+ if (!current.has(f)) {
475
+ restoreAttributes(f);
476
+ this.#focusables.delete(f);
484
477
  }
485
478
  }
486
- for (const focusable of current) {
487
- if (!this.#focusables.has(focusable)) {
488
- this.#focusables.add(focusable);
489
- saveAttributes(focusable, "tabindex");
490
- focusable.setAttribute("tabindex", "-1");
479
+ for (const f of current) {
480
+ if (!this.#focusables.has(f)) {
481
+ this.#focusables.add(f);
482
+ saveAttributes(f, "tabindex");
483
+ f.setAttribute("tabindex", "-1");
491
484
  }
492
485
  }
493
486
  }
@@ -542,7 +535,7 @@ function resolveOptions2(options) {
542
535
  * Lightweight DOM portal (teleport) utility with fully focus management.
543
536
  * Designed for accessible dialogs, menus, overlays, popovers.
544
537
  *
545
- * @version 1.3.6
538
+ * @version 1.3.7
546
539
  * @author Yusuke Kamiyamane
547
540
  * @license MIT
548
541
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -554,7 +547,7 @@ function resolveOptions2(options) {
554
547
  (**
555
548
  * Attribute Utils
556
549
  *
557
- * @version 2.0.10
550
+ * @version 2.0.11
558
551
  * @author Yusuke Kamiyamane
559
552
  * @license MIT
560
553
  * @copyright Copyright (c) Yusuke Kamiyamane
@@ -567,7 +560,7 @@ power-focusable/dist/index.js:
567
560
  * High-precision focus management utility with full composed tree support.
568
561
  * Handles complex focus rules including tabindex ordering, radio groups, inert.
569
562
  *
570
- * @version 4.3.30
563
+ * @version 4.3.31
571
564
  * @author Yusuke Kamiyamane
572
565
  * @license MIT
573
566
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ var utils__namespace = /*#__PURE__*/_interopNamespace(utils);
25
25
  var pf__namespace = /*#__PURE__*/_interopNamespace(pf);
26
26
 
27
27
  // src/index.ts
28
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
28
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
29
29
  function createPortal(host, container = document.body, options = {}) {
30
30
  if (!(host instanceof Element)) {
31
31
  console.warn("Invalid host element");
@@ -87,8 +87,8 @@ var Portal = class {
87
87
  this.#update();
88
88
  this.#controller = new AbortController();
89
89
  const { signal } = this.#controller;
90
- for (const sentinel of [this.#entranceSentinel, this.#exitSentinel]) {
91
- sentinel.addEventListener("focus", this.#onFocus, { signal });
90
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
91
+ s.addEventListener("focus", this.#onFocus, { signal });
92
92
  }
93
93
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
94
94
  this.#host.setAttribute("data-portaled", "");
@@ -147,17 +147,17 @@ var Portal = class {
147
147
  ...this.#getFocusables(),
148
148
  ...pf__namespace.getFocusables(this.#host, { composed: true })
149
149
  ]);
150
- for (const focusable of this.#focusables) {
151
- if (!current.has(focusable)) {
152
- utils__namespace.restoreAttributes(focusable);
153
- this.#focusables.delete(focusable);
150
+ for (const f of this.#focusables) {
151
+ if (!current.has(f)) {
152
+ utils__namespace.restoreAttributes(f);
153
+ this.#focusables.delete(f);
154
154
  }
155
155
  }
156
- for (const focusable of current) {
157
- if (!this.#focusables.has(focusable)) {
158
- this.#focusables.add(focusable);
159
- utils__namespace.saveAttributes(focusable, "tabindex");
160
- focusable.setAttribute("tabindex", "-1");
156
+ for (const f of current) {
157
+ if (!this.#focusables.has(f)) {
158
+ this.#focusables.add(f);
159
+ utils__namespace.saveAttributes(f, "tabindex");
160
+ f.setAttribute("tabindex", "-1");
161
161
  }
162
162
  }
163
163
  }
@@ -212,7 +212,7 @@ function resolveOptions(options) {
212
212
  * Lightweight DOM portal (teleport) utility with fully focus management.
213
213
  * Designed for accessible dialogs, menus, overlays, popovers.
214
214
  *
215
- * @version 1.3.6
215
+ * @version 1.3.7
216
216
  * @author Yusuke Kamiyamane
217
217
  * @license MIT
218
218
  * @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.3.6
6
+ * @version 1.3.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 DOM portal (teleport) utility with fully focus management.
4
4
  * Designed for accessible dialogs, menus, overlays, popovers.
5
5
  *
6
- * @version 1.3.6
6
+ * @version 1.3.7
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import * as utils from '@y14e/attribute-utils';
2
2
  import * as pf from 'power-focusable';
3
3
 
4
4
  // src/index.ts
5
- var VISUALLY_HIDDEN_CSS = `border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;`;
5
+ var VISUALLY_HIDDEN_CSS = "border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; user-select: none; white-space: nowrap; width: 1px;";
6
6
  function createPortal(host, container = document.body, options = {}) {
7
7
  if (!(host instanceof Element)) {
8
8
  console.warn("Invalid host element");
@@ -64,8 +64,8 @@ var Portal = class {
64
64
  this.#update();
65
65
  this.#controller = new AbortController();
66
66
  const { signal } = this.#controller;
67
- for (const sentinel of [this.#entranceSentinel, this.#exitSentinel]) {
68
- sentinel.addEventListener("focus", this.#onFocus, { signal });
67
+ for (const s of [this.#entranceSentinel, this.#exitSentinel]) {
68
+ s.addEventListener("focus", this.#onFocus, { signal });
69
69
  }
70
70
  this.#host.addEventListener("keydown", this.#onKeyDown, { signal });
71
71
  this.#host.setAttribute("data-portaled", "");
@@ -124,17 +124,17 @@ var Portal = class {
124
124
  ...this.#getFocusables(),
125
125
  ...pf.getFocusables(this.#host, { composed: true })
126
126
  ]);
127
- for (const focusable of this.#focusables) {
128
- if (!current.has(focusable)) {
129
- utils.restoreAttributes(focusable);
130
- this.#focusables.delete(focusable);
127
+ for (const f of this.#focusables) {
128
+ if (!current.has(f)) {
129
+ utils.restoreAttributes(f);
130
+ this.#focusables.delete(f);
131
131
  }
132
132
  }
133
- for (const focusable of current) {
134
- if (!this.#focusables.has(focusable)) {
135
- this.#focusables.add(focusable);
136
- utils.saveAttributes(focusable, "tabindex");
137
- focusable.setAttribute("tabindex", "-1");
133
+ for (const f of current) {
134
+ if (!this.#focusables.has(f)) {
135
+ this.#focusables.add(f);
136
+ utils.saveAttributes(f, "tabindex");
137
+ f.setAttribute("tabindex", "-1");
138
138
  }
139
139
  }
140
140
  }
@@ -189,7 +189,7 @@ function resolveOptions(options) {
189
189
  * Lightweight DOM portal (teleport) utility with fully focus management.
190
190
  * Designed for accessible dialogs, menus, overlays, popovers.
191
191
  *
192
- * @version 1.3.6
192
+ * @version 1.3.7
193
193
  * @author Yusuke Kamiyamane
194
194
  * @license MIT
195
195
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@y14e/portal",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
4
4
  "description": "Lightweight DOM portal (teleport) utility with fully focus management",
5
5
  "keywords": [
6
6
  "a11y",
@@ -58,7 +58,7 @@
58
58
  "esbuild": true
59
59
  },
60
60
  "dependencies": {
61
- "@y14e/attribute-utils": "^2.0.10",
62
- "power-focusable": "^4.3.30"
61
+ "@y14e/attribute-utils": "^2.0.11",
62
+ "power-focusable": "^4.3.31"
63
63
  }
64
64
  }