elements-kit 0.1.0 → 0.3.0
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/attributes.d.mts +1 -1
- package/dist/benchmark.CX_oY03V-COK1VBpH.mjs +5176 -0
- package/dist/custom-elements.d.mts +1 -1
- package/dist/{element-w1GCIMVp.mjs → element-BjpyY6qv.mjs} +17 -35
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +2 -2
- package/dist/{infer-DuFY-y2b.d.mts → infer-BUUWMoG9.d.mts} +3 -3
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +2 -2
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/jsx-runtime/index.mjs +1 -1
- package/dist/render.mjs +1 -1
- package/dist/{scope-DM2gzOkb.mjs → scope-CwVlgN8b.mjs} +1 -1
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.mjs +2 -2
- package/dist/{slot-CKtUoy2X.mjs → slot-BnzxFBfO.mjs} +1 -1
- package/dist/slot.d.mts +1 -1
- package/dist/slot.mjs +1 -1
- package/dist/{test.BmQO5GaM-BeO5pvCo.mjs → test.BmQO5GaM-C8YqghE0.mjs} +9 -5156
- package/dist/utilities/_observe.mjs +1 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +1 -1
- package/dist/utilities/active-element.test.mjs +2 -1
- package/dist/utilities/async.d.mts +1 -1
- package/dist/utilities/async.mjs +1 -1
- package/dist/utilities/async.test.mjs +3 -2
- package/dist/utilities/context.d.mts +78 -0
- package/dist/utilities/context.mjs +115 -0
- package/dist/utilities/context.test.d.mts +1 -0
- package/dist/utilities/context.test.mjs +171 -0
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +1 -1
- package/dist/utilities/debounced.test.mjs +3 -2
- package/dist/utilities/dom-lifecycle.bench.d.mts +1 -0
- package/dist/utilities/dom-lifecycle.bench.mjs +90 -0
- package/dist/utilities/dom-lifecycle.d.mts +88 -0
- package/dist/utilities/dom-lifecycle.mjs +113 -0
- package/dist/utilities/dom-lifecycle.test.d.mts +1 -0
- package/dist/utilities/dom-lifecycle.test.mjs +227 -0
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +1 -1
- package/dist/utilities/element-rect.test.mjs +3 -2
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/element-scroll.test.mjs +3 -2
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +1 -1
- package/dist/utilities/event-listener.test.mjs +3 -2
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +1 -1
- package/dist/utilities/focus-within.test.mjs +3 -2
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +1 -1
- package/dist/utilities/hover.test.mjs +3 -2
- package/dist/utilities/intersection-observer.test.mjs +3 -2
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +1 -1
- package/dist/utilities/interval.test.mjs +3 -2
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +1 -1
- package/dist/utilities/location.test.mjs +2 -1
- package/dist/utilities/long-press.test.mjs +3 -2
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +1 -1
- package/dist/utilities/media-devices.test.mjs +3 -2
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-player.test.mjs +3 -2
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +1 -1
- package/dist/utilities/mutation-observer.test.mjs +3 -2
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.mjs +1 -1
- package/dist/utilities/network.test.mjs +2 -1
- package/dist/utilities/on-click-outside.test.mjs +3 -2
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +1 -1
- package/dist/utilities/previous.test.mjs +3 -2
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/promise.mjs +1 -1
- package/dist/utilities/promise.test.mjs +3 -2
- package/dist/utilities/retry.mjs +1 -1
- package/dist/utilities/retry.test.mjs +3 -2
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +1 -1
- package/dist/utilities/routing.test.mjs +2 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/search-params.test.mjs +3 -2
- package/dist/utilities/ssr.test.mjs +2 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/storage.test.mjs +3 -2
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/throttled.mjs +1 -1
- package/dist/utilities/throttled.test.mjs +3 -2
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +1 -1
- package/dist/utilities/timeout.test.mjs +3 -2
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-focus.mjs +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +1 -1
- package/dist/utilities/window-size.test.mjs +2 -1
- package/package.json +13 -2
- /package/dist/{attributes-DILeh3-s.d.mts → attributes-3r7Diua4.d.mts} +0 -0
- /package/dist/{custom-elements-D5_NMNyD.d.mts → custom-elements-CBuenqVD.d.mts} +0 -0
- /package/dist/{lib-D6duEs38.mjs → lib-CVfOddra.mjs} +0 -0
- /package/dist/{magic-string.es-cTgJnTCj.mjs → magic-string.es-CXefOmkB.mjs} +0 -0
- /package/dist/{polyfill-B1lNNcum.mjs → polyfill-CdZVCxdo.mjs} +0 -0
- /package/dist/{slot-D5iBUSAm.d.mts → slot-CfafCBOW.d.mts} +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { isBrowser } from "./environment.mjs";
|
|
4
|
+
//#region src/utilities/dom-lifecycle.ts
|
|
5
|
+
/**
|
|
6
|
+
* Custom element backing the `<dom-lifecycle>` JSX tag. Place inside any
|
|
7
|
+
* element to receive lifecycle notifications for that surrounding subtree —
|
|
8
|
+
* `onConnect` / `onDisconnect` mirror `connectedCallback` /
|
|
9
|
+
* `disconnectedCallback`, `onMove` mirrors the upcoming `connectedMoveCallback`
|
|
10
|
+
* (fires when the element is moved with `Node.moveBefore()` instead of
|
|
11
|
+
* disconnect+connect), and `onAdopted` mirrors `adoptedCallback`.
|
|
12
|
+
*
|
|
13
|
+
* Position-tracking callbacks (`onConnect` / `onDisconnect` / `onMove`)
|
|
14
|
+
* receive the lifecycle element itself. Read `self.parentElement` for the
|
|
15
|
+
* surrounding element, `self.firstElementChild` / `self.children` for a
|
|
16
|
+
* wrapped subtree, or `self.getRootNode()` to walk through a shadow root.
|
|
17
|
+
* `self` is always the live element — non-null even when the lifecycle
|
|
18
|
+
* element is the root of a shadow tree (where `parentElement` is `null`).
|
|
19
|
+
*
|
|
20
|
+
* If you need the connect-time parent inside `onDisconnect` (the spec sets
|
|
21
|
+
* `parentElement` to `null` before `disconnectedCallback` runs), capture it
|
|
22
|
+
* yourself in `onConnect`.
|
|
23
|
+
*
|
|
24
|
+
* `onConnect` runs inside an `effectScope`, so any `onCleanup` registered
|
|
25
|
+
* inside it (directly or via factories like `setContext`, `on`, observers,
|
|
26
|
+
* etc.) fires on disconnect — before `onDisconnect` is invoked. The scope
|
|
27
|
+
* persists across moves (`onMove`); a fresh scope is created on every
|
|
28
|
+
* reconnection.
|
|
29
|
+
*
|
|
30
|
+
* Layout / a11y inert by default: `display: contents` removes the box so the
|
|
31
|
+
* element doesn't affect its parent's layout, and `role="none"` strips its
|
|
32
|
+
* implicit role from the accessibility tree. Children still participate in
|
|
33
|
+
* both layout and a11y. (CSS structural selectors like `:empty`,
|
|
34
|
+
* `:first-child`, and `:nth-child` still see the element in the DOM tree —
|
|
35
|
+
* place the lifecycle element where those selectors don't reach if needed.)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <div>
|
|
40
|
+
* <dom-lifecycle
|
|
41
|
+
* onConnect={(el) => el.parentElement?.classList.add("ready")}
|
|
42
|
+
* onDisconnect={(el) => {
|
|
43
|
+
* // el.parentElement is null here per spec — stash from onConnect if needed
|
|
44
|
+
* }}
|
|
45
|
+
* />
|
|
46
|
+
* </div>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* Wrap children — read the wrapped subtree via `firstElementChild`:
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <section>
|
|
53
|
+
* <dom-lifecycle onConnect={(el) => measure(el.firstElementChild)}>
|
|
54
|
+
* <h1>Title</h1>
|
|
55
|
+
* <p>Body</p>
|
|
56
|
+
* </dom-lifecycle>
|
|
57
|
+
* </section>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
var DomLifecycleElement = class extends HTMLElement {
|
|
61
|
+
#onConnect = null;
|
|
62
|
+
#onDisconnect = null;
|
|
63
|
+
#onMove = null;
|
|
64
|
+
#onAdopted = null;
|
|
65
|
+
#disposeScope = null;
|
|
66
|
+
constructor() {
|
|
67
|
+
super();
|
|
68
|
+
this.style.display = "contents";
|
|
69
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "none");
|
|
70
|
+
}
|
|
71
|
+
set onConnect(fn) {
|
|
72
|
+
this.#onConnect = fn;
|
|
73
|
+
}
|
|
74
|
+
get onConnect() {
|
|
75
|
+
return this.#onConnect;
|
|
76
|
+
}
|
|
77
|
+
set onDisconnect(fn) {
|
|
78
|
+
this.#onDisconnect = fn;
|
|
79
|
+
}
|
|
80
|
+
get onDisconnect() {
|
|
81
|
+
return this.#onDisconnect;
|
|
82
|
+
}
|
|
83
|
+
set onMove(fn) {
|
|
84
|
+
this.#onMove = fn;
|
|
85
|
+
}
|
|
86
|
+
get onMove() {
|
|
87
|
+
return this.#onMove;
|
|
88
|
+
}
|
|
89
|
+
set onAdopted(fn) {
|
|
90
|
+
this.#onAdopted = fn;
|
|
91
|
+
}
|
|
92
|
+
get onAdopted() {
|
|
93
|
+
return this.#onAdopted;
|
|
94
|
+
}
|
|
95
|
+
connectedCallback() {
|
|
96
|
+
this.#disposeScope?.();
|
|
97
|
+
this.#disposeScope = effectScope(() => this.#onConnect?.(this));
|
|
98
|
+
}
|
|
99
|
+
disconnectedCallback() {
|
|
100
|
+
this.#disposeScope?.();
|
|
101
|
+
this.#disposeScope = null;
|
|
102
|
+
this.#onDisconnect?.(this);
|
|
103
|
+
}
|
|
104
|
+
connectedMoveCallback() {
|
|
105
|
+
this.#onMove?.(this);
|
|
106
|
+
}
|
|
107
|
+
adoptedCallback(oldDocument, newDocument) {
|
|
108
|
+
this.#onAdopted?.(oldDocument, newDocument);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
if (isBrowser && !customElements.get("dom-lifecycle")) customElements.define("dom-lifecycle", DomLifecycleElement);
|
|
112
|
+
//#endregion
|
|
113
|
+
export { DomLifecycleElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
2
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
3
|
+
import { DomLifecycleElement } from "./dom-lifecycle.mjs";
|
|
4
|
+
//#region src/utilities/dom-lifecycle.test.ts
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.innerHTML = "";
|
|
7
|
+
});
|
|
8
|
+
function makeProbe() {
|
|
9
|
+
return document.createElement("dom-lifecycle");
|
|
10
|
+
}
|
|
11
|
+
describe("dom-lifecycle", () => {
|
|
12
|
+
it("registers as a custom element", () => {
|
|
13
|
+
globalExpect(customElements.get("dom-lifecycle")).toBe(DomLifecycleElement);
|
|
14
|
+
globalExpect(makeProbe()).toBeInstanceOf(DomLifecycleElement);
|
|
15
|
+
});
|
|
16
|
+
it("fires onConnect with self; self.parentElement is the surrounding element", () => {
|
|
17
|
+
const parent = document.createElement("div");
|
|
18
|
+
document.body.appendChild(parent);
|
|
19
|
+
const probe = makeProbe();
|
|
20
|
+
const onConnect = vi.fn();
|
|
21
|
+
probe.onConnect = onConnect;
|
|
22
|
+
parent.appendChild(probe);
|
|
23
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
24
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
25
|
+
globalExpect(probe.parentElement).toBe(parent);
|
|
26
|
+
});
|
|
27
|
+
it("does not fire onConnect when appended into a detached subtree", () => {
|
|
28
|
+
const parent = document.createElement("div");
|
|
29
|
+
const probe = makeProbe();
|
|
30
|
+
const onConnect = vi.fn();
|
|
31
|
+
probe.onConnect = onConnect;
|
|
32
|
+
parent.appendChild(probe);
|
|
33
|
+
globalExpect(onConnect).not.toHaveBeenCalled();
|
|
34
|
+
document.body.appendChild(parent);
|
|
35
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
36
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
37
|
+
});
|
|
38
|
+
it("fires onDisconnect with self; self.parentElement is null per spec", () => {
|
|
39
|
+
const parent = document.createElement("div");
|
|
40
|
+
document.body.appendChild(parent);
|
|
41
|
+
const probe = makeProbe();
|
|
42
|
+
const onDisconnect = vi.fn((self) => {
|
|
43
|
+
globalExpect(self.parentElement).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
probe.onDisconnect = onDisconnect;
|
|
46
|
+
parent.appendChild(probe);
|
|
47
|
+
probe.remove();
|
|
48
|
+
globalExpect(onDisconnect).toHaveBeenCalledTimes(1);
|
|
49
|
+
globalExpect(onDisconnect).toHaveBeenCalledWith(probe);
|
|
50
|
+
});
|
|
51
|
+
it("re-fires onConnect on reconnect", () => {
|
|
52
|
+
const parent = document.createElement("div");
|
|
53
|
+
document.body.appendChild(parent);
|
|
54
|
+
const probe = makeProbe();
|
|
55
|
+
const onConnect = vi.fn();
|
|
56
|
+
const onDisconnect = vi.fn();
|
|
57
|
+
probe.onConnect = onConnect;
|
|
58
|
+
probe.onDisconnect = onDisconnect;
|
|
59
|
+
parent.appendChild(probe);
|
|
60
|
+
probe.remove();
|
|
61
|
+
parent.appendChild(probe);
|
|
62
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(2);
|
|
63
|
+
globalExpect(onDisconnect).toHaveBeenCalledTimes(1);
|
|
64
|
+
});
|
|
65
|
+
it("self.parentElement reflects the new parent on cross-parent move", () => {
|
|
66
|
+
const a = document.createElement("section");
|
|
67
|
+
const b = document.createElement("section");
|
|
68
|
+
document.body.appendChild(a);
|
|
69
|
+
document.body.appendChild(b);
|
|
70
|
+
const probe = makeProbe();
|
|
71
|
+
const seen = [];
|
|
72
|
+
probe.onConnect = (el) => seen.push(["c", el.parentElement]);
|
|
73
|
+
probe.onDisconnect = (el) => seen.push(["d", el.parentElement]);
|
|
74
|
+
a.appendChild(probe);
|
|
75
|
+
b.appendChild(probe);
|
|
76
|
+
globalExpect(seen).toEqual([
|
|
77
|
+
["c", a],
|
|
78
|
+
["d", null],
|
|
79
|
+
["c", b]
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
it("works inside an open shadow root", () => {
|
|
83
|
+
const host = document.createElement("div");
|
|
84
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
85
|
+
document.body.appendChild(host);
|
|
86
|
+
const inner = document.createElement("div");
|
|
87
|
+
shadow.appendChild(inner);
|
|
88
|
+
const probe = makeProbe();
|
|
89
|
+
const onConnect = vi.fn((el) => {
|
|
90
|
+
globalExpect(el.parentElement).toBe(inner);
|
|
91
|
+
});
|
|
92
|
+
probe.onConnect = onConnect;
|
|
93
|
+
inner.appendChild(probe);
|
|
94
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
95
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
96
|
+
});
|
|
97
|
+
it("works inside a closed shadow root (no opt-in needed)", () => {
|
|
98
|
+
const host = document.createElement("div");
|
|
99
|
+
const shadow = host.attachShadow({ mode: "closed" });
|
|
100
|
+
document.body.appendChild(host);
|
|
101
|
+
const inner = document.createElement("div");
|
|
102
|
+
shadow.appendChild(inner);
|
|
103
|
+
const probe = makeProbe();
|
|
104
|
+
const onConnect = vi.fn();
|
|
105
|
+
const onDisconnect = vi.fn();
|
|
106
|
+
probe.onConnect = onConnect;
|
|
107
|
+
probe.onDisconnect = onDisconnect;
|
|
108
|
+
inner.appendChild(probe);
|
|
109
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
110
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
111
|
+
inner.remove();
|
|
112
|
+
globalExpect(onDisconnect).toHaveBeenCalledTimes(1);
|
|
113
|
+
globalExpect(onDisconnect).toHaveBeenCalledWith(probe);
|
|
114
|
+
});
|
|
115
|
+
it("self is non-null when the lifecycle element is the direct child of a ShadowRoot", () => {
|
|
116
|
+
const host = document.createElement("div");
|
|
117
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
118
|
+
document.body.appendChild(host);
|
|
119
|
+
const probe = makeProbe();
|
|
120
|
+
let observedSelf = null;
|
|
121
|
+
let observedParent = null;
|
|
122
|
+
let observedHost = null;
|
|
123
|
+
probe.onConnect = (el) => {
|
|
124
|
+
observedSelf = el;
|
|
125
|
+
observedParent = el.parentElement;
|
|
126
|
+
const root = el.getRootNode();
|
|
127
|
+
observedHost = root instanceof ShadowRoot ? root.host : null;
|
|
128
|
+
};
|
|
129
|
+
shadow.appendChild(probe);
|
|
130
|
+
globalExpect(observedSelf).toBe(probe);
|
|
131
|
+
globalExpect(observedParent).toBeNull();
|
|
132
|
+
globalExpect(observedHost).toBe(host);
|
|
133
|
+
});
|
|
134
|
+
it("wrap-children: self.firstElementChild is the wrapped subtree", () => {
|
|
135
|
+
const parent = document.createElement("section");
|
|
136
|
+
document.body.appendChild(parent);
|
|
137
|
+
const probe = makeProbe();
|
|
138
|
+
const wrapped = document.createElement("h1");
|
|
139
|
+
probe.appendChild(wrapped);
|
|
140
|
+
let observedFirstChild = null;
|
|
141
|
+
probe.onConnect = (el) => {
|
|
142
|
+
observedFirstChild = el.firstElementChild;
|
|
143
|
+
};
|
|
144
|
+
parent.appendChild(probe);
|
|
145
|
+
globalExpect(observedFirstChild).toBe(wrapped);
|
|
146
|
+
});
|
|
147
|
+
it("fires when a host with an inner dom-lifecycle is connected later", () => {
|
|
148
|
+
const parent = document.createElement("div");
|
|
149
|
+
const probe = makeProbe();
|
|
150
|
+
const onConnect = vi.fn();
|
|
151
|
+
probe.onConnect = onConnect;
|
|
152
|
+
parent.appendChild(probe);
|
|
153
|
+
globalExpect(onConnect).not.toHaveBeenCalled();
|
|
154
|
+
document.body.appendChild(parent);
|
|
155
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
156
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
157
|
+
});
|
|
158
|
+
it("upgrades when produced via innerHTML and connected", () => {
|
|
159
|
+
const parent = document.createElement("div");
|
|
160
|
+
document.body.appendChild(parent);
|
|
161
|
+
parent.innerHTML = "<dom-lifecycle></dom-lifecycle>";
|
|
162
|
+
const probe = parent.firstElementChild;
|
|
163
|
+
globalExpect(probe).toBeInstanceOf(DomLifecycleElement);
|
|
164
|
+
const onConnect = vi.fn();
|
|
165
|
+
probe.onConnect = onConnect;
|
|
166
|
+
probe.remove();
|
|
167
|
+
parent.appendChild(probe);
|
|
168
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
169
|
+
globalExpect(onConnect).toHaveBeenCalledWith(probe);
|
|
170
|
+
});
|
|
171
|
+
it("survives cloneNode(true) — clone fires its own connect", () => {
|
|
172
|
+
const parent = document.createElement("div");
|
|
173
|
+
document.body.appendChild(parent);
|
|
174
|
+
const original = makeProbe();
|
|
175
|
+
parent.appendChild(original);
|
|
176
|
+
const clone = original.cloneNode(true);
|
|
177
|
+
const onConnect = vi.fn();
|
|
178
|
+
clone.onConnect = onConnect;
|
|
179
|
+
parent.appendChild(clone);
|
|
180
|
+
globalExpect(onConnect).toHaveBeenCalledTimes(1);
|
|
181
|
+
globalExpect(onConnect).toHaveBeenCalledWith(clone);
|
|
182
|
+
});
|
|
183
|
+
it("honors null onConnect / onDisconnect (no throw)", () => {
|
|
184
|
+
const parent = document.createElement("div");
|
|
185
|
+
document.body.appendChild(parent);
|
|
186
|
+
const probe = makeProbe();
|
|
187
|
+
probe.onConnect = null;
|
|
188
|
+
probe.onDisconnect = null;
|
|
189
|
+
globalExpect(() => {
|
|
190
|
+
parent.appendChild(probe);
|
|
191
|
+
probe.remove();
|
|
192
|
+
}).not.toThrow();
|
|
193
|
+
});
|
|
194
|
+
it("applies render-inert defaults: display:contents and role='none'", () => {
|
|
195
|
+
const probe = makeProbe();
|
|
196
|
+
globalExpect(probe.style.display).toBe("contents");
|
|
197
|
+
globalExpect(probe.getAttribute("role")).toBe("none");
|
|
198
|
+
});
|
|
199
|
+
it("exposes onMove and onAdopted setters", () => {
|
|
200
|
+
const probe = makeProbe();
|
|
201
|
+
const move = vi.fn();
|
|
202
|
+
const adopt = vi.fn();
|
|
203
|
+
probe.onMove = move;
|
|
204
|
+
probe.onAdopted = adopt;
|
|
205
|
+
globalExpect(probe.onMove).toBe(move);
|
|
206
|
+
globalExpect(probe.onAdopted).toBe(adopt);
|
|
207
|
+
probe.onMove = null;
|
|
208
|
+
probe.onAdopted = null;
|
|
209
|
+
globalExpect(probe.onMove).toBeNull();
|
|
210
|
+
globalExpect(probe.onAdopted).toBeNull();
|
|
211
|
+
});
|
|
212
|
+
it("disconnects when an ancestor is removed", () => {
|
|
213
|
+
const grand = document.createElement("section");
|
|
214
|
+
const parent = document.createElement("div");
|
|
215
|
+
document.body.appendChild(grand);
|
|
216
|
+
grand.appendChild(parent);
|
|
217
|
+
const probe = makeProbe();
|
|
218
|
+
const onDisconnect = vi.fn();
|
|
219
|
+
probe.onDisconnect = onDisconnect;
|
|
220
|
+
parent.appendChild(probe);
|
|
221
|
+
grand.remove();
|
|
222
|
+
globalExpect(onDisconnect).toHaveBeenCalledTimes(1);
|
|
223
|
+
globalExpect(onDisconnect).toHaveBeenCalledWith(probe);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
//#endregion
|
|
227
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createElementRect } from "./element-rect.mjs";
|
|
5
6
|
//#region src/utilities/element-rect.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createElementScroll } from "./element-scroll.mjs";
|
|
5
6
|
//#region src/utilities/element-scroll.test.ts
|
|
6
7
|
describe("createElementScroll", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as trigger, i as SIGNAL, m as signal, o as computed, p as onCleanup } from "../lib-
|
|
1
|
+
import { h as trigger, i as SIGNAL, m as signal, o as computed, p as onCleanup } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
3
|
//#region src/utilities/event-driven.ts
|
|
4
4
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { c as effectScope, m as signal, s as effect } from "../lib-
|
|
1
|
+
import { c as effectScope, m as signal, s as effect } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
3
|
import { on } from "./event-listener.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
5
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
5
6
|
//#region src/utilities/event-listener.test.ts
|
|
6
7
|
afterEach(() => {
|
|
7
8
|
document.body.innerHTML = "";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createFocusWithin } from "./focus-within.mjs";
|
|
5
6
|
//#region src/utilities/focus-within.test.ts
|
|
6
7
|
afterEach(() => {
|
package/dist/utilities/hover.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createHover } from "./hover.mjs";
|
|
5
6
|
//#region src/utilities/hover.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createIntersectionObserver } from "./intersection-observer.mjs";
|
|
5
6
|
//#region src/utilities/intersection-observer.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { async } from "./async.mjs";
|
|
5
6
|
import { createInterval } from "./interval.mjs";
|
|
6
7
|
//#region src/utilities/interval.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as trigger, m as signal, o as computed, p as onCleanup } from "../lib-
|
|
1
|
+
import { h as trigger, m as signal, o as computed, p as onCleanup } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
3
|
import { fromEvent } from "./event-driven.mjs";
|
|
4
4
|
import { isBrowser } from "./environment.mjs";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
2
|
+
import { t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
2
3
|
import { currentLocation } from "./location.mjs";
|
|
3
4
|
//#region src/utilities/location.test.ts
|
|
4
5
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createLongPress } from "./long-press.mjs";
|
|
5
6
|
//#region src/utilities/long-press.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createMediaDevices } from "./media-devices.mjs";
|
|
5
6
|
//#region src/utilities/media-devices.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createMediaPlayer } from "./media-player.mjs";
|
|
5
6
|
//#region src/utilities/media-player.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { c as effectScope } from "../lib-
|
|
1
|
+
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
4
5
|
import { createMutationObserver } from "./mutation-observer.mjs";
|
|
5
6
|
//#region src/utilities/mutation-observer.test.ts
|
|
6
7
|
afterEach(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-COK1VBpH.mjs";
|
|
2
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-C8YqghE0.mjs";
|
|
2
3
|
import { online } from "./network.mjs";
|
|
3
4
|
//#region src/utilities/network.test.ts
|
|
4
5
|
afterEach(() => {
|