@solidjs/web 2.0.0-beta.13 → 2.0.0-beta.15
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 +246 -89
- package/dist/dev.js +242 -89
- package/dist/server.cjs +41 -1
- package/dist/server.js +32 -1
- package/dist/web.cjs +246 -89
- package/dist/web.js +242 -89
- package/package.json +3 -3
- package/types/client.d.ts +25 -12
- package/types/jsx-properties.d.ts +1 -0
- package/types/jsx.d.ts +55 -9
- package/types/server.d.ts +26 -7
- package/types-cjs/client.d.cts +25 -12
- package/types-cjs/jsx-properties.d.cts +1 -0
- package/types-cjs/jsx.d.cts +55 -9
- package/types-cjs/server.d.cts +26 -7
package/dist/dev.cjs
CHANGED
|
@@ -31,6 +31,8 @@ const DOMWithState = {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
34
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
35
|
+
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
34
36
|
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"]);
|
|
35
37
|
const SVGElements = /*#__PURE__*/new Set([
|
|
36
38
|
"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",
|
|
@@ -64,14 +66,18 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
|
|
|
64
66
|
} : transparentOptions);
|
|
65
67
|
const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
|
|
66
68
|
|
|
67
|
-
function reconcileArrays(parentNode, a, b) {
|
|
69
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
68
70
|
let bLength = b.length,
|
|
69
71
|
aEnd = a.length,
|
|
70
72
|
bEnd = bLength,
|
|
71
73
|
aStart = 0,
|
|
72
74
|
bStart = 0,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
tail = a[aEnd - 1],
|
|
76
|
+
tailTag = tail[$$SLOT],
|
|
77
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
78
|
+
map = null,
|
|
79
|
+
anchor,
|
|
80
|
+
anchorTag;
|
|
75
81
|
while (aStart < aEnd || bStart < bEnd) {
|
|
76
82
|
if (a[aStart] === b[bStart]) {
|
|
77
83
|
aStart++;
|
|
@@ -83,20 +89,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
83
89
|
bEnd--;
|
|
84
90
|
}
|
|
85
91
|
if (aEnd === aStart) {
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
let node;
|
|
93
|
+
if (bEnd < bLength) {
|
|
94
|
+
if (bStart) {
|
|
95
|
+
const prev = b[bStart - 1];
|
|
96
|
+
const prevTag = prev[$$SLOT];
|
|
97
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
98
|
+
} else node = b[bEnd - bStart];
|
|
99
|
+
} else node = after;
|
|
100
|
+
while (bStart < bEnd) {
|
|
101
|
+
const n = b[bStart++];
|
|
102
|
+
parentNode.insertBefore(n, node);
|
|
103
|
+
if (marker) n[$$SLOT] = marker;
|
|
104
|
+
}
|
|
88
105
|
} else if (bEnd === bStart) {
|
|
89
106
|
while (aStart < aEnd) {
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
const n = a[aStart++];
|
|
108
|
+
if (!map || !map.has(n)) {
|
|
109
|
+
const tag = n[$$SLOT];
|
|
110
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
114
|
+
if (marker) {
|
|
115
|
+
do {
|
|
116
|
+
const n = a[--aEnd];
|
|
117
|
+
parentNode.insertBefore(n, anchor);
|
|
118
|
+
n[$$SLOT] = marker;
|
|
119
|
+
bStart++;
|
|
120
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
121
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
122
|
+
} else {
|
|
123
|
+
do {
|
|
124
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
125
|
+
bStart++;
|
|
126
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
127
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
92
128
|
}
|
|
93
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
94
|
-
const anchor = a[aStart];
|
|
95
|
-
do {
|
|
96
|
-
parentNode.insertBefore(a[--aEnd], anchor);
|
|
97
|
-
bStart++;
|
|
98
|
-
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
99
|
-
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
100
129
|
} else {
|
|
101
130
|
if (!map) {
|
|
102
131
|
map = new Map();
|
|
@@ -114,36 +143,66 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
114
143
|
sequence++;
|
|
115
144
|
}
|
|
116
145
|
if (sequence > index - bStart) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
const head = a[aStart];
|
|
147
|
+
const headTag = head[$$SLOT];
|
|
148
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
149
|
+
while (bStart < index) {
|
|
150
|
+
const n = b[bStart++];
|
|
151
|
+
parentNode.insertBefore(n, node);
|
|
152
|
+
if (marker) n[$$SLOT] = marker;
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
const oldNode = a[aStart++];
|
|
156
|
+
const newNode = b[bStart++];
|
|
157
|
+
const oldTag = oldNode[$$SLOT];
|
|
158
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
159
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
160
|
+
} else {
|
|
161
|
+
parentNode.insertBefore(newNode, after);
|
|
162
|
+
}
|
|
163
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
164
|
+
}
|
|
120
165
|
} else aStart++;
|
|
121
|
-
} else
|
|
166
|
+
} else {
|
|
167
|
+
const n = a[aStart++];
|
|
168
|
+
const nTag = n[$$SLOT];
|
|
169
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
170
|
+
}
|
|
122
171
|
}
|
|
123
172
|
}
|
|
124
173
|
}
|
|
125
174
|
|
|
126
|
-
const $$
|
|
175
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
127
176
|
const INNER_OWNED = {};
|
|
177
|
+
const delegatedEvents = new Set();
|
|
178
|
+
const delegatedContainers = new Map();
|
|
128
179
|
function render$1(code, element, init, options = {}) {
|
|
129
180
|
if (!element) {
|
|
130
181
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
131
182
|
}
|
|
132
183
|
let disposer;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
184
|
+
registerDelegatedRoot(element);
|
|
185
|
+
try {
|
|
186
|
+
solidJs.createRoot(dispose => {
|
|
187
|
+
disposer = dispose;
|
|
188
|
+
if (element === document) {
|
|
189
|
+
const tree = code();
|
|
190
|
+
effect(() => solidJs.flatten(tree), () => {});
|
|
191
|
+
} else {
|
|
192
|
+
const tree = code();
|
|
193
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
194
|
+
}
|
|
195
|
+
}, {
|
|
196
|
+
id: options.renderId
|
|
197
|
+
});
|
|
198
|
+
} catch (err) {
|
|
199
|
+
if (disposer) disposer();
|
|
200
|
+
unregisterDelegatedRoot(element);
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
145
203
|
return () => {
|
|
146
204
|
disposer();
|
|
205
|
+
unregisterDelegatedRoot(element);
|
|
147
206
|
element.textContent = "";
|
|
148
207
|
};
|
|
149
208
|
}
|
|
@@ -159,20 +218,66 @@ function template(html, flag) {
|
|
|
159
218
|
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
160
219
|
return fn;
|
|
161
220
|
}
|
|
162
|
-
function delegateEvents(eventNames
|
|
163
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
221
|
+
function delegateEvents(eventNames) {
|
|
164
222
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
165
223
|
const name = eventNames[i];
|
|
166
|
-
if (!
|
|
167
|
-
|
|
168
|
-
|
|
224
|
+
if (!delegatedEvents.has(name)) {
|
|
225
|
+
delegatedEvents.add(name);
|
|
226
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
169
227
|
}
|
|
170
228
|
}
|
|
171
229
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
230
|
+
function registerDelegatedRoot(root) {
|
|
231
|
+
const state = registerDelegatedContainer(root, root);
|
|
232
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
233
|
+
}
|
|
234
|
+
function unregisterDelegatedRoot(root) {
|
|
235
|
+
const state = delegatedContainers.get(root);
|
|
236
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
237
|
+
unregisterDelegatedContainer(root, root);
|
|
238
|
+
}
|
|
239
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
240
|
+
if (!container || !owner) return;
|
|
241
|
+
let state = delegatedContainers.get(container);
|
|
242
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
243
|
+
owners: new Map(),
|
|
244
|
+
handlers: new Map()
|
|
245
|
+
});
|
|
246
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
247
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
248
|
+
return state;
|
|
249
|
+
}
|
|
250
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
251
|
+
const state = delegatedContainers.get(container);
|
|
252
|
+
if (!state) return;
|
|
253
|
+
const count = state.owners.get(owner);
|
|
254
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
255
|
+
if (state.owners.size) return;
|
|
256
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
257
|
+
delegatedContainers.delete(container);
|
|
258
|
+
}
|
|
259
|
+
function attachDelegatedEvent(name, container, state) {
|
|
260
|
+
if (state.handlers.has(name)) return;
|
|
261
|
+
const handler = e => eventHandler(e, container, state);
|
|
262
|
+
state.handlers.set(name, handler);
|
|
263
|
+
container.addEventListener(name, handler);
|
|
264
|
+
}
|
|
265
|
+
function getDelegatedRoot(node) {
|
|
266
|
+
while (node) {
|
|
267
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
268
|
+
node = node._$host || node.parentNode || node.host;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function findOwner(target, state) {
|
|
272
|
+
let node = target;
|
|
273
|
+
let distance = 0;
|
|
274
|
+
while (node) {
|
|
275
|
+
if (state.owners.has(node)) return {
|
|
276
|
+
owner: node,
|
|
277
|
+
distance
|
|
278
|
+
};
|
|
279
|
+
distance++;
|
|
280
|
+
node = node._$host || node.parentNode || node.host;
|
|
176
281
|
}
|
|
177
282
|
}
|
|
178
283
|
function setProperty(node, name, value) {
|
|
@@ -217,7 +322,7 @@ function className(node, value, prev) {
|
|
|
217
322
|
node.classList.add(key);
|
|
218
323
|
}
|
|
219
324
|
}
|
|
220
|
-
function
|
|
325
|
+
function addEvent(node, name, handler, delegate) {
|
|
221
326
|
if (delegate) {
|
|
222
327
|
if (Array.isArray(handler)) {
|
|
223
328
|
node[`$$${name}`] = handler[0];
|
|
@@ -284,6 +389,7 @@ function ref(fn, element) {
|
|
|
284
389
|
}
|
|
285
390
|
function insert(parent, accessor, marker, initial, options) {
|
|
286
391
|
const multi = marker !== undefined;
|
|
392
|
+
const host = options && options.host;
|
|
287
393
|
if (multi && !initial) initial = [];
|
|
288
394
|
if (isHydrating(parent)) {
|
|
289
395
|
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
@@ -297,7 +403,11 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
297
403
|
}
|
|
298
404
|
if (typeof accessor !== "function") {
|
|
299
405
|
accessor = normalize(accessor, initial, multi, true);
|
|
300
|
-
if (typeof accessor !== "function")
|
|
406
|
+
if (typeof accessor !== "function") {
|
|
407
|
+
insertExpression(parent, accessor, initial, marker);
|
|
408
|
+
host && tagHost(accessor, host);
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
301
411
|
}
|
|
302
412
|
if (multi && initial.length === 0) {
|
|
303
413
|
const placeholder = document.createTextNode("");
|
|
@@ -311,6 +421,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
311
421
|
effect(() => normalize(value, current, multi), inner => {
|
|
312
422
|
insertExpression(parent, inner, current, marker);
|
|
313
423
|
current = inner;
|
|
424
|
+
host && tagHost(current, host);
|
|
314
425
|
}, prev !== undefined && !(options && options.schedule) ? {
|
|
315
426
|
...options,
|
|
316
427
|
schedule: true
|
|
@@ -320,6 +431,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
320
431
|
if (value === INNER_OWNED) return;
|
|
321
432
|
insertExpression(parent, value, current, marker);
|
|
322
433
|
current = value;
|
|
434
|
+
host && tagHost(current, host);
|
|
323
435
|
}, options);
|
|
324
436
|
}
|
|
325
437
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
@@ -519,7 +631,17 @@ function runHydrationEvents() {
|
|
|
519
631
|
const [el, e] = events[0];
|
|
520
632
|
if (!completed.has(el)) return;
|
|
521
633
|
events.shift();
|
|
522
|
-
|
|
634
|
+
let match;
|
|
635
|
+
for (const [container, state] of delegatedContainers) {
|
|
636
|
+
if (!state.handlers.has(e.type)) continue;
|
|
637
|
+
const entry = findOwner(e.target, state);
|
|
638
|
+
if (entry && (!match || entry.distance < match.distance)) match = {
|
|
639
|
+
container,
|
|
640
|
+
state,
|
|
641
|
+
distance: entry.distance
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
if (match) eventHandler(e, match.container, match.state);
|
|
523
645
|
}
|
|
524
646
|
if (solidJs.sharedConfig.done) {
|
|
525
647
|
solidJs.sharedConfig.events = _$HY.events = null;
|
|
@@ -574,7 +696,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
574
696
|
node.removeEventListener(name, h);
|
|
575
697
|
}
|
|
576
698
|
if (delegate || value) {
|
|
577
|
-
|
|
699
|
+
addEvent(node, name, value, delegate);
|
|
578
700
|
delegate && delegateEvents([name]);
|
|
579
701
|
}
|
|
580
702
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
@@ -586,14 +708,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
586
708
|
}
|
|
587
709
|
return value;
|
|
588
710
|
}
|
|
589
|
-
function eventHandler(e) {
|
|
711
|
+
function eventHandler(e, container, state) {
|
|
590
712
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
591
713
|
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
592
714
|
}
|
|
715
|
+
if (e[$$EVENT_OWNER]) return;
|
|
716
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
717
|
+
if (state && !owner) return;
|
|
718
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
593
719
|
let node = e.target;
|
|
594
720
|
const key = `$$${e.type}`;
|
|
595
721
|
const oriTarget = e.target;
|
|
596
|
-
const
|
|
722
|
+
const boundary = owner || container || e.currentTarget;
|
|
597
723
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
598
724
|
configurable: true,
|
|
599
725
|
value
|
|
@@ -609,29 +735,34 @@ function eventHandler(e) {
|
|
|
609
735
|
return true;
|
|
610
736
|
};
|
|
611
737
|
const walkUpTree = () => {
|
|
612
|
-
while (handleNode()
|
|
738
|
+
while (handleNode()) {
|
|
739
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
740
|
+
node = node._$host || node.parentNode || node.host;
|
|
741
|
+
}
|
|
613
742
|
};
|
|
614
743
|
Object.defineProperty(e, "currentTarget", {
|
|
615
744
|
configurable: true,
|
|
616
745
|
get() {
|
|
617
|
-
return node || document;
|
|
746
|
+
return node || boundary || document;
|
|
618
747
|
}
|
|
619
748
|
});
|
|
620
749
|
if (e.composedPath) {
|
|
621
750
|
const path = e.composedPath();
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
751
|
+
if (path.length) {
|
|
752
|
+
retarget(path[0]);
|
|
753
|
+
for (let i = 0; i < path.length; i++) {
|
|
754
|
+
node = path[i];
|
|
755
|
+
if (!handleNode()) break;
|
|
756
|
+
if (node._$host) {
|
|
757
|
+
node = node._$host;
|
|
758
|
+
walkUpTree();
|
|
759
|
+
break;
|
|
760
|
+
}
|
|
761
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
633
764
|
}
|
|
634
|
-
}
|
|
765
|
+
} else walkUpTree();
|
|
635
766
|
}
|
|
636
767
|
else walkUpTree();
|
|
637
768
|
retarget(oriTarget);
|
|
@@ -651,9 +782,14 @@ function insertExpression(parent, value, current, marker) {
|
|
|
651
782
|
} else if (value.nodeType) {
|
|
652
783
|
if (Array.isArray(current)) {
|
|
653
784
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
654
|
-
} else if (current
|
|
785
|
+
} else if (current && current.nodeType) {
|
|
786
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
787
|
+
} else if (current && parent.firstChild) {
|
|
788
|
+
parent.replaceChild(value, parent.firstChild);
|
|
789
|
+
} else {
|
|
655
790
|
parent.appendChild(value);
|
|
656
|
-
}
|
|
791
|
+
}
|
|
792
|
+
if (marker) value[$$SLOT] = marker;
|
|
657
793
|
} else if (Array.isArray(value)) {
|
|
658
794
|
const currentArray = current && Array.isArray(current);
|
|
659
795
|
if (value.length === 0) {
|
|
@@ -661,7 +797,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
661
797
|
} else if (currentArray) {
|
|
662
798
|
if (current.length === 0) {
|
|
663
799
|
appendNodes(parent, value, marker);
|
|
664
|
-
} else reconcileArrays(parent, current, value);
|
|
800
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
665
801
|
} else {
|
|
666
802
|
current && cleanChildren(parent);
|
|
667
803
|
appendNodes(parent, value);
|
|
@@ -685,8 +821,23 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
685
821
|
}
|
|
686
822
|
return value;
|
|
687
823
|
}
|
|
824
|
+
function tagHost(value, host) {
|
|
825
|
+
if (Array.isArray(value)) {
|
|
826
|
+
for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
|
|
827
|
+
} else if (value && value.nodeType && value[$$HOST] !== host) {
|
|
828
|
+
value[$$HOST] = host;
|
|
829
|
+
Object.defineProperty(value, "_$host", {
|
|
830
|
+
get: host,
|
|
831
|
+
configurable: true
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
}
|
|
688
835
|
function appendNodes(parent, array, marker = null) {
|
|
689
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
836
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
837
|
+
const n = array[i];
|
|
838
|
+
parent.insertBefore(n, marker);
|
|
839
|
+
if (marker) n[$$SLOT] = marker;
|
|
840
|
+
}
|
|
690
841
|
}
|
|
691
842
|
function cleanChildren(parent, current, marker, replacement) {
|
|
692
843
|
if (marker === undefined) return parent.textContent = "";
|
|
@@ -695,11 +846,13 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
695
846
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
696
847
|
const el = current[i];
|
|
697
848
|
if (replacement !== el) {
|
|
698
|
-
const
|
|
699
|
-
|
|
849
|
+
const tag = el[$$SLOT];
|
|
850
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
851
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
700
852
|
} else inserted = true;
|
|
701
853
|
}
|
|
702
854
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
855
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
703
856
|
}
|
|
704
857
|
function gatherHydratable(element, root) {
|
|
705
858
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -763,12 +916,20 @@ function Portal(props) {
|
|
|
763
916
|
const treeMarker = document.createTextNode(""),
|
|
764
917
|
startMarker = document.createTextNode(""),
|
|
765
918
|
endMarker = document.createTextNode(""),
|
|
766
|
-
mount = () =>
|
|
767
|
-
|
|
768
|
-
solidJs.createRenderEffect(
|
|
919
|
+
mount = () => props.mount || document.body,
|
|
920
|
+
content = solidJs.createMemo(() => [startMarker, props.children]);
|
|
921
|
+
solidJs.createRenderEffect(
|
|
922
|
+
() => [mount(), content(), solidJs.getOwner()], ([, c, owner]) => {
|
|
923
|
+
const m = solidJs.untrack(mount);
|
|
769
924
|
m.appendChild(endMarker);
|
|
770
|
-
|
|
925
|
+
const dispose = solidJs.runWithOwner(owner, () => solidJs.createRoot(d => {
|
|
926
|
+
insert(m, c, endMarker, undefined, {
|
|
927
|
+
host: () => treeMarker.parentNode
|
|
928
|
+
});
|
|
929
|
+
return d;
|
|
930
|
+
}));
|
|
771
931
|
return () => {
|
|
932
|
+
dispose();
|
|
772
933
|
let c = startMarker;
|
|
773
934
|
while (c && c !== endMarker) {
|
|
774
935
|
const n = c.nextSibling;
|
|
@@ -776,6 +937,15 @@ function Portal(props) {
|
|
|
776
937
|
c = n;
|
|
777
938
|
}
|
|
778
939
|
};
|
|
940
|
+
}, {
|
|
941
|
+
schedule: true
|
|
942
|
+
});
|
|
943
|
+
solidJs.createEffect(mount, () => {
|
|
944
|
+
const m = solidJs.untrack(mount);
|
|
945
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
946
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
947
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
948
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
779
949
|
});
|
|
780
950
|
return treeMarker;
|
|
781
951
|
}
|
|
@@ -809,23 +979,6 @@ function createElement(tagName, is = undefined) {
|
|
|
809
979
|
is
|
|
810
980
|
});
|
|
811
981
|
}
|
|
812
|
-
function createElementProxy(el, marker) {
|
|
813
|
-
return new Proxy(el, {
|
|
814
|
-
get(target, prop) {
|
|
815
|
-
if (prop === "appendChild" || prop === "insertBefore") {
|
|
816
|
-
return (...args) => {
|
|
817
|
-
Object.defineProperty(args[0], "_$host", {
|
|
818
|
-
get: () => marker.parentNode,
|
|
819
|
-
configurable: true
|
|
820
|
-
});
|
|
821
|
-
target[prop](...args);
|
|
822
|
-
};
|
|
823
|
-
}
|
|
824
|
-
const value = Reflect.get(target, prop);
|
|
825
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
}
|
|
829
982
|
|
|
830
983
|
Object.defineProperty(exports, "Errored", {
|
|
831
984
|
enumerable: true,
|
|
@@ -893,11 +1046,10 @@ exports.RawTextElements = RawTextElements;
|
|
|
893
1046
|
exports.RequestContext = RequestContext;
|
|
894
1047
|
exports.SVGElements = SVGElements;
|
|
895
1048
|
exports.VoidElements = VoidElements;
|
|
896
|
-
exports.
|
|
1049
|
+
exports.addEvent = addEvent;
|
|
897
1050
|
exports.applyRef = applyRef;
|
|
898
1051
|
exports.assign = assign;
|
|
899
1052
|
exports.className = className;
|
|
900
|
-
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
901
1053
|
exports.delegateEvents = delegateEvents;
|
|
902
1054
|
exports.dynamic = dynamic;
|
|
903
1055
|
exports.dynamicProperty = dynamicProperty;
|
|
@@ -905,6 +1057,7 @@ exports.effect = effect;
|
|
|
905
1057
|
exports.escape = escape;
|
|
906
1058
|
exports.generateHydrationScript = voidFn;
|
|
907
1059
|
exports.getAssets = voidFn;
|
|
1060
|
+
exports.getDelegatedRoot = getDelegatedRoot;
|
|
908
1061
|
exports.getFirstChild = getFirstChild;
|
|
909
1062
|
exports.getHydrationKey = getHydrationKey;
|
|
910
1063
|
exports.getNextElement = getNextElement;
|
|
@@ -919,6 +1072,8 @@ exports.isServer = isServer;
|
|
|
919
1072
|
exports.memo = memo;
|
|
920
1073
|
exports.mergeProps = mergeProps;
|
|
921
1074
|
exports.ref = ref;
|
|
1075
|
+
exports.registerDelegatedContainer = registerDelegatedContainer;
|
|
1076
|
+
exports.registerDelegatedRoot = registerDelegatedRoot;
|
|
922
1077
|
exports.render = render;
|
|
923
1078
|
exports.renderToStream = renderToStream;
|
|
924
1079
|
exports.renderToString = renderToString;
|
|
@@ -938,4 +1093,6 @@ exports.ssrHydrationKey = ssrHydrationKey;
|
|
|
938
1093
|
exports.ssrStyle = ssrStyle;
|
|
939
1094
|
exports.style = style;
|
|
940
1095
|
exports.template = template;
|
|
1096
|
+
exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
|
|
1097
|
+
exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
|
|
941
1098
|
exports.useAssets = voidFn;
|