@solidjs/web 2.0.0-beta.3 → 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 +59 -38
- package/dist/dev.js +58 -38
- package/dist/server.cjs +0 -3
- package/dist/server.js +1 -3
- package/dist/web.cjs +54 -35
- package/dist/web.js +53 -35
- 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,14 +224,9 @@ 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
|
-
if (!skipChildren)
|
|
209
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
210
|
-
insertExpression(node, value, prevProps.children);
|
|
211
|
-
prevProps.children = value;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
229
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
214
230
|
effect(() => {
|
|
215
231
|
const r = props.ref;
|
|
216
232
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -222,7 +238,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
222
238
|
newProps[prop] = props[prop];
|
|
223
239
|
}
|
|
224
240
|
return newProps;
|
|
225
|
-
}, props => assign(node, props,
|
|
241
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
226
242
|
return prevProps;
|
|
227
243
|
}
|
|
228
244
|
function dynamicProperty(props, key) {
|
|
@@ -260,19 +276,20 @@ function insert(parent, accessor, marker, initial) {
|
|
|
260
276
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
261
277
|
}
|
|
262
278
|
accessor = memo(accessor, true);
|
|
263
|
-
if (multi && initial.length === 0
|
|
279
|
+
if (multi && initial.length === 0) {
|
|
264
280
|
const placeholder = document.createTextNode("");
|
|
265
281
|
parent.insertBefore(placeholder, marker);
|
|
266
282
|
initial = [placeholder];
|
|
267
283
|
}
|
|
268
284
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
269
285
|
}
|
|
270
|
-
function assign(node, props,
|
|
286
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
287
|
+
const nodeName = node.nodeName;
|
|
271
288
|
props || (props = {});
|
|
272
289
|
for (const prop in prevProps) {
|
|
273
290
|
if (!(prop in props)) {
|
|
274
291
|
if (prop === "children") continue;
|
|
275
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
292
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
276
293
|
}
|
|
277
294
|
}
|
|
278
295
|
for (const prop in props) {
|
|
@@ -280,8 +297,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
280
297
|
if (!skipChildren) insertExpression(node, props.children);
|
|
281
298
|
continue;
|
|
282
299
|
}
|
|
283
|
-
|
|
284
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
300
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
285
301
|
}
|
|
286
302
|
}
|
|
287
303
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -315,7 +331,9 @@ function hydrate$1(code, element, options = {}) {
|
|
|
315
331
|
{
|
|
316
332
|
solidJs.sharedConfig.verifyHydration = () => {
|
|
317
333
|
if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
|
|
318
|
-
const orphaned = [...solidJs.sharedConfig.registry.values()];
|
|
334
|
+
const orphaned = [...solidJs.sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
335
|
+
solidJs.sharedConfig.registry.clear();
|
|
336
|
+
if (!orphaned.length) return;
|
|
319
337
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
320
338
|
}
|
|
321
339
|
};
|
|
@@ -457,14 +475,16 @@ function flattenClassList(list, result) {
|
|
|
457
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;
|
|
458
476
|
}
|
|
459
477
|
}
|
|
460
|
-
function assignProp(node, prop, value, prev,
|
|
461
|
-
let forceProp;
|
|
478
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
462
479
|
if (prop === "style") return style(node, value, prev), value;
|
|
463
|
-
if (prop === "class") return className(node, value,
|
|
464
|
-
if (value === prev) return prev;
|
|
480
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
481
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
465
482
|
if (prop === "ref") {
|
|
466
483
|
if (!skipRef && value) ref(() => value, node);
|
|
467
|
-
|
|
484
|
+
return value;
|
|
485
|
+
}
|
|
486
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
487
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
468
488
|
const e = prop.slice(3);
|
|
469
489
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
470
490
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -479,11 +499,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
479
499
|
addEventListener(node, name, value, delegate);
|
|
480
500
|
delegate && delegateEvents([name]);
|
|
481
501
|
}
|
|
482
|
-
} else if (
|
|
483
|
-
if (
|
|
484
|
-
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;
|
|
485
505
|
} else {
|
|
486
|
-
const ns =
|
|
506
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
487
507
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
488
508
|
}
|
|
489
509
|
return value;
|
|
@@ -768,11 +788,12 @@ Object.defineProperty(exports, "untrack", {
|
|
|
768
788
|
exports.Assets = voidFn;
|
|
769
789
|
exports.ChildProperties = ChildProperties;
|
|
770
790
|
exports.DOMElements = DOMElements;
|
|
791
|
+
exports.DOMWithState = DOMWithState;
|
|
771
792
|
exports.DelegatedEvents = DelegatedEvents;
|
|
772
793
|
exports.Dynamic = Dynamic;
|
|
773
794
|
exports.HydrationScript = voidFn;
|
|
795
|
+
exports.MathMLElements = MathMLElements;
|
|
774
796
|
exports.Portal = Portal;
|
|
775
|
-
exports.Properties = Properties;
|
|
776
797
|
exports.RequestContext = RequestContext;
|
|
777
798
|
exports.SVGElements = SVGElements;
|
|
778
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,14 +223,9 @@ 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
|
-
if (!skipChildren)
|
|
208
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
209
|
-
insertExpression(node, value, prevProps.children);
|
|
210
|
-
prevProps.children = value;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
228
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
213
229
|
effect(() => {
|
|
214
230
|
const r = props.ref;
|
|
215
231
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -221,7 +237,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
221
237
|
newProps[prop] = props[prop];
|
|
222
238
|
}
|
|
223
239
|
return newProps;
|
|
224
|
-
}, props => assign(node, props,
|
|
240
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
225
241
|
return prevProps;
|
|
226
242
|
}
|
|
227
243
|
function dynamicProperty(props, key) {
|
|
@@ -259,19 +275,20 @@ function insert(parent, accessor, marker, initial) {
|
|
|
259
275
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
260
276
|
}
|
|
261
277
|
accessor = memo(accessor, true);
|
|
262
|
-
if (multi && initial.length === 0
|
|
278
|
+
if (multi && initial.length === 0) {
|
|
263
279
|
const placeholder = document.createTextNode("");
|
|
264
280
|
parent.insertBefore(placeholder, marker);
|
|
265
281
|
initial = [placeholder];
|
|
266
282
|
}
|
|
267
283
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
268
284
|
}
|
|
269
|
-
function assign(node, props,
|
|
285
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
286
|
+
const nodeName = node.nodeName;
|
|
270
287
|
props || (props = {});
|
|
271
288
|
for (const prop in prevProps) {
|
|
272
289
|
if (!(prop in props)) {
|
|
273
290
|
if (prop === "children") continue;
|
|
274
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
291
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
275
292
|
}
|
|
276
293
|
}
|
|
277
294
|
for (const prop in props) {
|
|
@@ -279,8 +296,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
279
296
|
if (!skipChildren) insertExpression(node, props.children);
|
|
280
297
|
continue;
|
|
281
298
|
}
|
|
282
|
-
|
|
283
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
299
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
284
300
|
}
|
|
285
301
|
}
|
|
286
302
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -314,7 +330,9 @@ function hydrate$1(code, element, options = {}) {
|
|
|
314
330
|
{
|
|
315
331
|
sharedConfig.verifyHydration = () => {
|
|
316
332
|
if (sharedConfig.registry && sharedConfig.registry.size) {
|
|
317
|
-
const orphaned = [...sharedConfig.registry.values()];
|
|
333
|
+
const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
334
|
+
sharedConfig.registry.clear();
|
|
335
|
+
if (!orphaned.length) return;
|
|
318
336
|
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
319
337
|
}
|
|
320
338
|
};
|
|
@@ -456,14 +474,16 @@ function flattenClassList(list, result) {
|
|
|
456
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;
|
|
457
475
|
}
|
|
458
476
|
}
|
|
459
|
-
function assignProp(node, prop, value, prev,
|
|
460
|
-
let forceProp;
|
|
477
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
461
478
|
if (prop === "style") return style(node, value, prev), value;
|
|
462
|
-
if (prop === "class") return className(node, value,
|
|
463
|
-
if (value === prev) return prev;
|
|
479
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
480
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
464
481
|
if (prop === "ref") {
|
|
465
482
|
if (!skipRef && value) ref(() => value, node);
|
|
466
|
-
|
|
483
|
+
return value;
|
|
484
|
+
}
|
|
485
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
486
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
467
487
|
const e = prop.slice(3);
|
|
468
488
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
469
489
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -478,11 +498,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
478
498
|
addEventListener(node, name, value, delegate);
|
|
479
499
|
delegate && delegateEvents([name]);
|
|
480
500
|
}
|
|
481
|
-
} else if (
|
|
482
|
-
if (
|
|
483
|
-
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;
|
|
484
504
|
} else {
|
|
485
|
-
const ns =
|
|
505
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
486
506
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
487
507
|
}
|
|
488
508
|
return value;
|
|
@@ -716,4 +736,4 @@ function Dynamic(props) {
|
|
|
716
736
|
return createDynamic(() => props.component, others);
|
|
717
737
|
}
|
|
718
738
|
|
|
719
|
-
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,14 +219,9 @@ 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
|
-
if (!skipChildren)
|
|
204
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
205
|
-
insertExpression(node, value, prevProps.children);
|
|
206
|
-
prevProps.children = value;
|
|
207
|
-
});
|
|
208
|
-
}
|
|
224
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
209
225
|
effect(() => {
|
|
210
226
|
const r = props.ref;
|
|
211
227
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -217,7 +233,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
217
233
|
newProps[prop] = props[prop];
|
|
218
234
|
}
|
|
219
235
|
return newProps;
|
|
220
|
-
}, props => assign(node, props,
|
|
236
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
221
237
|
return prevProps;
|
|
222
238
|
}
|
|
223
239
|
function dynamicProperty(props, key) {
|
|
@@ -255,19 +271,20 @@ function insert(parent, accessor, marker, initial) {
|
|
|
255
271
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
256
272
|
}
|
|
257
273
|
accessor = memo(accessor, true);
|
|
258
|
-
if (multi && initial.length === 0
|
|
274
|
+
if (multi && initial.length === 0) {
|
|
259
275
|
const placeholder = document.createTextNode("");
|
|
260
276
|
parent.insertBefore(placeholder, marker);
|
|
261
277
|
initial = [placeholder];
|
|
262
278
|
}
|
|
263
279
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
264
280
|
}
|
|
265
|
-
function assign(node, props,
|
|
281
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
282
|
+
const nodeName = node.nodeName;
|
|
266
283
|
props || (props = {});
|
|
267
284
|
for (const prop in prevProps) {
|
|
268
285
|
if (!(prop in props)) {
|
|
269
286
|
if (prop === "children") continue;
|
|
270
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
287
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
271
288
|
}
|
|
272
289
|
}
|
|
273
290
|
for (const prop in props) {
|
|
@@ -275,8 +292,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
275
292
|
if (!skipChildren) insertExpression(node, props.children);
|
|
276
293
|
continue;
|
|
277
294
|
}
|
|
278
|
-
|
|
279
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
295
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
280
296
|
}
|
|
281
297
|
}
|
|
282
298
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -403,14 +419,16 @@ function flattenClassList(list, result) {
|
|
|
403
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;
|
|
404
420
|
}
|
|
405
421
|
}
|
|
406
|
-
function assignProp(node, prop, value, prev,
|
|
407
|
-
let forceProp;
|
|
422
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
408
423
|
if (prop === "style") return style(node, value, prev), value;
|
|
409
|
-
if (prop === "class") return className(node, value,
|
|
410
|
-
if (value === prev) return prev;
|
|
424
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
425
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
411
426
|
if (prop === "ref") {
|
|
412
427
|
if (!skipRef && value) ref(() => value, node);
|
|
413
|
-
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
430
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
431
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
414
432
|
const e = prop.slice(3);
|
|
415
433
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
416
434
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -425,11 +443,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
425
443
|
addEventListener(node, name, value, delegate);
|
|
426
444
|
delegate && delegateEvents([name]);
|
|
427
445
|
}
|
|
428
|
-
} else if (
|
|
429
|
-
if (
|
|
430
|
-
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;
|
|
431
449
|
} else {
|
|
432
|
-
const ns =
|
|
450
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
433
451
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
434
452
|
}
|
|
435
453
|
return value;
|
|
@@ -709,11 +727,12 @@ Object.defineProperty(exports, "untrack", {
|
|
|
709
727
|
exports.Assets = voidFn;
|
|
710
728
|
exports.ChildProperties = ChildProperties;
|
|
711
729
|
exports.DOMElements = DOMElements;
|
|
730
|
+
exports.DOMWithState = DOMWithState;
|
|
712
731
|
exports.DelegatedEvents = DelegatedEvents;
|
|
713
732
|
exports.Dynamic = Dynamic;
|
|
714
733
|
exports.HydrationScript = voidFn;
|
|
734
|
+
exports.MathMLElements = MathMLElements;
|
|
715
735
|
exports.Portal = Portal;
|
|
716
|
-
exports.Properties = Properties;
|
|
717
736
|
exports.RequestContext = RequestContext;
|
|
718
737
|
exports.SVGElements = SVGElements;
|
|
719
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,14 +218,9 @@ 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
|
-
if (!skipChildren)
|
|
203
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
204
|
-
insertExpression(node, value, prevProps.children);
|
|
205
|
-
prevProps.children = value;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
223
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
208
224
|
effect(() => {
|
|
209
225
|
const r = props.ref;
|
|
210
226
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -216,7 +232,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
216
232
|
newProps[prop] = props[prop];
|
|
217
233
|
}
|
|
218
234
|
return newProps;
|
|
219
|
-
}, props => assign(node, props,
|
|
235
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
220
236
|
return prevProps;
|
|
221
237
|
}
|
|
222
238
|
function dynamicProperty(props, key) {
|
|
@@ -254,19 +270,20 @@ function insert(parent, accessor, marker, initial) {
|
|
|
254
270
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
255
271
|
}
|
|
256
272
|
accessor = memo(accessor, true);
|
|
257
|
-
if (multi && initial.length === 0
|
|
273
|
+
if (multi && initial.length === 0) {
|
|
258
274
|
const placeholder = document.createTextNode("");
|
|
259
275
|
parent.insertBefore(placeholder, marker);
|
|
260
276
|
initial = [placeholder];
|
|
261
277
|
}
|
|
262
278
|
effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
|
|
263
279
|
}
|
|
264
|
-
function assign(node, props,
|
|
280
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
281
|
+
const nodeName = node.nodeName;
|
|
265
282
|
props || (props = {});
|
|
266
283
|
for (const prop in prevProps) {
|
|
267
284
|
if (!(prop in props)) {
|
|
268
285
|
if (prop === "children") continue;
|
|
269
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
286
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
|
|
270
287
|
}
|
|
271
288
|
}
|
|
272
289
|
for (const prop in props) {
|
|
@@ -274,8 +291,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
|
|
|
274
291
|
if (!skipChildren) insertExpression(node, props.children);
|
|
275
292
|
continue;
|
|
276
293
|
}
|
|
277
|
-
|
|
278
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
294
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
|
|
279
295
|
}
|
|
280
296
|
}
|
|
281
297
|
function hydrate$1(code, element, options = {}) {
|
|
@@ -402,14 +418,16 @@ function flattenClassList(list, result) {
|
|
|
402
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;
|
|
403
419
|
}
|
|
404
420
|
}
|
|
405
|
-
function assignProp(node, prop, value, prev,
|
|
406
|
-
let forceProp;
|
|
421
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
|
|
407
422
|
if (prop === "style") return style(node, value, prev), value;
|
|
408
|
-
if (prop === "class") return className(node, value,
|
|
409
|
-
if (value === prev) return prev;
|
|
423
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
424
|
+
if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
|
|
410
425
|
if (prop === "ref") {
|
|
411
426
|
if (!skipRef && value) ref(() => value, node);
|
|
412
|
-
|
|
427
|
+
return value;
|
|
428
|
+
}
|
|
429
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
430
|
+
if (hasNamespace && prop.slice(0, 3) === "on:") {
|
|
413
431
|
const e = prop.slice(3);
|
|
414
432
|
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
|
|
415
433
|
value && node.addEventListener(e, value, typeof value !== "function" && value);
|
|
@@ -424,11 +442,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
424
442
|
addEventListener(node, name, value, delegate);
|
|
425
443
|
delegate && delegateEvents([name]);
|
|
426
444
|
}
|
|
427
|
-
} else if (
|
|
428
|
-
if (
|
|
429
|
-
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;
|
|
430
448
|
} else {
|
|
431
|
-
const ns =
|
|
449
|
+
const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
|
|
432
450
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
433
451
|
}
|
|
434
452
|
return value;
|
|
@@ -657,4 +675,4 @@ function Dynamic(props) {
|
|
|
657
675
|
return createDynamic(() => props.component, others);
|
|
658
676
|
}
|
|
659
677
|
|
|
660
|
-
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(
|