@solidjs/web 2.0.0-beta.12 → 2.0.0-beta.14
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/dev.cjs +225 -93
- package/dist/dev.js +221 -93
- package/dist/server.cjs +41 -1
- package/dist/server.js +32 -1
- package/dist/web.cjs +224 -92
- package/dist/web.js +220 -92
- package/package.json +3 -3
- package/types/client.d.ts +14 -11
- package/types/jsx-properties.d.ts +1 -0
- package/types/jsx.d.ts +21 -211
- package/types/server.d.ts +26 -7
- package/types-cjs/client.d.cts +14 -11
- package/types-cjs/jsx-properties.d.cts +1 -0
- package/types-cjs/jsx.d.cts +21 -211
- package/types-cjs/server.d.cts +26 -7
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, enableHydration, flush } from 'solid-js';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createEffect, enableHydration, flush } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
const DOMWithState = {
|
|
@@ -30,6 +30,7 @@ const DOMWithState = {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
33
34
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
34
35
|
const SVGElements = /*#__PURE__*/new Set([
|
|
35
36
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -63,14 +64,18 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
|
|
|
63
64
|
} : transparentOptions);
|
|
64
65
|
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
65
66
|
|
|
66
|
-
function reconcileArrays(parentNode, a, b) {
|
|
67
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
67
68
|
let bLength = b.length,
|
|
68
69
|
aEnd = a.length,
|
|
69
70
|
bEnd = bLength,
|
|
70
71
|
aStart = 0,
|
|
71
72
|
bStart = 0,
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
tail = a[aEnd - 1],
|
|
74
|
+
tailTag = tail[$$SLOT],
|
|
75
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
76
|
+
map = null,
|
|
77
|
+
anchor,
|
|
78
|
+
anchorTag;
|
|
74
79
|
while (aStart < aEnd || bStart < bEnd) {
|
|
75
80
|
if (a[aStart] === b[bStart]) {
|
|
76
81
|
aStart++;
|
|
@@ -82,20 +87,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
82
87
|
bEnd--;
|
|
83
88
|
}
|
|
84
89
|
if (aEnd === aStart) {
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
let node;
|
|
91
|
+
if (bEnd < bLength) {
|
|
92
|
+
if (bStart) {
|
|
93
|
+
const prev = b[bStart - 1];
|
|
94
|
+
const prevTag = prev[$$SLOT];
|
|
95
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
96
|
+
} else node = b[bEnd - bStart];
|
|
97
|
+
} else node = after;
|
|
98
|
+
while (bStart < bEnd) {
|
|
99
|
+
const n = b[bStart++];
|
|
100
|
+
parentNode.insertBefore(n, node);
|
|
101
|
+
if (marker) n[$$SLOT] = marker;
|
|
102
|
+
}
|
|
87
103
|
} else if (bEnd === bStart) {
|
|
88
104
|
while (aStart < aEnd) {
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
const n = a[aStart++];
|
|
106
|
+
if (!map || !map.has(n)) {
|
|
107
|
+
const tag = n[$$SLOT];
|
|
108
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
112
|
+
if (marker) {
|
|
113
|
+
do {
|
|
114
|
+
const n = a[--aEnd];
|
|
115
|
+
parentNode.insertBefore(n, anchor);
|
|
116
|
+
n[$$SLOT] = marker;
|
|
117
|
+
bStart++;
|
|
118
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
119
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
120
|
+
} else {
|
|
121
|
+
do {
|
|
122
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
123
|
+
bStart++;
|
|
124
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
125
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
91
126
|
}
|
|
92
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
93
|
-
const anchor = a[aStart];
|
|
94
|
-
do {
|
|
95
|
-
parentNode.insertBefore(a[--aEnd], anchor);
|
|
96
|
-
bStart++;
|
|
97
|
-
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
98
|
-
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
99
127
|
} else {
|
|
100
128
|
if (!map) {
|
|
101
129
|
map = new Map();
|
|
@@ -113,35 +141,64 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
113
141
|
sequence++;
|
|
114
142
|
}
|
|
115
143
|
if (sequence > index - bStart) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
const head = a[aStart];
|
|
145
|
+
const headTag = head[$$SLOT];
|
|
146
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
147
|
+
while (bStart < index) {
|
|
148
|
+
const n = b[bStart++];
|
|
149
|
+
parentNode.insertBefore(n, node);
|
|
150
|
+
if (marker) n[$$SLOT] = marker;
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
const oldNode = a[aStart++];
|
|
154
|
+
const newNode = b[bStart++];
|
|
155
|
+
const oldTag = oldNode[$$SLOT];
|
|
156
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
157
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
158
|
+
} else {
|
|
159
|
+
parentNode.insertBefore(newNode, after);
|
|
160
|
+
}
|
|
161
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
162
|
+
}
|
|
119
163
|
} else aStart++;
|
|
120
|
-
} else
|
|
164
|
+
} else {
|
|
165
|
+
const n = a[aStart++];
|
|
166
|
+
const nTag = n[$$SLOT];
|
|
167
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
168
|
+
}
|
|
121
169
|
}
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
172
|
|
|
125
|
-
const $$
|
|
173
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
126
174
|
const INNER_OWNED = {};
|
|
175
|
+
const delegatedEvents = new Set();
|
|
176
|
+
const delegatedContainers = new Map();
|
|
127
177
|
function render$1(code, element, init, options = {}) {
|
|
128
|
-
const renderRoot = getChildRoot(element);
|
|
129
178
|
let disposer;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
179
|
+
registerDelegatedRoot(element);
|
|
180
|
+
try {
|
|
181
|
+
createRoot(dispose => {
|
|
182
|
+
disposer = dispose;
|
|
183
|
+
if (element === document) {
|
|
184
|
+
const tree = code();
|
|
185
|
+
effect(() => flatten(tree), () => {});
|
|
186
|
+
} else {
|
|
187
|
+
const tree = code();
|
|
188
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
id: options.renderId
|
|
192
|
+
});
|
|
193
|
+
} catch (err) {
|
|
194
|
+
if (disposer) disposer();
|
|
195
|
+
unregisterDelegatedRoot(element);
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
142
198
|
return () => {
|
|
143
199
|
disposer();
|
|
144
|
-
|
|
200
|
+
unregisterDelegatedRoot(element);
|
|
201
|
+
element.textContent = "";
|
|
145
202
|
};
|
|
146
203
|
}
|
|
147
204
|
function create(html, bypassGuard, flag) {
|
|
@@ -154,20 +211,66 @@ function template(html, flag) {
|
|
|
154
211
|
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
155
212
|
return fn;
|
|
156
213
|
}
|
|
157
|
-
function delegateEvents(eventNames
|
|
158
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
214
|
+
function delegateEvents(eventNames) {
|
|
159
215
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
160
216
|
const name = eventNames[i];
|
|
161
|
-
if (!
|
|
162
|
-
|
|
163
|
-
|
|
217
|
+
if (!delegatedEvents.has(name)) {
|
|
218
|
+
delegatedEvents.add(name);
|
|
219
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
164
220
|
}
|
|
165
221
|
}
|
|
166
222
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
223
|
+
function registerDelegatedRoot(root) {
|
|
224
|
+
const state = registerDelegatedContainer(root, root);
|
|
225
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
226
|
+
}
|
|
227
|
+
function unregisterDelegatedRoot(root) {
|
|
228
|
+
const state = delegatedContainers.get(root);
|
|
229
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
230
|
+
unregisterDelegatedContainer(root, root);
|
|
231
|
+
}
|
|
232
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
233
|
+
if (!container || !owner) return;
|
|
234
|
+
let state = delegatedContainers.get(container);
|
|
235
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
236
|
+
owners: new Map(),
|
|
237
|
+
handlers: new Map()
|
|
238
|
+
});
|
|
239
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
240
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
241
|
+
return state;
|
|
242
|
+
}
|
|
243
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
244
|
+
const state = delegatedContainers.get(container);
|
|
245
|
+
if (!state) return;
|
|
246
|
+
const count = state.owners.get(owner);
|
|
247
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
248
|
+
if (state.owners.size) return;
|
|
249
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
250
|
+
delegatedContainers.delete(container);
|
|
251
|
+
}
|
|
252
|
+
function attachDelegatedEvent(name, container, state) {
|
|
253
|
+
if (state.handlers.has(name)) return;
|
|
254
|
+
const handler = e => eventHandler(e, container, state);
|
|
255
|
+
state.handlers.set(name, handler);
|
|
256
|
+
container.addEventListener(name, handler);
|
|
257
|
+
}
|
|
258
|
+
function getDelegatedRoot(node) {
|
|
259
|
+
while (node) {
|
|
260
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
261
|
+
node = node._$host || node.parentNode || node.host;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function findOwner(target, state) {
|
|
265
|
+
let node = target;
|
|
266
|
+
let distance = 0;
|
|
267
|
+
while (node) {
|
|
268
|
+
if (state.owners.has(node)) return {
|
|
269
|
+
owner: node,
|
|
270
|
+
distance
|
|
271
|
+
};
|
|
272
|
+
distance++;
|
|
273
|
+
node = node._$host || node.parentNode || node.host;
|
|
171
274
|
}
|
|
172
275
|
}
|
|
173
276
|
function setProperty(node, name, value) {
|
|
@@ -212,7 +315,7 @@ function className(node, value, prev) {
|
|
|
212
315
|
node.classList.add(key);
|
|
213
316
|
}
|
|
214
317
|
}
|
|
215
|
-
function
|
|
318
|
+
function addEvent(node, name, handler, delegate) {
|
|
216
319
|
if (delegate) {
|
|
217
320
|
if (Array.isArray(handler)) {
|
|
218
321
|
node[`$$${name}`] = handler[0];
|
|
@@ -278,11 +381,10 @@ function ref(fn, element) {
|
|
|
278
381
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
279
382
|
}
|
|
280
383
|
function insert(parent, accessor, marker, initial, options) {
|
|
281
|
-
const childRoot = getChildRoot(parent);
|
|
282
384
|
const multi = marker !== undefined;
|
|
283
385
|
if (multi && !initial) initial = [];
|
|
284
386
|
if (isHydrating(parent)) {
|
|
285
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
387
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
286
388
|
if (Array.isArray(initial)) {
|
|
287
389
|
let j = 0;
|
|
288
390
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -297,7 +399,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
297
399
|
}
|
|
298
400
|
if (multi && initial.length === 0) {
|
|
299
401
|
const placeholder = document.createTextNode("");
|
|
300
|
-
|
|
402
|
+
parent.insertBefore(placeholder, marker);
|
|
301
403
|
initial = [placeholder];
|
|
302
404
|
}
|
|
303
405
|
let current = initial;
|
|
@@ -352,7 +454,7 @@ function loadModuleAssets(mapping) {
|
|
|
352
454
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
353
455
|
}
|
|
354
456
|
function hydrate$1(code, element, options = {}) {
|
|
355
|
-
if (globalThis._$HY.done) return render$1(code, element, [...
|
|
457
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
356
458
|
options.renderId ||= "";
|
|
357
459
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
358
460
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -388,7 +490,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
388
490
|
let disposer;
|
|
389
491
|
p.then(() => {
|
|
390
492
|
try {
|
|
391
|
-
disposer = render$1(code, element, [...
|
|
493
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
392
494
|
} finally {
|
|
393
495
|
sharedConfig.hydrating = false;
|
|
394
496
|
}
|
|
@@ -400,7 +502,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
400
502
|
}
|
|
401
503
|
try {
|
|
402
504
|
gatherHydratable(element, options.renderId);
|
|
403
|
-
return render$1(code, element, [...
|
|
505
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
404
506
|
} finally {
|
|
405
507
|
sharedConfig.hydrating = false;
|
|
406
508
|
}
|
|
@@ -443,7 +545,7 @@ function getNextMarker(start) {
|
|
|
443
545
|
return [end, current];
|
|
444
546
|
}
|
|
445
547
|
function getFirstChild(node, expectedTag) {
|
|
446
|
-
const child =
|
|
548
|
+
const child = node.firstChild;
|
|
447
549
|
return child;
|
|
448
550
|
}
|
|
449
551
|
function getNextSibling(node, expectedTag) {
|
|
@@ -463,7 +565,17 @@ function runHydrationEvents() {
|
|
|
463
565
|
const [el, e] = events[0];
|
|
464
566
|
if (!completed.has(el)) return;
|
|
465
567
|
events.shift();
|
|
466
|
-
|
|
568
|
+
let match;
|
|
569
|
+
for (const [container, state] of delegatedContainers) {
|
|
570
|
+
if (!state.handlers.has(e.type)) continue;
|
|
571
|
+
const entry = findOwner(e.target, state);
|
|
572
|
+
if (entry && (!match || entry.distance < match.distance)) match = {
|
|
573
|
+
container,
|
|
574
|
+
state,
|
|
575
|
+
distance: entry.distance
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
if (match) eventHandler(e, match.container, match.state);
|
|
467
579
|
}
|
|
468
580
|
if (sharedConfig.done) {
|
|
469
581
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -476,9 +588,6 @@ function runHydrationEvents() {
|
|
|
476
588
|
function isHydrating(node) {
|
|
477
589
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
478
590
|
}
|
|
479
|
-
function getChildRoot(node) {
|
|
480
|
-
return node && node.localName === "template" ? node.content : node;
|
|
481
|
-
}
|
|
482
591
|
function classListToObject(classList) {
|
|
483
592
|
if (Array.isArray(classList)) {
|
|
484
593
|
const result = {};
|
|
@@ -513,11 +622,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
513
622
|
return value;
|
|
514
623
|
}
|
|
515
624
|
const hasNamespace = prop.indexOf(":") > -1;
|
|
516
|
-
if (hasNamespace && prop.slice(0,
|
|
517
|
-
const e = prop.slice(3);
|
|
518
|
-
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
519
|
-
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
520
|
-
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
625
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
521
626
|
const name = prop.slice(2).toLowerCase();
|
|
522
627
|
const delegate = DelegatedEvents.has(name);
|
|
523
628
|
if (!delegate && prev) {
|
|
@@ -525,7 +630,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
525
630
|
node.removeEventListener(name, h);
|
|
526
631
|
}
|
|
527
632
|
if (delegate || value) {
|
|
528
|
-
|
|
633
|
+
addEvent(node, name, value, delegate);
|
|
529
634
|
delegate && delegateEvents([name]);
|
|
530
635
|
}
|
|
531
636
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
@@ -537,14 +642,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
537
642
|
}
|
|
538
643
|
return value;
|
|
539
644
|
}
|
|
540
|
-
function eventHandler(e) {
|
|
645
|
+
function eventHandler(e, container, state) {
|
|
541
646
|
if (sharedConfig.registry && sharedConfig.events) {
|
|
542
647
|
if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
543
648
|
}
|
|
649
|
+
if (e[$$EVENT_OWNER]) return;
|
|
650
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
651
|
+
if (state && !owner) return;
|
|
652
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
544
653
|
let node = e.target;
|
|
545
654
|
const key = `$$${e.type}`;
|
|
546
655
|
const oriTarget = e.target;
|
|
547
|
-
const
|
|
656
|
+
const boundary = owner || container || e.currentTarget;
|
|
548
657
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
549
658
|
configurable: true,
|
|
550
659
|
value
|
|
@@ -560,29 +669,34 @@ function eventHandler(e) {
|
|
|
560
669
|
return true;
|
|
561
670
|
};
|
|
562
671
|
const walkUpTree = () => {
|
|
563
|
-
while (handleNode()
|
|
672
|
+
while (handleNode()) {
|
|
673
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
674
|
+
node = node._$host || node.parentNode || node.host;
|
|
675
|
+
}
|
|
564
676
|
};
|
|
565
677
|
Object.defineProperty(e, "currentTarget", {
|
|
566
678
|
configurable: true,
|
|
567
679
|
get() {
|
|
568
|
-
return node || document;
|
|
680
|
+
return node || boundary || document;
|
|
569
681
|
}
|
|
570
682
|
});
|
|
571
683
|
if (e.composedPath) {
|
|
572
684
|
const path = e.composedPath();
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
685
|
+
if (path.length) {
|
|
686
|
+
retarget(path[0]);
|
|
687
|
+
for (let i = 0; i < path.length; i++) {
|
|
688
|
+
node = path[i];
|
|
689
|
+
if (!handleNode()) break;
|
|
690
|
+
if (node._$host) {
|
|
691
|
+
node = node._$host;
|
|
692
|
+
walkUpTree();
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
584
698
|
}
|
|
585
|
-
}
|
|
699
|
+
} else walkUpTree();
|
|
586
700
|
}
|
|
587
701
|
else walkUpTree();
|
|
588
702
|
retarget(oriTarget);
|
|
@@ -590,22 +704,26 @@ function eventHandler(e) {
|
|
|
590
704
|
function insertExpression(parent, value, current, marker) {
|
|
591
705
|
if (isHydrating(parent)) return;
|
|
592
706
|
if (value === current) return;
|
|
593
|
-
const childRoot = getChildRoot(parent);
|
|
594
707
|
const t = typeof value,
|
|
595
708
|
multi = marker !== undefined;
|
|
596
709
|
if (t === "string" || t === "number") {
|
|
597
710
|
const tc = typeof current;
|
|
598
711
|
if (tc === "string" || tc === "number") {
|
|
599
|
-
|
|
600
|
-
} else
|
|
712
|
+
parent.firstChild.data = value;
|
|
713
|
+
} else parent.textContent = value;
|
|
601
714
|
} else if (value === undefined) {
|
|
602
715
|
cleanChildren(parent, current, marker);
|
|
603
716
|
} else if (value.nodeType) {
|
|
604
717
|
if (Array.isArray(current)) {
|
|
605
718
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
606
|
-
} else if (current
|
|
607
|
-
|
|
608
|
-
} else
|
|
719
|
+
} else if (current && current.nodeType) {
|
|
720
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
721
|
+
} else if (current && parent.firstChild) {
|
|
722
|
+
parent.replaceChild(value, parent.firstChild);
|
|
723
|
+
} else {
|
|
724
|
+
parent.appendChild(value);
|
|
725
|
+
}
|
|
726
|
+
if (marker) value[$$SLOT] = marker;
|
|
609
727
|
} else if (Array.isArray(value)) {
|
|
610
728
|
const currentArray = current && Array.isArray(current);
|
|
611
729
|
if (value.length === 0) {
|
|
@@ -613,7 +731,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
613
731
|
} else if (currentArray) {
|
|
614
732
|
if (current.length === 0) {
|
|
615
733
|
appendNodes(parent, value, marker);
|
|
616
|
-
} else reconcileArrays(
|
|
734
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
617
735
|
} else {
|
|
618
736
|
current && cleanChildren(parent);
|
|
619
737
|
appendNodes(parent, value);
|
|
@@ -638,22 +756,26 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
638
756
|
return value;
|
|
639
757
|
}
|
|
640
758
|
function appendNodes(parent, array, marker = null) {
|
|
641
|
-
|
|
642
|
-
|
|
759
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
760
|
+
const n = array[i];
|
|
761
|
+
parent.insertBefore(n, marker);
|
|
762
|
+
if (marker) n[$$SLOT] = marker;
|
|
763
|
+
}
|
|
643
764
|
}
|
|
644
765
|
function cleanChildren(parent, current, marker, replacement) {
|
|
645
|
-
parent = getChildRoot(parent);
|
|
646
766
|
if (marker === undefined) return parent.textContent = "";
|
|
647
767
|
if (current.length) {
|
|
648
768
|
let inserted = false;
|
|
649
769
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
650
770
|
const el = current[i];
|
|
651
771
|
if (replacement !== el) {
|
|
652
|
-
const
|
|
653
|
-
|
|
772
|
+
const tag = el[$$SLOT];
|
|
773
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
774
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
654
775
|
} else inserted = true;
|
|
655
776
|
}
|
|
656
777
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
778
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
657
779
|
}
|
|
658
780
|
function gatherHydratable(element, root) {
|
|
659
781
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -715,8 +837,8 @@ function Portal(props) {
|
|
|
715
837
|
const treeMarker = document.createTextNode(""),
|
|
716
838
|
startMarker = document.createTextNode(""),
|
|
717
839
|
endMarker = document.createTextNode(""),
|
|
718
|
-
mount = () => createElementProxy(props.mount || document.body, treeMarker)
|
|
719
|
-
|
|
840
|
+
mount = () => createElementProxy(props.mount || document.body, treeMarker),
|
|
841
|
+
content = createMemo(() => [startMarker, props.children]);
|
|
720
842
|
createRenderEffect(() => [mount(), content()], ([m, c]) => {
|
|
721
843
|
m.appendChild(endMarker);
|
|
722
844
|
insert(m, c, endMarker);
|
|
@@ -729,6 +851,12 @@ function Portal(props) {
|
|
|
729
851
|
}
|
|
730
852
|
};
|
|
731
853
|
});
|
|
854
|
+
createEffect(mount, m => {
|
|
855
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
856
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
857
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
858
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
859
|
+
});
|
|
732
860
|
return treeMarker;
|
|
733
861
|
}
|
|
734
862
|
function dynamic(source) {
|
|
@@ -776,4 +904,4 @@ function createElementProxy(el, marker) {
|
|
|
776
904
|
});
|
|
777
905
|
}
|
|
778
906
|
|
|
779
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements,
|
|
907
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, registerDelegatedContainer, registerDelegatedRoot, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.14",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -137,10 +137,10 @@
|
|
|
137
137
|
"seroval-plugins": "^1.1.0"
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"solid-js": "^2.0.0-beta.
|
|
140
|
+
"solid-js": "^2.0.0-beta.14"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
|
-
"solid-js": "2.0.0-beta.
|
|
143
|
+
"solid-js": "2.0.0-beta.14"
|
|
144
144
|
},
|
|
145
145
|
"scripts": {
|
|
146
146
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
package/types/client.d.ts
CHANGED
|
@@ -33,8 +33,18 @@ export function insert<T>(
|
|
|
33
33
|
init?: JSX.Element
|
|
34
34
|
): JSX.Element;
|
|
35
35
|
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
36
|
-
export function delegateEvents(eventNames: string[]
|
|
37
|
-
export function
|
|
36
|
+
export function delegateEvents(eventNames: string[]): void;
|
|
37
|
+
export function registerDelegatedRoot(root: MountableElement): void;
|
|
38
|
+
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
39
|
+
export function registerDelegatedContainer(
|
|
40
|
+
container: MountableElement,
|
|
41
|
+
owner?: MountableElement
|
|
42
|
+
): void;
|
|
43
|
+
export function unregisterDelegatedContainer(
|
|
44
|
+
container: MountableElement,
|
|
45
|
+
owner?: MountableElement
|
|
46
|
+
): void;
|
|
47
|
+
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
38
48
|
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
39
49
|
export function assign(
|
|
40
50
|
node: Element,
|
|
@@ -45,17 +55,10 @@ export function assign(
|
|
|
45
55
|
): void;
|
|
46
56
|
export function setAttribute(node: Element, name: string, value: string): void;
|
|
47
57
|
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
48
|
-
|
|
49
|
-
| Record<string, boolean>
|
|
50
|
-
| Array<string | number | boolean | null | undefined | Record<string, boolean>>;
|
|
51
|
-
export function className(
|
|
52
|
-
node: Element,
|
|
53
|
-
value: string | ClassList,
|
|
54
|
-
prev?: string | ClassList
|
|
55
|
-
): void;
|
|
58
|
+
export function className(node: Element, value: JSX.ClassValue, prev?: JSX.ClassValue): void;
|
|
56
59
|
export function setProperty(node: Element, name: string, value: any): void;
|
|
57
60
|
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
58
|
-
export function
|
|
61
|
+
export function addEvent(
|
|
59
62
|
node: Element,
|
|
60
63
|
name: string,
|
|
61
64
|
handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
|