@solidjs/web 2.0.0-beta.4 → 2.0.0-beta.5
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 +57 -51
- package/dist/dev.js +56 -51
- package/dist/server.cjs +0 -3
- package/dist/server.js +1 -3
- package/dist/web.cjs +53 -45
- package/dist/web.js +52 -45
- package/package.json +5 -4
- package/types/client.d.ts +4 -5
- package/types/server.d.ts +2 -4
package/dist/dev.cjs
CHANGED
|
@@ -3,8 +3,28 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
var signals = require('@solidjs/signals');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const DOMWithState = {
|
|
7
|
+
INPUT: {
|
|
8
|
+
value: 1,
|
|
9
|
+
checked: 1
|
|
10
|
+
},
|
|
11
|
+
SELECT: {
|
|
12
|
+
value: 1
|
|
13
|
+
},
|
|
14
|
+
OPTION: {
|
|
15
|
+
value: 1,
|
|
16
|
+
selected: 1
|
|
17
|
+
},
|
|
18
|
+
TEXTAREA: {
|
|
19
|
+
value: 1
|
|
20
|
+
},
|
|
21
|
+
VIDEO: {
|
|
22
|
+
muted: 1
|
|
23
|
+
},
|
|
24
|
+
AUDIO: {
|
|
25
|
+
muted: 1
|
|
26
|
+
}
|
|
27
|
+
};
|
|
8
28
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
29
|
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"]);
|
|
10
30
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -12,6 +32,7 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
12
32
|
"set", "stop",
|
|
13
33
|
"svg", "switch", "symbol", "text", "textPath",
|
|
14
34
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
35
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
15
36
|
const SVGNamespace = {
|
|
16
37
|
xlink: "http://www.w3.org/1999/xlink",
|
|
17
38
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
@@ -101,16 +122,16 @@ function render$1(code, element, init, options = {}) {
|
|
|
101
122
|
element.textContent = "";
|
|
102
123
|
};
|
|
103
124
|
}
|
|
104
|
-
function
|
|
125
|
+
function create(html, bypassGuard, flag) {
|
|
126
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
127
|
+
const t = document.createElement("template");
|
|
128
|
+
t.innerHTML = html;
|
|
129
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
130
|
+
}
|
|
131
|
+
function template(html, flag) {
|
|
105
132
|
let node;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
109
|
-
t.innerHTML = html;
|
|
110
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
111
|
-
};
|
|
112
|
-
const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
|
|
113
|
-
fn._html = html;
|
|
133
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
134
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
114
135
|
return fn;
|
|
115
136
|
}
|
|
116
137
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -139,16 +160,16 @@ function setAttribute(node, name, value) {
|
|
|
139
160
|
}
|
|
140
161
|
function setAttributeNS(node, namespace, name, value) {
|
|
141
162
|
if (isHydrating(node)) return;
|
|
142
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
163
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
143
164
|
}
|
|
144
|
-
function className(node, value,
|
|
165
|
+
function className(node, value, prev) {
|
|
145
166
|
if (isHydrating(node)) return;
|
|
146
167
|
if (value == null || value === false) {
|
|
147
168
|
prev && node.removeAttribute("class");
|
|
148
169
|
return;
|
|
149
170
|
}
|
|
150
171
|
if (typeof value === "string") {
|
|
151
|
-
value !== prev &&
|
|
172
|
+
value !== prev && node.setAttribute("class", value);
|
|
152
173
|
return;
|
|
153
174
|
}
|
|
154
175
|
if (typeof prev === "string") {
|
|
@@ -203,7 +224,7 @@ function style(node, value, prev) {
|
|
|
203
224
|
function setStyleProperty(node, name, value) {
|
|
204
225
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
205
226
|
}
|
|
206
|
-
function spread(node, props = {},
|
|
227
|
+
function spread(node, props = {}, skipChildren) {
|
|
207
228
|
const prevProps = {};
|
|
208
229
|
if (!skipChildren) insert(node, () => props.children);
|
|
209
230
|
effect(() => {
|
|
@@ -217,7 +238,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
217
238
|
newProps[prop] = props[prop];
|
|
218
239
|
}
|
|
219
240
|
return newProps;
|
|
220
|
-
}, props => assign(node, props,
|
|
241
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
221
242
|
return prevProps;
|
|
222
243
|
}
|
|
223
244
|
function dynamicProperty(props, key) {
|
|
@@ -262,12 +283,13 @@ function insert(parent, accessor, marker, initial) {
|
|
|
262
283
|
}
|
|
263
284
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
264
285
|
}
|
|
265
|
-
function assign(node, props,
|
|
286
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
287
|
+
const nodeName = node.nodeName;
|
|
266
288
|
props || (props = {});
|
|
267
289
|
for (const prop in prevProps) {
|
|
268
290
|
if (!(prop in props)) {
|
|
269
291
|
if (prop === "children") continue;
|
|
270
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
292
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
271
293
|
}
|
|
272
294
|
}
|
|
273
295
|
for (const prop in props) {
|
|
@@ -275,8 +297,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
275
297
|
if (!skipChildren) insertExpression(node, props.children);
|
|
276
298
|
continue;
|
|
277
299
|
}
|
|
278
|
-
|
|
279
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
300
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
280
301
|
}
|
|
281
302
|
}
|
|
282
303
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -310,10 +331,8 @@ function hydrate$1(code, element, options = {}) {
|
|
|
310
331
|
{
|
|
311
332
|
solidJs.sharedConfig.verifyHydration = () => {
|
|
312
333
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
|
|
313
|
-
const orphaned = [];
|
|
314
|
-
|
|
315
|
-
if (node.isConnected) orphaned.push(node);else solidJs.sharedConfig.registry.delete(key);
|
|
316
|
-
}
|
|
334
|
+
const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
335
|
+
solidJs.sharedConfig.registry.clear();
|
|
317
336
|
if (!orphaned.length) return;
|
|
318
337
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
319
338
|
}
|
|
@@ -456,14 +475,16 @@ function flattenClassList(list, result) {
|
|
|
456
475
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
457
476
|
}
|
|
458
477
|
}
|
|
459
|
-
function assignProp(node, prop, value, prev,
|
|
460
|
-
let forceProp;
|
|
478
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
461
479
|
if (prop === "style") return style(node, value, prev), value;
|
|
462
|
-
if (prop === "class") return className(node, value,
|
|
463
|
-
if (value === prev) return prev;
|
|
480
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
481
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
464
482
|
if (prop === "ref") {
|
|
465
483
|
if (!skipRef && value) ref(() => value, node);
|
|
466
|
-
|
|
484
|
+
return value;
|
|
485
|
+
}
|
|
486
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
487
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
467
488
|
const e = prop.slice(3);
|
|
468
489
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
469
490
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -478,11 +499,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
478
499
|
addEventListener(node, name, value, delegate);
|
|
479
500
|
delegate && delegateEvents([name]);
|
|
480
501
|
}
|
|
481
|
-
} else if (
|
|
482
|
-
if (
|
|
483
|
-
if (prop === "value" &&
|
|
502
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
|
|
503
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
504
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
484
505
|
} else {
|
|
485
|
-
const ns =
|
|
506
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
486
507
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
487
508
|
}
|
|
488
509
|
return value;
|
|
@@ -564,7 +585,6 @@ function insertExpression(parent, value, current, marker) {
|
|
|
564
585
|
appendNodes(parent, value, marker);
|
|
565
586
|
} else reconcileArrays(parent, current, value);
|
|
566
587
|
} else {
|
|
567
|
-
if (current && current.nodeType) clearHydrationRegistry(current);
|
|
568
588
|
current && cleanChildren(parent);
|
|
569
589
|
appendNodes(parent, value);
|
|
570
590
|
}
|
|
@@ -590,18 +610,6 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
590
610
|
function appendNodes(parent, array, marker = null) {
|
|
591
611
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
592
612
|
}
|
|
593
|
-
function clearHydrationRegistry(node) {
|
|
594
|
-
if (!solidJs.sharedConfig.registry || !node || node.nodeType !== 1) return;
|
|
595
|
-
const key = node.getAttribute("_hk");
|
|
596
|
-
if (key) solidJs.sharedConfig.registry.delete(key);
|
|
597
|
-
const descendants = node.querySelectorAll?.(`*[_hk]`);
|
|
598
|
-
if (descendants) {
|
|
599
|
-
for (let i = 0; i < descendants.length; i++) {
|
|
600
|
-
const descendantKey = descendants[i].getAttribute("_hk");
|
|
601
|
-
if (descendantKey) solidJs.sharedConfig.registry.delete(descendantKey);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
613
|
function cleanChildren(parent, current, marker, replacement) {
|
|
606
614
|
if (marker === undefined) return parent.textContent = "";
|
|
607
615
|
if (current.length) {
|
|
@@ -610,10 +618,7 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
610
618
|
const el = current[i];
|
|
611
619
|
if (replacement !== el) {
|
|
612
620
|
const isParent = el.parentNode === parent;
|
|
613
|
-
if (replacement && !inserted && !i) isParent ?
|
|
614
|
-
clearHydrationRegistry(el);
|
|
615
|
-
el.remove();
|
|
616
|
-
}
|
|
621
|
+
if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
|
|
617
622
|
} else inserted = true;
|
|
618
623
|
}
|
|
619
624
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
@@ -783,11 +788,12 @@ Object.defineProperty(exports, "untrack", {
|
|
|
783
788
|
exports.Assets = voidFn;
|
|
784
789
|
exports.ChildProperties = ChildProperties;
|
|
785
790
|
exports.DOMElements = DOMElements;
|
|
791
|
+
exports.DOMWithState = DOMWithState;
|
|
786
792
|
exports.DelegatedEvents = DelegatedEvents;
|
|
787
793
|
exports.Dynamic = Dynamic;
|
|
788
794
|
exports.HydrationScript = voidFn;
|
|
795
|
+
exports.MathMLElements = MathMLElements;
|
|
789
796
|
exports.Portal = Portal;
|
|
790
|
-
exports.Properties = Properties;
|
|
791
797
|
exports.RequestContext = RequestContext;
|
|
792
798
|
exports.SVGElements = SVGElements;
|
|
793
799
|
exports.SVGNamespace = SVGNamespace;
|
package/dist/dev.js
CHANGED
|
@@ -2,8 +2,28 @@ import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack,
|
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
3
|
import { createMemo } from '@solidjs/signals';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const DOMWithState = {
|
|
6
|
+
INPUT: {
|
|
7
|
+
value: 1,
|
|
8
|
+
checked: 1
|
|
9
|
+
},
|
|
10
|
+
SELECT: {
|
|
11
|
+
value: 1
|
|
12
|
+
},
|
|
13
|
+
OPTION: {
|
|
14
|
+
value: 1,
|
|
15
|
+
selected: 1
|
|
16
|
+
},
|
|
17
|
+
TEXTAREA: {
|
|
18
|
+
value: 1
|
|
19
|
+
},
|
|
20
|
+
VIDEO: {
|
|
21
|
+
muted: 1
|
|
22
|
+
},
|
|
23
|
+
AUDIO: {
|
|
24
|
+
muted: 1
|
|
25
|
+
}
|
|
26
|
+
};
|
|
7
27
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
28
|
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"]);
|
|
9
29
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -11,6 +31,7 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
11
31
|
"set", "stop",
|
|
12
32
|
"svg", "switch", "symbol", "text", "textPath",
|
|
13
33
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
34
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
14
35
|
const SVGNamespace = {
|
|
15
36
|
xlink: "http://www.w3.org/1999/xlink",
|
|
16
37
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
@@ -100,16 +121,16 @@ function render$1(code, element, init, options = {}) {
|
|
|
100
121
|
element.textContent = "";
|
|
101
122
|
};
|
|
102
123
|
}
|
|
103
|
-
function
|
|
124
|
+
function create(html, bypassGuard, flag) {
|
|
125
|
+
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
126
|
+
const t = document.createElement("template");
|
|
127
|
+
t.innerHTML = html;
|
|
128
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
129
|
+
}
|
|
130
|
+
function template(html, flag) {
|
|
104
131
|
let node;
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
108
|
-
t.innerHTML = html;
|
|
109
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
110
|
-
};
|
|
111
|
-
const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
|
|
112
|
-
fn._html = html;
|
|
132
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
133
|
+
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
113
134
|
return fn;
|
|
114
135
|
}
|
|
115
136
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -138,16 +159,16 @@ function setAttribute(node, name, value) {
|
|
|
138
159
|
}
|
|
139
160
|
function setAttributeNS(node, namespace, name, value) {
|
|
140
161
|
if (isHydrating(node)) return;
|
|
141
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
162
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
142
163
|
}
|
|
143
|
-
function className(node, value,
|
|
164
|
+
function className(node, value, prev) {
|
|
144
165
|
if (isHydrating(node)) return;
|
|
145
166
|
if (value == null || value === false) {
|
|
146
167
|
prev && node.removeAttribute("class");
|
|
147
168
|
return;
|
|
148
169
|
}
|
|
149
170
|
if (typeof value === "string") {
|
|
150
|
-
value !== prev &&
|
|
171
|
+
value !== prev && node.setAttribute("class", value);
|
|
151
172
|
return;
|
|
152
173
|
}
|
|
153
174
|
if (typeof prev === "string") {
|
|
@@ -202,7 +223,7 @@ function style(node, value, prev) {
|
|
|
202
223
|
function setStyleProperty(node, name, value) {
|
|
203
224
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
204
225
|
}
|
|
205
|
-
function spread(node, props = {},
|
|
226
|
+
function spread(node, props = {}, skipChildren) {
|
|
206
227
|
const prevProps = {};
|
|
207
228
|
if (!skipChildren) insert(node, () => props.children);
|
|
208
229
|
effect(() => {
|
|
@@ -216,7 +237,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
216
237
|
newProps[prop] = props[prop];
|
|
217
238
|
}
|
|
218
239
|
return newProps;
|
|
219
|
-
}, props => assign(node, props,
|
|
240
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
220
241
|
return prevProps;
|
|
221
242
|
}
|
|
222
243
|
function dynamicProperty(props, key) {
|
|
@@ -261,12 +282,13 @@ function insert(parent, accessor, marker, initial) {
|
|
|
261
282
|
}
|
|
262
283
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
263
284
|
}
|
|
264
|
-
function assign(node, props,
|
|
285
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
286
|
+
const nodeName = node.nodeName;
|
|
265
287
|
props || (props = {});
|
|
266
288
|
for (const prop in prevProps) {
|
|
267
289
|
if (!(prop in props)) {
|
|
268
290
|
if (prop === "children") continue;
|
|
269
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
291
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
270
292
|
}
|
|
271
293
|
}
|
|
272
294
|
for (const prop in props) {
|
|
@@ -274,8 +296,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
274
296
|
if (!skipChildren) insertExpression(node, props.children);
|
|
275
297
|
continue;
|
|
276
298
|
}
|
|
277
|
-
|
|
278
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
299
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
279
300
|
}
|
|
280
301
|
}
|
|
281
302
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -309,10 +330,8 @@ function hydrate$1(code, element, options = {}) {
|
|
|
309
330
|
{
|
|
310
331
|
sharedConfig.verifyHydration = () => {
|
|
311
332
|
if (sharedConfig.registry && sharedConfig.registry.size) {
|
|
312
|
-
const orphaned = [];
|
|
313
|
-
|
|
314
|
-
if (node.isConnected) orphaned.push(node);else sharedConfig.registry.delete(key);
|
|
315
|
-
}
|
|
333
|
+
const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
334
|
+
sharedConfig.registry.clear();
|
|
316
335
|
if (!orphaned.length) return;
|
|
317
336
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
318
337
|
}
|
|
@@ -455,14 +474,16 @@ function flattenClassList(list, result) {
|
|
|
455
474
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
456
475
|
}
|
|
457
476
|
}
|
|
458
|
-
function assignProp(node, prop, value, prev,
|
|
459
|
-
let forceProp;
|
|
477
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
460
478
|
if (prop === "style") return style(node, value, prev), value;
|
|
461
|
-
if (prop === "class") return className(node, value,
|
|
462
|
-
if (value === prev) return prev;
|
|
479
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
480
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
463
481
|
if (prop === "ref") {
|
|
464
482
|
if (!skipRef && value) ref(() => value, node);
|
|
465
|
-
|
|
483
|
+
return value;
|
|
484
|
+
}
|
|
485
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
486
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
466
487
|
const e = prop.slice(3);
|
|
467
488
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
468
489
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -477,11 +498,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
477
498
|
addEventListener(node, name, value, delegate);
|
|
478
499
|
delegate && delegateEvents([name]);
|
|
479
500
|
}
|
|
480
|
-
} else if (
|
|
481
|
-
if (
|
|
482
|
-
if (prop === "value" &&
|
|
501
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
|
|
502
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
503
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
483
504
|
} else {
|
|
484
|
-
const ns =
|
|
505
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
485
506
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
486
507
|
}
|
|
487
508
|
return value;
|
|
@@ -563,7 +584,6 @@ function insertExpression(parent, value, current, marker) {
|
|
|
563
584
|
appendNodes(parent, value, marker);
|
|
564
585
|
} else reconcileArrays(parent, current, value);
|
|
565
586
|
} else {
|
|
566
|
-
if (current && current.nodeType) clearHydrationRegistry(current);
|
|
567
587
|
current && cleanChildren(parent);
|
|
568
588
|
appendNodes(parent, value);
|
|
569
589
|
}
|
|
@@ -589,18 +609,6 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
589
609
|
function appendNodes(parent, array, marker = null) {
|
|
590
610
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
591
611
|
}
|
|
592
|
-
function clearHydrationRegistry(node) {
|
|
593
|
-
if (!sharedConfig.registry || !node || node.nodeType !== 1) return;
|
|
594
|
-
const key = node.getAttribute("_hk");
|
|
595
|
-
if (key) sharedConfig.registry.delete(key);
|
|
596
|
-
const descendants = node.querySelectorAll?.(`*[_hk]`);
|
|
597
|
-
if (descendants) {
|
|
598
|
-
for (let i = 0; i < descendants.length; i++) {
|
|
599
|
-
const descendantKey = descendants[i].getAttribute("_hk");
|
|
600
|
-
if (descendantKey) sharedConfig.registry.delete(descendantKey);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
612
|
function cleanChildren(parent, current, marker, replacement) {
|
|
605
613
|
if (marker === undefined) return parent.textContent = "";
|
|
606
614
|
if (current.length) {
|
|
@@ -609,10 +617,7 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
609
617
|
const el = current[i];
|
|
610
618
|
if (replacement !== el) {
|
|
611
619
|
const isParent = el.parentNode === parent;
|
|
612
|
-
if (replacement && !inserted && !i) isParent ?
|
|
613
|
-
clearHydrationRegistry(el);
|
|
614
|
-
el.remove();
|
|
615
|
-
}
|
|
620
|
+
if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
|
|
616
621
|
} else inserted = true;
|
|
617
622
|
}
|
|
618
623
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
@@ -731,4 +736,4 @@ function Dynamic(props) {
|
|
|
731
736
|
return createDynamic(() => props.component, others);
|
|
732
737
|
}
|
|
733
738
|
|
|
734
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript,
|
|
739
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Portal, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
|
package/dist/server.cjs
CHANGED
|
@@ -5,8 +5,6 @@ var seroval = require('seroval');
|
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
6
|
var signals = require('@solidjs/signals');
|
|
7
7
|
|
|
8
|
-
const Properties = /*#__PURE__*/new Set([
|
|
9
|
-
"value", "checked", "selected", "muted"]);
|
|
10
8
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
11
9
|
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"]);
|
|
12
10
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -915,7 +913,6 @@ exports.DelegatedEvents = DelegatedEvents;
|
|
|
915
913
|
exports.Dynamic = Dynamic;
|
|
916
914
|
exports.HydrationScript = HydrationScript;
|
|
917
915
|
exports.Portal = Portal;
|
|
918
|
-
exports.Properties = Properties;
|
|
919
916
|
exports.RequestContext = RequestContext;
|
|
920
917
|
exports.SVGElements = SVGElements;
|
|
921
918
|
exports.SVGNamespace = SVGNamespace;
|
package/dist/server.js
CHANGED
|
@@ -4,8 +4,6 @@ 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
|
import { createMemo } from '@solidjs/signals';
|
|
6
6
|
|
|
7
|
-
const Properties = /*#__PURE__*/new Set([
|
|
8
|
-
"value", "checked", "selected", "muted"]);
|
|
9
7
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
10
8
|
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"]);
|
|
11
9
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -856,4 +854,4 @@ function Portal(props) {
|
|
|
856
854
|
throw new Error("Portal is not supported on the server");
|
|
857
855
|
}
|
|
858
856
|
|
|
859
|
-
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, Portal,
|
|
857
|
+
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, Portal, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, applyRef, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };
|
package/dist/web.cjs
CHANGED
|
@@ -3,8 +3,28 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
var signals = require('@solidjs/signals');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const DOMWithState = {
|
|
7
|
+
INPUT: {
|
|
8
|
+
value: 1,
|
|
9
|
+
checked: 1
|
|
10
|
+
},
|
|
11
|
+
SELECT: {
|
|
12
|
+
value: 1
|
|
13
|
+
},
|
|
14
|
+
OPTION: {
|
|
15
|
+
value: 1,
|
|
16
|
+
selected: 1
|
|
17
|
+
},
|
|
18
|
+
TEXTAREA: {
|
|
19
|
+
value: 1
|
|
20
|
+
},
|
|
21
|
+
VIDEO: {
|
|
22
|
+
muted: 1
|
|
23
|
+
},
|
|
24
|
+
AUDIO: {
|
|
25
|
+
muted: 1
|
|
26
|
+
}
|
|
27
|
+
};
|
|
8
28
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
29
|
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"]);
|
|
10
30
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -12,6 +32,7 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
12
32
|
"set", "stop",
|
|
13
33
|
"svg", "switch", "symbol", "text", "textPath",
|
|
14
34
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
35
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
15
36
|
const SVGNamespace = {
|
|
16
37
|
xlink: "http://www.w3.org/1999/xlink",
|
|
17
38
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
@@ -98,14 +119,14 @@ function render$1(code, element, init, options = {}) {
|
|
|
98
119
|
element.textContent = "";
|
|
99
120
|
};
|
|
100
121
|
}
|
|
101
|
-
function
|
|
122
|
+
function create(html, bypassGuard, flag) {
|
|
123
|
+
const t = document.createElement("template");
|
|
124
|
+
t.innerHTML = html;
|
|
125
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
126
|
+
}
|
|
127
|
+
function template(html, flag) {
|
|
102
128
|
let node;
|
|
103
|
-
const
|
|
104
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
105
|
-
t.innerHTML = html;
|
|
106
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
107
|
-
};
|
|
108
|
-
const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
|
|
129
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
109
130
|
return fn;
|
|
110
131
|
}
|
|
111
132
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -134,16 +155,16 @@ function setAttribute(node, name, value) {
|
|
|
134
155
|
}
|
|
135
156
|
function setAttributeNS(node, namespace, name, value) {
|
|
136
157
|
if (isHydrating(node)) return;
|
|
137
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
158
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
138
159
|
}
|
|
139
|
-
function className(node, value,
|
|
160
|
+
function className(node, value, prev) {
|
|
140
161
|
if (isHydrating(node)) return;
|
|
141
162
|
if (value == null || value === false) {
|
|
142
163
|
prev && node.removeAttribute("class");
|
|
143
164
|
return;
|
|
144
165
|
}
|
|
145
166
|
if (typeof value === "string") {
|
|
146
|
-
value !== prev &&
|
|
167
|
+
value !== prev && node.setAttribute("class", value);
|
|
147
168
|
return;
|
|
148
169
|
}
|
|
149
170
|
if (typeof prev === "string") {
|
|
@@ -198,7 +219,7 @@ function style(node, value, prev) {
|
|
|
198
219
|
function setStyleProperty(node, name, value) {
|
|
199
220
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
200
221
|
}
|
|
201
|
-
function spread(node, props = {},
|
|
222
|
+
function spread(node, props = {}, skipChildren) {
|
|
202
223
|
const prevProps = {};
|
|
203
224
|
if (!skipChildren) insert(node, () => props.children);
|
|
204
225
|
effect(() => {
|
|
@@ -212,7 +233,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
212
233
|
newProps[prop] = props[prop];
|
|
213
234
|
}
|
|
214
235
|
return newProps;
|
|
215
|
-
}, props => assign(node, props,
|
|
236
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
216
237
|
return prevProps;
|
|
217
238
|
}
|
|
218
239
|
function dynamicProperty(props, key) {
|
|
@@ -257,12 +278,13 @@ function insert(parent, accessor, marker, initial) {
|
|
|
257
278
|
}
|
|
258
279
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
259
280
|
}
|
|
260
|
-
function assign(node, props,
|
|
281
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
282
|
+
const nodeName = node.nodeName;
|
|
261
283
|
props || (props = {});
|
|
262
284
|
for (const prop in prevProps) {
|
|
263
285
|
if (!(prop in props)) {
|
|
264
286
|
if (prop === "children") continue;
|
|
265
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
287
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
266
288
|
}
|
|
267
289
|
}
|
|
268
290
|
for (const prop in props) {
|
|
@@ -270,8 +292,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
270
292
|
if (!skipChildren) insertExpression(node, props.children);
|
|
271
293
|
continue;
|
|
272
294
|
}
|
|
273
|
-
|
|
274
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
295
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
275
296
|
}
|
|
276
297
|
}
|
|
277
298
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -398,14 +419,16 @@ function flattenClassList(list, result) {
|
|
|
398
419
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
399
420
|
}
|
|
400
421
|
}
|
|
401
|
-
function assignProp(node, prop, value, prev,
|
|
402
|
-
let forceProp;
|
|
422
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
403
423
|
if (prop === "style") return style(node, value, prev), value;
|
|
404
|
-
if (prop === "class") return className(node, value,
|
|
405
|
-
if (value === prev) return prev;
|
|
424
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
425
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
406
426
|
if (prop === "ref") {
|
|
407
427
|
if (!skipRef && value) ref(() => value, node);
|
|
408
|
-
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
430
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
431
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
409
432
|
const e = prop.slice(3);
|
|
410
433
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
411
434
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -420,11 +443,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
420
443
|
addEventListener(node, name, value, delegate);
|
|
421
444
|
delegate && delegateEvents([name]);
|
|
422
445
|
}
|
|
423
|
-
} else if (
|
|
424
|
-
if (
|
|
425
|
-
if (prop === "value" &&
|
|
446
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
|
|
447
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
448
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
426
449
|
} else {
|
|
427
|
-
const ns =
|
|
450
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
428
451
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
429
452
|
}
|
|
430
453
|
return value;
|
|
@@ -506,7 +529,6 @@ function insertExpression(parent, value, current, marker) {
|
|
|
506
529
|
appendNodes(parent, value, marker);
|
|
507
530
|
} else reconcileArrays(parent, current, value);
|
|
508
531
|
} else {
|
|
509
|
-
if (current && current.nodeType) clearHydrationRegistry(current);
|
|
510
532
|
current && cleanChildren(parent);
|
|
511
533
|
appendNodes(parent, value);
|
|
512
534
|
}
|
|
@@ -532,18 +554,6 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
532
554
|
function appendNodes(parent, array, marker = null) {
|
|
533
555
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
534
556
|
}
|
|
535
|
-
function clearHydrationRegistry(node) {
|
|
536
|
-
if (!solidJs.sharedConfig.registry || !node || node.nodeType !== 1) return;
|
|
537
|
-
const key = node.getAttribute("_hk");
|
|
538
|
-
if (key) solidJs.sharedConfig.registry.delete(key);
|
|
539
|
-
const descendants = node.querySelectorAll?.(`*[_hk]`);
|
|
540
|
-
if (descendants) {
|
|
541
|
-
for (let i = 0; i < descendants.length; i++) {
|
|
542
|
-
const descendantKey = descendants[i].getAttribute("_hk");
|
|
543
|
-
if (descendantKey) solidJs.sharedConfig.registry.delete(descendantKey);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
557
|
function cleanChildren(parent, current, marker, replacement) {
|
|
548
558
|
if (marker === undefined) return parent.textContent = "";
|
|
549
559
|
if (current.length) {
|
|
@@ -552,10 +562,7 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
552
562
|
const el = current[i];
|
|
553
563
|
if (replacement !== el) {
|
|
554
564
|
const isParent = el.parentNode === parent;
|
|
555
|
-
if (replacement && !inserted && !i) isParent ?
|
|
556
|
-
clearHydrationRegistry(el);
|
|
557
|
-
el.remove();
|
|
558
|
-
}
|
|
565
|
+
if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
|
|
559
566
|
} else inserted = true;
|
|
560
567
|
}
|
|
561
568
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
@@ -720,11 +727,12 @@ Object.defineProperty(exports, "untrack", {
|
|
|
720
727
|
exports.Assets = voidFn;
|
|
721
728
|
exports.ChildProperties = ChildProperties;
|
|
722
729
|
exports.DOMElements = DOMElements;
|
|
730
|
+
exports.DOMWithState = DOMWithState;
|
|
723
731
|
exports.DelegatedEvents = DelegatedEvents;
|
|
724
732
|
exports.Dynamic = Dynamic;
|
|
725
733
|
exports.HydrationScript = voidFn;
|
|
734
|
+
exports.MathMLElements = MathMLElements;
|
|
726
735
|
exports.Portal = Portal;
|
|
727
|
-
exports.Properties = Properties;
|
|
728
736
|
exports.RequestContext = RequestContext;
|
|
729
737
|
exports.SVGElements = SVGElements;
|
|
730
738
|
exports.SVGNamespace = SVGNamespace;
|
package/dist/web.js
CHANGED
|
@@ -2,8 +2,28 @@ import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack,
|
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
3
|
import { createMemo } from '@solidjs/signals';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const DOMWithState = {
|
|
6
|
+
INPUT: {
|
|
7
|
+
value: 1,
|
|
8
|
+
checked: 1
|
|
9
|
+
},
|
|
10
|
+
SELECT: {
|
|
11
|
+
value: 1
|
|
12
|
+
},
|
|
13
|
+
OPTION: {
|
|
14
|
+
value: 1,
|
|
15
|
+
selected: 1
|
|
16
|
+
},
|
|
17
|
+
TEXTAREA: {
|
|
18
|
+
value: 1
|
|
19
|
+
},
|
|
20
|
+
VIDEO: {
|
|
21
|
+
muted: 1
|
|
22
|
+
},
|
|
23
|
+
AUDIO: {
|
|
24
|
+
muted: 1
|
|
25
|
+
}
|
|
26
|
+
};
|
|
7
27
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
28
|
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"]);
|
|
9
29
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -11,6 +31,7 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
11
31
|
"set", "stop",
|
|
12
32
|
"svg", "switch", "symbol", "text", "textPath",
|
|
13
33
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
34
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
14
35
|
const SVGNamespace = {
|
|
15
36
|
xlink: "http://www.w3.org/1999/xlink",
|
|
16
37
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
@@ -97,14 +118,14 @@ function render$1(code, element, init, options = {}) {
|
|
|
97
118
|
element.textContent = "";
|
|
98
119
|
};
|
|
99
120
|
}
|
|
100
|
-
function
|
|
121
|
+
function create(html, bypassGuard, flag) {
|
|
122
|
+
const t = document.createElement("template");
|
|
123
|
+
t.innerHTML = html;
|
|
124
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
125
|
+
}
|
|
126
|
+
function template(html, flag) {
|
|
101
127
|
let node;
|
|
102
|
-
const
|
|
103
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
104
|
-
t.innerHTML = html;
|
|
105
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
106
|
-
};
|
|
107
|
-
const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
|
|
128
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
108
129
|
return fn;
|
|
109
130
|
}
|
|
110
131
|
function delegateEvents(eventNames, document = window.document) {
|
|
@@ -133,16 +154,16 @@ function setAttribute(node, name, value) {
|
|
|
133
154
|
}
|
|
134
155
|
function setAttributeNS(node, namespace, name, value) {
|
|
135
156
|
if (isHydrating(node)) return;
|
|
136
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
157
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
137
158
|
}
|
|
138
|
-
function className(node, value,
|
|
159
|
+
function className(node, value, prev) {
|
|
139
160
|
if (isHydrating(node)) return;
|
|
140
161
|
if (value == null || value === false) {
|
|
141
162
|
prev && node.removeAttribute("class");
|
|
142
163
|
return;
|
|
143
164
|
}
|
|
144
165
|
if (typeof value === "string") {
|
|
145
|
-
value !== prev &&
|
|
166
|
+
value !== prev && node.setAttribute("class", value);
|
|
146
167
|
return;
|
|
147
168
|
}
|
|
148
169
|
if (typeof prev === "string") {
|
|
@@ -197,7 +218,7 @@ function style(node, value, prev) {
|
|
|
197
218
|
function setStyleProperty(node, name, value) {
|
|
198
219
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
199
220
|
}
|
|
200
|
-
function spread(node, props = {},
|
|
221
|
+
function spread(node, props = {}, skipChildren) {
|
|
201
222
|
const prevProps = {};
|
|
202
223
|
if (!skipChildren) insert(node, () => props.children);
|
|
203
224
|
effect(() => {
|
|
@@ -211,7 +232,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
211
232
|
newProps[prop] = props[prop];
|
|
212
233
|
}
|
|
213
234
|
return newProps;
|
|
214
|
-
}, props => assign(node, props,
|
|
235
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
215
236
|
return prevProps;
|
|
216
237
|
}
|
|
217
238
|
function dynamicProperty(props, key) {
|
|
@@ -256,12 +277,13 @@ function insert(parent, accessor, marker, initial) {
|
|
|
256
277
|
}
|
|
257
278
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
258
279
|
}
|
|
259
|
-
function assign(node, props,
|
|
280
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
281
|
+
const nodeName = node.nodeName;
|
|
260
282
|
props || (props = {});
|
|
261
283
|
for (const prop in prevProps) {
|
|
262
284
|
if (!(prop in props)) {
|
|
263
285
|
if (prop === "children") continue;
|
|
264
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
286
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
265
287
|
}
|
|
266
288
|
}
|
|
267
289
|
for (const prop in props) {
|
|
@@ -269,8 +291,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
269
291
|
if (!skipChildren) insertExpression(node, props.children);
|
|
270
292
|
continue;
|
|
271
293
|
}
|
|
272
|
-
|
|
273
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
294
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
274
295
|
}
|
|
275
296
|
}
|
|
276
297
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -397,14 +418,16 @@ function flattenClassList(list, result) {
|
|
|
397
418
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
398
419
|
}
|
|
399
420
|
}
|
|
400
|
-
function assignProp(node, prop, value, prev,
|
|
401
|
-
let forceProp;
|
|
421
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
402
422
|
if (prop === "style") return style(node, value, prev), value;
|
|
403
|
-
if (prop === "class") return className(node, value,
|
|
404
|
-
if (value === prev) return prev;
|
|
423
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
424
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
405
425
|
if (prop === "ref") {
|
|
406
426
|
if (!skipRef && value) ref(() => value, node);
|
|
407
|
-
|
|
427
|
+
return value;
|
|
428
|
+
}
|
|
429
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
430
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
408
431
|
const e = prop.slice(3);
|
|
409
432
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
410
433
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -419,11 +442,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
419
442
|
addEventListener(node, name, value, delegate);
|
|
420
443
|
delegate && delegateEvents([name]);
|
|
421
444
|
}
|
|
422
|
-
} else if (
|
|
423
|
-
if (
|
|
424
|
-
if (prop === "value" &&
|
|
445
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
|
|
446
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
447
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
425
448
|
} else {
|
|
426
|
-
const ns =
|
|
449
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
427
450
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
428
451
|
}
|
|
429
452
|
return value;
|
|
@@ -505,7 +528,6 @@ function insertExpression(parent, value, current, marker) {
|
|
|
505
528
|
appendNodes(parent, value, marker);
|
|
506
529
|
} else reconcileArrays(parent, current, value);
|
|
507
530
|
} else {
|
|
508
|
-
if (current && current.nodeType) clearHydrationRegistry(current);
|
|
509
531
|
current && cleanChildren(parent);
|
|
510
532
|
appendNodes(parent, value);
|
|
511
533
|
}
|
|
@@ -531,18 +553,6 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
531
553
|
function appendNodes(parent, array, marker = null) {
|
|
532
554
|
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
|
|
533
555
|
}
|
|
534
|
-
function clearHydrationRegistry(node) {
|
|
535
|
-
if (!sharedConfig.registry || !node || node.nodeType !== 1) return;
|
|
536
|
-
const key = node.getAttribute("_hk");
|
|
537
|
-
if (key) sharedConfig.registry.delete(key);
|
|
538
|
-
const descendants = node.querySelectorAll?.(`*[_hk]`);
|
|
539
|
-
if (descendants) {
|
|
540
|
-
for (let i = 0; i < descendants.length; i++) {
|
|
541
|
-
const descendantKey = descendants[i].getAttribute("_hk");
|
|
542
|
-
if (descendantKey) sharedConfig.registry.delete(descendantKey);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
556
|
function cleanChildren(parent, current, marker, replacement) {
|
|
547
557
|
if (marker === undefined) return parent.textContent = "";
|
|
548
558
|
if (current.length) {
|
|
@@ -551,10 +561,7 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
551
561
|
const el = current[i];
|
|
552
562
|
if (replacement !== el) {
|
|
553
563
|
const isParent = el.parentNode === parent;
|
|
554
|
-
if (replacement && !inserted && !i) isParent ?
|
|
555
|
-
clearHydrationRegistry(el);
|
|
556
|
-
el.remove();
|
|
557
|
-
}
|
|
564
|
+
if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
|
|
558
565
|
} else inserted = true;
|
|
559
566
|
}
|
|
560
567
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
@@ -668,4 +675,4 @@ function Dynamic(props) {
|
|
|
668
675
|
return createDynamic(() => props.component, others);
|
|
669
676
|
}
|
|
670
677
|
|
|
671
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript,
|
|
678
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Portal, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, 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 for the browser and the server",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.5",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -75,11 +75,12 @@
|
|
|
75
75
|
"seroval-plugins": "^1.1.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"
|
|
79
|
-
"
|
|
78
|
+
"@solidjs/signals": "^0.13.9",
|
|
79
|
+
"solid-js": "^2.0.0-beta.5"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"
|
|
82
|
+
"@solidjs/signals": "^0.13.9",
|
|
83
|
+
"solid-js": "2.0.0-beta.5"
|
|
83
84
|
},
|
|
84
85
|
"scripts": {
|
|
85
86
|
"build": "npm-run-all -nl build:*",
|
package/types/client.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { JSX } from "./jsx.js";
|
|
2
|
-
export const
|
|
2
|
+
export const DOMWithState: Record<string, Record<string, number>>;
|
|
3
3
|
export const ChildProperties: Set<string>;
|
|
4
4
|
export const DelegatedEvents: Set<string>;
|
|
5
5
|
export const DOMElements: Set<string>;
|
|
6
6
|
export const SVGElements: Set<string>;
|
|
7
|
+
export const MathMLElements: Set<string>;
|
|
7
8
|
export const SVGNamespace: Record<string, string>;
|
|
8
9
|
|
|
9
10
|
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
@@ -13,7 +14,7 @@ export function render(
|
|
|
13
14
|
init?: JSX.Element,
|
|
14
15
|
options?: { owner?: unknown }
|
|
15
16
|
): () => void;
|
|
16
|
-
export function template(html: string,
|
|
17
|
+
export function template(html: string, flag?: number): () => Element;
|
|
17
18
|
export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void, init?: T): void;
|
|
18
19
|
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
19
20
|
export function untrack<T>(fn: () => T): T;
|
|
@@ -29,13 +30,11 @@ export function clearDelegatedEvents(d?: Document): void;
|
|
|
29
30
|
export function spread<T>(
|
|
30
31
|
node: Element,
|
|
31
32
|
accessor: T,
|
|
32
|
-
isSVG?: Boolean,
|
|
33
33
|
skipChildren?: Boolean
|
|
34
34
|
): void;
|
|
35
35
|
export function assign(
|
|
36
36
|
node: Element,
|
|
37
37
|
props: any,
|
|
38
|
-
isSVG?: Boolean,
|
|
39
38
|
skipChildren?: Boolean,
|
|
40
39
|
prevProps?: any,
|
|
41
40
|
skipRef?: Boolean
|
|
@@ -45,7 +44,7 @@ export function setAttributeNS(node: Element, namespace: string, name: string, v
|
|
|
45
44
|
type ClassList =
|
|
46
45
|
| Record<string, boolean>
|
|
47
46
|
| Array<string | number | boolean | null | undefined | Record<string, boolean>>;
|
|
48
|
-
export function className(node: Element, value: string | ClassList,
|
|
47
|
+
export function className(node: Element, value: string | ClassList, prev?: string | ClassList): void;
|
|
49
48
|
export function setProperty(node: Element, name: string, value: any): void;
|
|
50
49
|
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
51
50
|
export function addEventListener(
|
package/types/server.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSX } from "./jsx.js";
|
|
2
|
-
export const Properties: Set<string>;
|
|
3
2
|
export const ChildProperties: Set<string>;
|
|
4
3
|
export const DelegatedEvents: Set<string>;
|
|
5
4
|
export const DOMElements: Set<string>;
|
|
@@ -107,7 +106,6 @@ export function insert<T>(
|
|
|
107
106
|
export function spread<T>(
|
|
108
107
|
node: Element,
|
|
109
108
|
accessor: T,
|
|
110
|
-
isSVG?: Boolean,
|
|
111
109
|
skipChildren?: Boolean
|
|
112
110
|
): void;
|
|
113
111
|
|
|
@@ -131,13 +129,13 @@ export function addEventListener(
|
|
|
131
129
|
/** @deprecated not supported on the server side */
|
|
132
130
|
export function render(code: () => JSX.Element, element: MountableElement): () => void;
|
|
133
131
|
/** @deprecated not supported on the server side */
|
|
134
|
-
export function template(html: string,
|
|
132
|
+
export function template(html: string, flag?: number): () => Element;
|
|
135
133
|
/** @deprecated not supported on the server side */
|
|
136
134
|
export function setProperty(node: Element, name: string, value: any): void;
|
|
137
135
|
/** @deprecated not supported on the server side */
|
|
138
136
|
export function className(node: Element, value: string): void;
|
|
139
137
|
/** @deprecated not supported on the server side */
|
|
140
|
-
export function assign(node: Element, props: any,
|
|
138
|
+
export function assign(node: Element, props: any, skipChildren?: Boolean): void;
|
|
141
139
|
|
|
142
140
|
/** @deprecated not supported on the server side */
|
|
143
141
|
export function hydrate(
|