@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/server.js
CHANGED
|
@@ -3,6 +3,34 @@ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, S
|
|
|
3
3
|
import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
|
|
4
4
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
5
|
|
|
6
|
+
const DOMWithState = {
|
|
7
|
+
INPUT: {
|
|
8
|
+
value: 1,
|
|
9
|
+
defaultValue: 2,
|
|
10
|
+
checked: 1,
|
|
11
|
+
defaultChecked: 2
|
|
12
|
+
},
|
|
13
|
+
SELECT: {
|
|
14
|
+
value: 1
|
|
15
|
+
},
|
|
16
|
+
OPTION: {
|
|
17
|
+
value: 1,
|
|
18
|
+
selected: 1,
|
|
19
|
+
defaultSelected: 2
|
|
20
|
+
},
|
|
21
|
+
TEXTAREA: {
|
|
22
|
+
value: 1,
|
|
23
|
+
defaultValue: 2
|
|
24
|
+
},
|
|
25
|
+
VIDEO: {
|
|
26
|
+
muted: 1,
|
|
27
|
+
defaultMuted: 2
|
|
28
|
+
},
|
|
29
|
+
AUDIO: {
|
|
30
|
+
muted: 1,
|
|
31
|
+
defaultMuted: 2
|
|
32
|
+
}
|
|
33
|
+
};
|
|
6
34
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
7
35
|
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"]);
|
|
8
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -951,6 +979,9 @@ function getAssets() {
|
|
|
951
979
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
952
980
|
return out;
|
|
953
981
|
}
|
|
982
|
+
function Assets(props) {
|
|
983
|
+
useAssets(() => props.children);
|
|
984
|
+
}
|
|
954
985
|
function generateHydrationScript({
|
|
955
986
|
eventNames = ["click", "input"],
|
|
956
987
|
nonce
|
|
@@ -1175,4 +1206,4 @@ function Portal(props) {
|
|
|
1175
1206
|
throw new Error("Portal is not supported on the server");
|
|
1176
1207
|
}
|
|
1177
1208
|
|
|
1178
|
-
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as
|
|
1209
|
+
export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
|
package/dist/web.cjs
CHANGED
|
@@ -31,6 +31,7 @@ const DOMWithState = {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
34
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
34
35
|
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
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
36
37
|
"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 +65,18 @@ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectF
|
|
|
64
65
|
} : transparentOptions);
|
|
65
66
|
const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
|
|
66
67
|
|
|
67
|
-
function reconcileArrays(parentNode, a, b) {
|
|
68
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
68
69
|
let bLength = b.length,
|
|
69
70
|
aEnd = a.length,
|
|
70
71
|
bEnd = bLength,
|
|
71
72
|
aStart = 0,
|
|
72
73
|
bStart = 0,
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
tail = a[aEnd - 1],
|
|
75
|
+
tailTag = tail[$$SLOT],
|
|
76
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
77
|
+
map = null,
|
|
78
|
+
anchor,
|
|
79
|
+
anchorTag;
|
|
75
80
|
while (aStart < aEnd || bStart < bEnd) {
|
|
76
81
|
if (a[aStart] === b[bStart]) {
|
|
77
82
|
aStart++;
|
|
@@ -83,20 +88,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
83
88
|
bEnd--;
|
|
84
89
|
}
|
|
85
90
|
if (aEnd === aStart) {
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
let node;
|
|
92
|
+
if (bEnd < bLength) {
|
|
93
|
+
if (bStart) {
|
|
94
|
+
const prev = b[bStart - 1];
|
|
95
|
+
const prevTag = prev[$$SLOT];
|
|
96
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
97
|
+
} else node = b[bEnd - bStart];
|
|
98
|
+
} else node = after;
|
|
99
|
+
while (bStart < bEnd) {
|
|
100
|
+
const n = b[bStart++];
|
|
101
|
+
parentNode.insertBefore(n, node);
|
|
102
|
+
if (marker) n[$$SLOT] = marker;
|
|
103
|
+
}
|
|
88
104
|
} else if (bEnd === bStart) {
|
|
89
105
|
while (aStart < aEnd) {
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
const n = a[aStart++];
|
|
107
|
+
if (!map || !map.has(n)) {
|
|
108
|
+
const tag = n[$$SLOT];
|
|
109
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
113
|
+
if (marker) {
|
|
114
|
+
do {
|
|
115
|
+
const n = a[--aEnd];
|
|
116
|
+
parentNode.insertBefore(n, anchor);
|
|
117
|
+
n[$$SLOT] = marker;
|
|
118
|
+
bStart++;
|
|
119
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
120
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
121
|
+
} else {
|
|
122
|
+
do {
|
|
123
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
124
|
+
bStart++;
|
|
125
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
126
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
92
127
|
}
|
|
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
128
|
} else {
|
|
101
129
|
if (!map) {
|
|
102
130
|
map = new Map();
|
|
@@ -114,35 +142,64 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
114
142
|
sequence++;
|
|
115
143
|
}
|
|
116
144
|
if (sequence > index - bStart) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
145
|
+
const head = a[aStart];
|
|
146
|
+
const headTag = head[$$SLOT];
|
|
147
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
148
|
+
while (bStart < index) {
|
|
149
|
+
const n = b[bStart++];
|
|
150
|
+
parentNode.insertBefore(n, node);
|
|
151
|
+
if (marker) n[$$SLOT] = marker;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
const oldNode = a[aStart++];
|
|
155
|
+
const newNode = b[bStart++];
|
|
156
|
+
const oldTag = oldNode[$$SLOT];
|
|
157
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
158
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
159
|
+
} else {
|
|
160
|
+
parentNode.insertBefore(newNode, after);
|
|
161
|
+
}
|
|
162
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
163
|
+
}
|
|
120
164
|
} else aStart++;
|
|
121
|
-
} else
|
|
165
|
+
} else {
|
|
166
|
+
const n = a[aStart++];
|
|
167
|
+
const nTag = n[$$SLOT];
|
|
168
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
169
|
+
}
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
172
|
}
|
|
125
173
|
|
|
126
|
-
const $$
|
|
174
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
127
175
|
const INNER_OWNED = {};
|
|
176
|
+
const delegatedEvents = new Set();
|
|
177
|
+
const delegatedContainers = new Map();
|
|
128
178
|
function render$1(code, element, init, options = {}) {
|
|
129
|
-
const renderRoot = getChildRoot(element);
|
|
130
179
|
let disposer;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
180
|
+
registerDelegatedRoot(element);
|
|
181
|
+
try {
|
|
182
|
+
solidJs.createRoot(dispose => {
|
|
183
|
+
disposer = dispose;
|
|
184
|
+
if (element === document) {
|
|
185
|
+
const tree = code();
|
|
186
|
+
effect(() => solidJs.flatten(tree), () => {});
|
|
187
|
+
} else {
|
|
188
|
+
const tree = code();
|
|
189
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
id: options.renderId
|
|
193
|
+
});
|
|
194
|
+
} catch (err) {
|
|
195
|
+
if (disposer) disposer();
|
|
196
|
+
unregisterDelegatedRoot(element);
|
|
197
|
+
throw err;
|
|
198
|
+
}
|
|
143
199
|
return () => {
|
|
144
200
|
disposer();
|
|
145
|
-
|
|
201
|
+
unregisterDelegatedRoot(element);
|
|
202
|
+
element.textContent = "";
|
|
146
203
|
};
|
|
147
204
|
}
|
|
148
205
|
function create(html, bypassGuard, flag) {
|
|
@@ -155,20 +212,66 @@ function template(html, flag) {
|
|
|
155
212
|
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
156
213
|
return fn;
|
|
157
214
|
}
|
|
158
|
-
function delegateEvents(eventNames
|
|
159
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
215
|
+
function delegateEvents(eventNames) {
|
|
160
216
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
161
217
|
const name = eventNames[i];
|
|
162
|
-
if (!
|
|
163
|
-
|
|
164
|
-
|
|
218
|
+
if (!delegatedEvents.has(name)) {
|
|
219
|
+
delegatedEvents.add(name);
|
|
220
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
165
221
|
}
|
|
166
222
|
}
|
|
167
223
|
}
|
|
168
|
-
function
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
224
|
+
function registerDelegatedRoot(root) {
|
|
225
|
+
const state = registerDelegatedContainer(root, root);
|
|
226
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
227
|
+
}
|
|
228
|
+
function unregisterDelegatedRoot(root) {
|
|
229
|
+
const state = delegatedContainers.get(root);
|
|
230
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
231
|
+
unregisterDelegatedContainer(root, root);
|
|
232
|
+
}
|
|
233
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
234
|
+
if (!container || !owner) return;
|
|
235
|
+
let state = delegatedContainers.get(container);
|
|
236
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
237
|
+
owners: new Map(),
|
|
238
|
+
handlers: new Map()
|
|
239
|
+
});
|
|
240
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
241
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
242
|
+
return state;
|
|
243
|
+
}
|
|
244
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
245
|
+
const state = delegatedContainers.get(container);
|
|
246
|
+
if (!state) return;
|
|
247
|
+
const count = state.owners.get(owner);
|
|
248
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
249
|
+
if (state.owners.size) return;
|
|
250
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
251
|
+
delegatedContainers.delete(container);
|
|
252
|
+
}
|
|
253
|
+
function attachDelegatedEvent(name, container, state) {
|
|
254
|
+
if (state.handlers.has(name)) return;
|
|
255
|
+
const handler = e => eventHandler(e, container, state);
|
|
256
|
+
state.handlers.set(name, handler);
|
|
257
|
+
container.addEventListener(name, handler);
|
|
258
|
+
}
|
|
259
|
+
function getDelegatedRoot(node) {
|
|
260
|
+
while (node) {
|
|
261
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
262
|
+
node = node._$host || node.parentNode || node.host;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function findOwner(target, state) {
|
|
266
|
+
let node = target;
|
|
267
|
+
let distance = 0;
|
|
268
|
+
while (node) {
|
|
269
|
+
if (state.owners.has(node)) return {
|
|
270
|
+
owner: node,
|
|
271
|
+
distance
|
|
272
|
+
};
|
|
273
|
+
distance++;
|
|
274
|
+
node = node._$host || node.parentNode || node.host;
|
|
172
275
|
}
|
|
173
276
|
}
|
|
174
277
|
function setProperty(node, name, value) {
|
|
@@ -213,7 +316,7 @@ function className(node, value, prev) {
|
|
|
213
316
|
node.classList.add(key);
|
|
214
317
|
}
|
|
215
318
|
}
|
|
216
|
-
function
|
|
319
|
+
function addEvent(node, name, handler, delegate) {
|
|
217
320
|
if (delegate) {
|
|
218
321
|
if (Array.isArray(handler)) {
|
|
219
322
|
node[`$$${name}`] = handler[0];
|
|
@@ -279,11 +382,10 @@ function ref(fn, element) {
|
|
|
279
382
|
solidJs.runWithOwner(null, () => applyRef(resolved, element));
|
|
280
383
|
}
|
|
281
384
|
function insert(parent, accessor, marker, initial, options) {
|
|
282
|
-
const childRoot = getChildRoot(parent);
|
|
283
385
|
const multi = marker !== undefined;
|
|
284
386
|
if (multi && !initial) initial = [];
|
|
285
387
|
if (isHydrating(parent)) {
|
|
286
|
-
if (!multi && initial === undefined && parent) initial = [...
|
|
388
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
287
389
|
if (Array.isArray(initial)) {
|
|
288
390
|
let j = 0;
|
|
289
391
|
for (let i = 0; i < initial.length; i++) {
|
|
@@ -298,7 +400,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
298
400
|
}
|
|
299
401
|
if (multi && initial.length === 0) {
|
|
300
402
|
const placeholder = document.createTextNode("");
|
|
301
|
-
|
|
403
|
+
parent.insertBefore(placeholder, marker);
|
|
302
404
|
initial = [placeholder];
|
|
303
405
|
}
|
|
304
406
|
let current = initial;
|
|
@@ -353,7 +455,7 @@ function loadModuleAssets(mapping) {
|
|
|
353
455
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
354
456
|
}
|
|
355
457
|
function hydrate$1(code, element, options = {}) {
|
|
356
|
-
if (globalThis._$HY.done) return render$1(code, element, [...
|
|
458
|
+
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
357
459
|
options.renderId ||= "";
|
|
358
460
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
359
461
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -389,7 +491,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
389
491
|
let disposer;
|
|
390
492
|
p.then(() => {
|
|
391
493
|
try {
|
|
392
|
-
disposer = render$1(code, element, [...
|
|
494
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
393
495
|
} finally {
|
|
394
496
|
solidJs.sharedConfig.hydrating = false;
|
|
395
497
|
}
|
|
@@ -401,7 +503,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
401
503
|
}
|
|
402
504
|
try {
|
|
403
505
|
gatherHydratable(element, options.renderId);
|
|
404
|
-
return render$1(code, element, [...
|
|
506
|
+
return render$1(code, element, [...element.childNodes], options);
|
|
405
507
|
} finally {
|
|
406
508
|
solidJs.sharedConfig.hydrating = false;
|
|
407
509
|
}
|
|
@@ -444,7 +546,7 @@ function getNextMarker(start) {
|
|
|
444
546
|
return [end, current];
|
|
445
547
|
}
|
|
446
548
|
function getFirstChild(node, expectedTag) {
|
|
447
|
-
const child =
|
|
549
|
+
const child = node.firstChild;
|
|
448
550
|
return child;
|
|
449
551
|
}
|
|
450
552
|
function getNextSibling(node, expectedTag) {
|
|
@@ -464,7 +566,17 @@ function runHydrationEvents() {
|
|
|
464
566
|
const [el, e] = events[0];
|
|
465
567
|
if (!completed.has(el)) return;
|
|
466
568
|
events.shift();
|
|
467
|
-
|
|
569
|
+
let match;
|
|
570
|
+
for (const [container, state] of delegatedContainers) {
|
|
571
|
+
if (!state.handlers.has(e.type)) continue;
|
|
572
|
+
const entry = findOwner(e.target, state);
|
|
573
|
+
if (entry && (!match || entry.distance < match.distance)) match = {
|
|
574
|
+
container,
|
|
575
|
+
state,
|
|
576
|
+
distance: entry.distance
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
if (match) eventHandler(e, match.container, match.state);
|
|
468
580
|
}
|
|
469
581
|
if (solidJs.sharedConfig.done) {
|
|
470
582
|
solidJs.sharedConfig.events = _$HY.events = null;
|
|
@@ -477,9 +589,6 @@ function runHydrationEvents() {
|
|
|
477
589
|
function isHydrating(node) {
|
|
478
590
|
return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
|
|
479
591
|
}
|
|
480
|
-
function getChildRoot(node) {
|
|
481
|
-
return node && node.localName === "template" ? node.content : node;
|
|
482
|
-
}
|
|
483
592
|
function classListToObject(classList) {
|
|
484
593
|
if (Array.isArray(classList)) {
|
|
485
594
|
const result = {};
|
|
@@ -514,11 +623,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
514
623
|
return value;
|
|
515
624
|
}
|
|
516
625
|
const hasNamespace = prop.indexOf(":") > -1;
|
|
517
|
-
if (hasNamespace && prop.slice(0,
|
|
518
|
-
const e = prop.slice(3);
|
|
519
|
-
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
520
|
-
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
521
|
-
} else if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
626
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
522
627
|
const name = prop.slice(2).toLowerCase();
|
|
523
628
|
const delegate = DelegatedEvents.has(name);
|
|
524
629
|
if (!delegate && prev) {
|
|
@@ -526,7 +631,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
526
631
|
node.removeEventListener(name, h);
|
|
527
632
|
}
|
|
528
633
|
if (delegate || value) {
|
|
529
|
-
|
|
634
|
+
addEvent(node, name, value, delegate);
|
|
530
635
|
delegate && delegateEvents([name]);
|
|
531
636
|
}
|
|
532
637
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
@@ -538,14 +643,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
538
643
|
}
|
|
539
644
|
return value;
|
|
540
645
|
}
|
|
541
|
-
function eventHandler(e) {
|
|
646
|
+
function eventHandler(e, container, state) {
|
|
542
647
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
|
|
543
648
|
if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
544
649
|
}
|
|
650
|
+
if (e[$$EVENT_OWNER]) return;
|
|
651
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
652
|
+
if (state && !owner) return;
|
|
653
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
545
654
|
let node = e.target;
|
|
546
655
|
const key = `$$${e.type}`;
|
|
547
656
|
const oriTarget = e.target;
|
|
548
|
-
const
|
|
657
|
+
const boundary = owner || container || e.currentTarget;
|
|
549
658
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
550
659
|
configurable: true,
|
|
551
660
|
value
|
|
@@ -561,29 +670,34 @@ function eventHandler(e) {
|
|
|
561
670
|
return true;
|
|
562
671
|
};
|
|
563
672
|
const walkUpTree = () => {
|
|
564
|
-
while (handleNode()
|
|
673
|
+
while (handleNode()) {
|
|
674
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
675
|
+
node = node._$host || node.parentNode || node.host;
|
|
676
|
+
}
|
|
565
677
|
};
|
|
566
678
|
Object.defineProperty(e, "currentTarget", {
|
|
567
679
|
configurable: true,
|
|
568
680
|
get() {
|
|
569
|
-
return node || document;
|
|
681
|
+
return node || boundary || document;
|
|
570
682
|
}
|
|
571
683
|
});
|
|
572
684
|
if (e.composedPath) {
|
|
573
685
|
const path = e.composedPath();
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
686
|
+
if (path.length) {
|
|
687
|
+
retarget(path[0]);
|
|
688
|
+
for (let i = 0; i < path.length; i++) {
|
|
689
|
+
node = path[i];
|
|
690
|
+
if (!handleNode()) break;
|
|
691
|
+
if (node._$host) {
|
|
692
|
+
node = node._$host;
|
|
693
|
+
walkUpTree();
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
585
699
|
}
|
|
586
|
-
}
|
|
700
|
+
} else walkUpTree();
|
|
587
701
|
}
|
|
588
702
|
else walkUpTree();
|
|
589
703
|
retarget(oriTarget);
|
|
@@ -591,22 +705,26 @@ function eventHandler(e) {
|
|
|
591
705
|
function insertExpression(parent, value, current, marker) {
|
|
592
706
|
if (isHydrating(parent)) return;
|
|
593
707
|
if (value === current) return;
|
|
594
|
-
const childRoot = getChildRoot(parent);
|
|
595
708
|
const t = typeof value,
|
|
596
709
|
multi = marker !== undefined;
|
|
597
710
|
if (t === "string" || t === "number") {
|
|
598
711
|
const tc = typeof current;
|
|
599
712
|
if (tc === "string" || tc === "number") {
|
|
600
|
-
|
|
601
|
-
} else
|
|
713
|
+
parent.firstChild.data = value;
|
|
714
|
+
} else parent.textContent = value;
|
|
602
715
|
} else if (value === undefined) {
|
|
603
716
|
cleanChildren(parent, current, marker);
|
|
604
717
|
} else if (value.nodeType) {
|
|
605
718
|
if (Array.isArray(current)) {
|
|
606
719
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
607
|
-
} else if (current
|
|
608
|
-
|
|
609
|
-
} else
|
|
720
|
+
} else if (current && current.nodeType) {
|
|
721
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
722
|
+
} else if (current && parent.firstChild) {
|
|
723
|
+
parent.replaceChild(value, parent.firstChild);
|
|
724
|
+
} else {
|
|
725
|
+
parent.appendChild(value);
|
|
726
|
+
}
|
|
727
|
+
if (marker) value[$$SLOT] = marker;
|
|
610
728
|
} else if (Array.isArray(value)) {
|
|
611
729
|
const currentArray = current && Array.isArray(current);
|
|
612
730
|
if (value.length === 0) {
|
|
@@ -614,7 +732,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
614
732
|
} else if (currentArray) {
|
|
615
733
|
if (current.length === 0) {
|
|
616
734
|
appendNodes(parent, value, marker);
|
|
617
|
-
} else reconcileArrays(
|
|
735
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
618
736
|
} else {
|
|
619
737
|
current && cleanChildren(parent);
|
|
620
738
|
appendNodes(parent, value);
|
|
@@ -639,22 +757,26 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
639
757
|
return value;
|
|
640
758
|
}
|
|
641
759
|
function appendNodes(parent, array, marker = null) {
|
|
642
|
-
|
|
643
|
-
|
|
760
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
761
|
+
const n = array[i];
|
|
762
|
+
parent.insertBefore(n, marker);
|
|
763
|
+
if (marker) n[$$SLOT] = marker;
|
|
764
|
+
}
|
|
644
765
|
}
|
|
645
766
|
function cleanChildren(parent, current, marker, replacement) {
|
|
646
|
-
parent = getChildRoot(parent);
|
|
647
767
|
if (marker === undefined) return parent.textContent = "";
|
|
648
768
|
if (current.length) {
|
|
649
769
|
let inserted = false;
|
|
650
770
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
651
771
|
const el = current[i];
|
|
652
772
|
if (replacement !== el) {
|
|
653
|
-
const
|
|
654
|
-
|
|
773
|
+
const tag = el[$$SLOT];
|
|
774
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
775
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
655
776
|
} else inserted = true;
|
|
656
777
|
}
|
|
657
778
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
779
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
658
780
|
}
|
|
659
781
|
function gatherHydratable(element, root) {
|
|
660
782
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -716,8 +838,8 @@ function Portal(props) {
|
|
|
716
838
|
const treeMarker = document.createTextNode(""),
|
|
717
839
|
startMarker = document.createTextNode(""),
|
|
718
840
|
endMarker = document.createTextNode(""),
|
|
719
|
-
mount = () => createElementProxy(props.mount || document.body, treeMarker)
|
|
720
|
-
|
|
841
|
+
mount = () => createElementProxy(props.mount || document.body, treeMarker),
|
|
842
|
+
content = solidJs.createMemo(() => [startMarker, props.children]);
|
|
721
843
|
solidJs.createRenderEffect(() => [mount(), content()], ([m, c]) => {
|
|
722
844
|
m.appendChild(endMarker);
|
|
723
845
|
insert(m, c, endMarker);
|
|
@@ -730,6 +852,12 @@ function Portal(props) {
|
|
|
730
852
|
}
|
|
731
853
|
};
|
|
732
854
|
});
|
|
855
|
+
solidJs.createEffect(mount, m => {
|
|
856
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
857
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
858
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
859
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
860
|
+
});
|
|
733
861
|
return treeMarker;
|
|
734
862
|
}
|
|
735
863
|
function dynamic(source) {
|
|
@@ -843,11 +971,10 @@ exports.RawTextElements = RawTextElements;
|
|
|
843
971
|
exports.RequestContext = RequestContext;
|
|
844
972
|
exports.SVGElements = SVGElements;
|
|
845
973
|
exports.VoidElements = VoidElements;
|
|
846
|
-
exports.
|
|
974
|
+
exports.addEvent = addEvent;
|
|
847
975
|
exports.applyRef = applyRef;
|
|
848
976
|
exports.assign = assign;
|
|
849
977
|
exports.className = className;
|
|
850
|
-
exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
851
978
|
exports.delegateEvents = delegateEvents;
|
|
852
979
|
exports.dynamic = dynamic;
|
|
853
980
|
exports.dynamicProperty = dynamicProperty;
|
|
@@ -855,6 +982,7 @@ exports.effect = effect;
|
|
|
855
982
|
exports.escape = escape;
|
|
856
983
|
exports.generateHydrationScript = voidFn;
|
|
857
984
|
exports.getAssets = voidFn;
|
|
985
|
+
exports.getDelegatedRoot = getDelegatedRoot;
|
|
858
986
|
exports.getFirstChild = getFirstChild;
|
|
859
987
|
exports.getHydrationKey = getHydrationKey;
|
|
860
988
|
exports.getNextElement = getNextElement;
|
|
@@ -869,6 +997,8 @@ exports.isServer = isServer;
|
|
|
869
997
|
exports.memo = memo;
|
|
870
998
|
exports.mergeProps = mergeProps;
|
|
871
999
|
exports.ref = ref;
|
|
1000
|
+
exports.registerDelegatedContainer = registerDelegatedContainer;
|
|
1001
|
+
exports.registerDelegatedRoot = registerDelegatedRoot;
|
|
872
1002
|
exports.render = render;
|
|
873
1003
|
exports.renderToStream = renderToStream;
|
|
874
1004
|
exports.renderToString = renderToString;
|
|
@@ -888,4 +1018,6 @@ exports.ssrHydrationKey = ssrHydrationKey;
|
|
|
888
1018
|
exports.ssrStyle = ssrStyle;
|
|
889
1019
|
exports.style = style;
|
|
890
1020
|
exports.template = template;
|
|
1021
|
+
exports.unregisterDelegatedContainer = unregisterDelegatedContainer;
|
|
1022
|
+
exports.unregisterDelegatedRoot = unregisterDelegatedRoot;
|
|
891
1023
|
exports.useAssets = voidFn;
|