@isoloop/dom 0.0.0-next.56111e3 → 0.0.0-next.5aa1a15
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/{applier-CkaI6Dw-.js → applier-D5wb4gz9.js} +11 -1
- package/dist/{dom-9S5T0UVQ.js → dom-7EzPoV0N.js} +20 -1
- package/dist/{dom-BrJVEi7G.d.ts → dom-ANUAQHqi.d.ts} +12 -1
- package/dist/host.d.ts +1 -1
- package/dist/host.js +1 -1
- package/dist/{install-DBKGtAel.js → install-DE1VIvyG.js} +1 -1
- package/dist/{records-2Jf3U4Sp.d.ts → records-OXGckMg9.d.ts} +3 -0
- package/dist/testing-worker.d.ts +2 -2
- package/dist/testing-worker.js +2 -2
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +2 -2
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ function createApplier(container, policy) {
|
|
|
17
17
|
const nodes = /* @__PURE__ */ new Map([[0, container]]);
|
|
18
18
|
const ids = new WeakMap([[container, 0]]);
|
|
19
19
|
const listens = /* @__PURE__ */ new Map();
|
|
20
|
+
const known = /* @__PURE__ */ new WeakMap();
|
|
20
21
|
const setAttr = (el, name, value) => {
|
|
21
22
|
const safe = value === null ? null : policy.attribute(el.localName, nsOf(el), name, value);
|
|
22
23
|
try {
|
|
@@ -25,6 +26,7 @@ function createApplier(container, policy) {
|
|
|
25
26
|
} catch {}
|
|
26
27
|
};
|
|
27
28
|
const setProp = (el, name, value, force = false) => {
|
|
29
|
+
if (name === "checked") known.set(el, Boolean(value));
|
|
28
30
|
if (!policy.property(el, name, value, force)) return;
|
|
29
31
|
if (name === "checked" && el instanceof HTMLInputElement) el.checked = Boolean(value);
|
|
30
32
|
else if (name === "selected" && el instanceof HTMLOptionElement) el.selected = Boolean(value);
|
|
@@ -160,7 +162,11 @@ function createApplier(container, policy) {
|
|
|
160
162
|
};
|
|
161
163
|
const el = nodes.get(target);
|
|
162
164
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) out.value = el.value;
|
|
163
|
-
if (el instanceof HTMLInputElement &&
|
|
165
|
+
if (el instanceof HTMLInputElement && el.type === "radio") out.checked = el.checked;
|
|
166
|
+
else if (el instanceof HTMLInputElement && el.type === "checkbox" && known.get(el) !== el.checked) {
|
|
167
|
+
out.checked = el.checked;
|
|
168
|
+
known.set(el, el.checked);
|
|
169
|
+
}
|
|
164
170
|
if (e instanceof MouseEvent || e instanceof KeyboardEvent) out.mods = {
|
|
165
171
|
alt: e.altKey,
|
|
166
172
|
ctrl: e.ctrlKey,
|
|
@@ -171,6 +177,10 @@ function createApplier(container, policy) {
|
|
|
171
177
|
out.key = e.key;
|
|
172
178
|
out.code = e.code;
|
|
173
179
|
}
|
|
180
|
+
if (e.type === "scroll" && el instanceof Element) {
|
|
181
|
+
out.scrollTop = el.scrollTop;
|
|
182
|
+
out.scrollLeft = el.scrollLeft;
|
|
183
|
+
}
|
|
174
184
|
if (e instanceof MouseEvent) {
|
|
175
185
|
out.x = e.clientX;
|
|
176
186
|
out.y = e.clientY;
|
|
@@ -528,6 +528,11 @@ var WElement = class extends WParentNode {
|
|
|
528
528
|
/** @internal */ isoStyle = null;
|
|
529
529
|
/** @internal */ isoClassList = null;
|
|
530
530
|
/** @internal */ isoDataset = null;
|
|
531
|
+
/** @internal The offsets the last `scroll` event brought (design §4.6). */
|
|
532
|
+
isoScroll = {
|
|
533
|
+
top: 0,
|
|
534
|
+
left: 0
|
|
535
|
+
};
|
|
531
536
|
constructor(doc, id, localName, ns) {
|
|
532
537
|
super(doc, id);
|
|
533
538
|
this.localName = localName;
|
|
@@ -594,6 +599,16 @@ var WElement = class extends WParentNode {
|
|
|
594
599
|
this.isoDataset ??= createDataset(this);
|
|
595
600
|
return this.isoDataset;
|
|
596
601
|
}
|
|
602
|
+
/**
|
|
603
|
+
* Read only, and as of the last `scroll` event the element got: the host
|
|
604
|
+
* owns scrolling. 0 until the element is scrolled and listens for `scroll`.
|
|
605
|
+
*/
|
|
606
|
+
get scrollTop() {
|
|
607
|
+
return this.isoScroll.top;
|
|
608
|
+
}
|
|
609
|
+
get scrollLeft() {
|
|
610
|
+
return this.isoScroll.left;
|
|
611
|
+
}
|
|
597
612
|
get id() {
|
|
598
613
|
return this.getAttribute("id") ?? "";
|
|
599
614
|
}
|
|
@@ -1016,6 +1031,10 @@ function createDom(opts) {
|
|
|
1016
1031
|
if (!node) return;
|
|
1017
1032
|
if ((node instanceof WHTMLInputElement || node instanceof WHTMLTextAreaElement || node instanceof WHTMLSelectElement) && event.value !== void 0) node.isoSetProp("value", event.value, false);
|
|
1018
1033
|
if (node instanceof WHTMLInputElement && event.checked !== void 0) node.isoSetProp("checked", event.checked, false);
|
|
1034
|
+
if (event.type === "scroll" && node instanceof WElement) node.isoScroll = {
|
|
1035
|
+
top: event.scrollTop ?? 0,
|
|
1036
|
+
left: event.scrollLeft ?? 0
|
|
1037
|
+
};
|
|
1019
1038
|
node.dispatchEvent(toEvent(event));
|
|
1020
1039
|
}
|
|
1021
1040
|
};
|
|
@@ -1023,7 +1042,7 @@ function createDom(opts) {
|
|
|
1023
1042
|
/** A real `Event` with the fields frameworks read from mouse and keyboard events. */
|
|
1024
1043
|
function toEvent(e) {
|
|
1025
1044
|
const ev = new Event(e.type, {
|
|
1026
|
-
bubbles:
|
|
1045
|
+
bubbles: e.type !== "scroll",
|
|
1027
1046
|
cancelable: true
|
|
1028
1047
|
});
|
|
1029
1048
|
const mods = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as DomRecord, n as DomEvent, o as Namespace, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-
|
|
1
|
+
import { i as DomRecord, n as DomEvent, o as Namespace, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
|
|
2
2
|
type ListenerFn = (event: Event) => void;
|
|
3
3
|
type Listener = {
|
|
4
4
|
fn: ListenerFn | {
|
|
@@ -165,6 +165,11 @@ declare class WElement extends WParentNode {
|
|
|
165
165
|
/** @internal */ isoStyle: WStyle | null;
|
|
166
166
|
/** @internal */ isoClassList: WDOMTokenList | null;
|
|
167
167
|
/** @internal */ isoDataset: Record<string, string | undefined> | null;
|
|
168
|
+
/** @internal The offsets the last `scroll` event brought (design §4.6). */
|
|
169
|
+
isoScroll: {
|
|
170
|
+
top: number;
|
|
171
|
+
left: number;
|
|
172
|
+
};
|
|
168
173
|
constructor(doc: WDocument, id: NodeId, localName: string, ns: Namespace);
|
|
169
174
|
get tagName(): string;
|
|
170
175
|
get nodeName(): string;
|
|
@@ -183,6 +188,12 @@ declare class WElement extends WParentNode {
|
|
|
183
188
|
get style(): WStyle;
|
|
184
189
|
get classList(): WDOMTokenList;
|
|
185
190
|
get dataset(): Record<string, string | undefined>;
|
|
191
|
+
/**
|
|
192
|
+
* Read only, and as of the last `scroll` event the element got: the host
|
|
193
|
+
* owns scrolling. 0 until the element is scrolled and listens for `scroll`.
|
|
194
|
+
*/
|
|
195
|
+
get scrollTop(): number;
|
|
196
|
+
get scrollLeft(): number;
|
|
186
197
|
get id(): string;
|
|
187
198
|
set id(v: string);
|
|
188
199
|
/** @internal */ isoSetProp(name: SyncedProp, value: string | boolean, record: boolean): void;
|
package/dist/host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, d as isDomBatch, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-
|
|
1
|
+
import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, d as isDomBatch, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
|
|
2
2
|
/** Decides what the applier may create and write. Supplied by the host; required. */
|
|
3
3
|
interface SanitisePolicy {
|
|
4
4
|
/** The host element to create for an isolate's tag. */
|
package/dist/host.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as ROOT_ID, r as isDomBatch, t as ISOLOOP_DOM_FMT } from "./records-wVZrPpqr.js";
|
|
2
|
-
import { t as createApplier } from "./applier-
|
|
2
|
+
import { t as createApplier } from "./applier-D5wb4gz9.js";
|
|
3
3
|
export { ISOLOOP_DOM_FMT, ROOT_ID, createApplier, isDomBatch };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as WText, a as WDocumentFragment, c as WHTMLElement, d as WHTMLOptionElement, f as WHTMLSelectElement, g as WSVGElement, l as WHTMLIFrameElement, m as WNode, n as WComment, o as WElement, p as WHTMLTextAreaElement, r as WDOMTokenList, u as WHTMLInputElement } from "./dom-
|
|
1
|
+
import { _ as WText, a as WDocumentFragment, c as WHTMLElement, d as WHTMLOptionElement, f as WHTMLSelectElement, g as WSVGElement, l as WHTMLIFrameElement, m as WNode, n as WComment, o as WElement, p as WHTMLTextAreaElement, r as WDOMTokenList, u as WHTMLInputElement } from "./dom-7EzPoV0N.js";
|
|
2
2
|
// src/worker/install.ts
|
|
3
3
|
/** The DOM globals the subset provides (ADR 0010 point 2), by their DOM names. */
|
|
4
4
|
const DOM_GLOBALS = {
|
|
@@ -52,6 +52,9 @@ type DomEvent = {
|
|
|
52
52
|
/** For `resize` on a transferred canvas: its new CSS size (design §4.7). */
|
|
53
53
|
width?: number;
|
|
54
54
|
height?: number;
|
|
55
|
+
/** For `scroll`: the scrolled element's offsets, mirrored on the worker node. */
|
|
56
|
+
scrollTop?: number;
|
|
57
|
+
scrollLeft?: number;
|
|
55
58
|
};
|
|
56
59
|
/** The batch comes from an isolate, so its shape is checked before anything touches the DOM. */
|
|
57
60
|
declare function isDomBatch(x: unknown): x is DomBatch;
|
package/dist/testing-worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as DomBatch } from "./records-
|
|
2
|
-
import { s as WorkerDom } from "./dom-
|
|
1
|
+
import { t as DomBatch } from "./records-OXGckMg9.js";
|
|
2
|
+
import { s as WorkerDom } from "./dom-ANUAQHqi.js";
|
|
3
3
|
/** One framework major's log, as `packages/dom/usage/<project>.json` stores it. */
|
|
4
4
|
export type UsageLog = {
|
|
5
5
|
/** E.g. `preact@10.29.8`. */
|
package/dist/testing-worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as install, t as DOM_GLOBALS } from "./install-
|
|
2
|
-
import { h as WParentNode, i as WDocument, o as WElement, s as WEventTarget, t as WCharacterData, v as createDom } from "./dom-
|
|
1
|
+
import { n as install, t as DOM_GLOBALS } from "./install-DE1VIvyG.js";
|
|
2
|
+
import { h as WParentNode, i as WDocument, o as WElement, s as WEventTarget, t as WCharacterData, v as createDom } from "./dom-7EzPoV0N.js";
|
|
3
3
|
// src/testing/worker.ts
|
|
4
4
|
/** Everything a framework sees: the classes `install()` exposes, and `document`. */
|
|
5
5
|
const CLASSES = [
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as WorkerDom } from "./dom-
|
|
1
|
+
import { s as WorkerDom } from "./dom-ANUAQHqi.js";
|
|
2
2
|
import { FixtureMessage, UsageLog } from "./testing-worker.js";
|
|
3
3
|
/** An event as a host bridge sends it to the isolate, reduced to what the suite reads. */
|
|
4
4
|
type ConformanceEvent = {
|
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as WParentNode, o as WElement, t as WCharacterData, v as createDom } from "./dom-
|
|
2
|
-
import { t as createApplier } from "./applier-
|
|
1
|
+
import { h as WParentNode, o as WElement, t as WCharacterData, v as createDom } from "./dom-7EzPoV0N.js";
|
|
2
|
+
import { t as createApplier } from "./applier-D5wb4gz9.js";
|
|
3
3
|
import { afterEach, describe, expect, it } from "vitest";
|
|
4
4
|
import { commands } from "vitest/browser";
|
|
5
5
|
// src/testing/conformance.ts
|
package/dist/worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-
|
|
2
|
-
import { a as WNode, c as WorkerDomOptions, i as WElement, l as createDom, n as WDocument, o as WText, r as WDocumentFragment, s as WorkerDom, t as WComment } from "./dom-
|
|
1
|
+
import { a as ISOLOOP_DOM_FMT, c as ROOT_ID, i as DomRecord, l as SerializedNode, n as DomEvent, o as Namespace, r as DomMods, s as NodeId, t as DomBatch, u as SyncedProp } from "./records-OXGckMg9.js";
|
|
2
|
+
import { a as WNode, c as WorkerDomOptions, i as WElement, l as createDom, n as WDocument, o as WText, r as WDocumentFragment, s as WorkerDom, t as WComment } from "./dom-ANUAQHqi.js";
|
|
3
3
|
/** The DOM globals the subset provides (ADR 0010 point 2), by their DOM names. */
|
|
4
4
|
export declare const DOM_GLOBALS: Readonly<Record<string, unknown>>;
|
|
5
5
|
/**
|
package/dist/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as ROOT_ID, t as ISOLOOP_DOM_FMT } from "./records-wVZrPpqr.js";
|
|
2
|
-
import { _ as WText, a as WDocumentFragment, i as WDocument, m as WNode, n as WComment, o as WElement, v as createDom } from "./dom-
|
|
3
|
-
import { n as install, t as DOM_GLOBALS } from "./install-
|
|
2
|
+
import { _ as WText, a as WDocumentFragment, i as WDocument, m as WNode, n as WComment, o as WElement, v as createDom } from "./dom-7EzPoV0N.js";
|
|
3
|
+
import { n as install, t as DOM_GLOBALS } from "./install-DE1VIvyG.js";
|
|
4
4
|
export { DOM_GLOBALS, ISOLOOP_DOM_FMT, ROOT_ID, WComment, WDocument, WDocumentFragment, WElement, WNode, WText, createDom, install };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isoloop/dom",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.5aa1a15",
|
|
4
4
|
"description": "Internal: Isoloop's render bridge (isoloop-dom@1). Used by @isoloop/runtime and @isoloop/host; not for app code.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|