@solidjs/web 2.0.0-beta.13 → 2.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +213 -69
- package/dist/dev.js +209 -69
- package/dist/server.cjs +41 -1
- package/dist/server.js +32 -1
- package/dist/web.cjs +213 -69
- package/dist/web.js +209 -69
- package/package.json +3 -3
- package/types/client.d.ts +14 -11
- package/types/jsx-properties.d.ts +1 -0
- package/types/jsx.d.ts +50 -8
- package/types/server.d.ts +26 -7
- package/types-cjs/client.d.cts +14 -11
- package/types-cjs/jsx-properties.d.cts +1 -0
- package/types-cjs/jsx.d.cts +50 -8
- package/types-cjs/server.d.cts +26 -7
package/dist/web.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, enableHydration, flush } from 'solid-js';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createEffect, enableHydration, flush } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
const DOMWithState = {
|
|
@@ -30,6 +30,7 @@ const DOMWithState = {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
33
34
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
34
35
|
const SVGElements = /*#__PURE__*/new Set([
|
|
35
36
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -63,14 +64,18 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
|
|
|
63
64
|
} : transparentOptions);
|
|
64
65
|
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
65
66
|
|
|
66
|
-
function reconcileArrays(parentNode, a, b) {
|
|
67
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
67
68
|
let bLength = b.length,
|
|
68
69
|
aEnd = a.length,
|
|
69
70
|
bEnd = bLength,
|
|
70
71
|
aStart = 0,
|
|
71
72
|
bStart = 0,
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
tail = a[aEnd - 1],
|
|
74
|
+
tailTag = tail[$$SLOT],
|
|
75
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
76
|
+
map = null,
|
|
77
|
+
anchor,
|
|
78
|
+
anchorTag;
|
|
74
79
|
while (aStart < aEnd || bStart < bEnd) {
|
|
75
80
|
if (a[aStart] === b[bStart]) {
|
|
76
81
|
aStart++;
|
|
@@ -82,20 +87,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
82
87
|
bEnd--;
|
|
83
88
|
}
|
|
84
89
|
if (aEnd === aStart) {
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
let node;
|
|
91
|
+
if (bEnd < bLength) {
|
|
92
|
+
if (bStart) {
|
|
93
|
+
const prev = b[bStart - 1];
|
|
94
|
+
const prevTag = prev[$$SLOT];
|
|
95
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
96
|
+
} else node = b[bEnd - bStart];
|
|
97
|
+
} else node = after;
|
|
98
|
+
while (bStart < bEnd) {
|
|
99
|
+
const n = b[bStart++];
|
|
100
|
+
parentNode.insertBefore(n, node);
|
|
101
|
+
if (marker) n[$$SLOT] = marker;
|
|
102
|
+
}
|
|
87
103
|
} else if (bEnd === bStart) {
|
|
88
104
|
while (aStart < aEnd) {
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
const n = a[aStart++];
|
|
106
|
+
if (!map || !map.has(n)) {
|
|
107
|
+
const tag = n[$$SLOT];
|
|
108
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
112
|
+
if (marker) {
|
|
113
|
+
do {
|
|
114
|
+
const n = a[--aEnd];
|
|
115
|
+
parentNode.insertBefore(n, anchor);
|
|
116
|
+
n[$$SLOT] = marker;
|
|
117
|
+
bStart++;
|
|
118
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
119
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
120
|
+
} else {
|
|
121
|
+
do {
|
|
122
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
123
|
+
bStart++;
|
|
124
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
125
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
91
126
|
}
|
|
92
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
93
|
-
const anchor = a[aStart];
|
|
94
|
-
do {
|
|
95
|
-
parentNode.insertBefore(a[--aEnd], anchor);
|
|
96
|
-
bStart++;
|
|
97
|
-
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
98
|
-
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
99
127
|
} else {
|
|
100
128
|
if (!map) {
|
|
101
129
|
map = new Map();
|
|
@@ -113,33 +141,63 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
113
141
|
sequence++;
|
|
114
142
|
}
|
|
115
143
|
if (sequence > index - bStart) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
const head = a[aStart];
|
|
145
|
+
const headTag = head[$$SLOT];
|
|
146
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
147
|
+
while (bStart < index) {
|
|
148
|
+
const n = b[bStart++];
|
|
149
|
+
parentNode.insertBefore(n, node);
|
|
150
|
+
if (marker) n[$$SLOT] = marker;
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
const oldNode = a[aStart++];
|
|
154
|
+
const newNode = b[bStart++];
|
|
155
|
+
const oldTag = oldNode[$$SLOT];
|
|
156
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
157
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
158
|
+
} else {
|
|
159
|
+
parentNode.insertBefore(newNode, after);
|
|
160
|
+
}
|
|
161
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
162
|
+
}
|
|
119
163
|
} else aStart++;
|
|
120
|
-
} else
|
|
164
|
+
} else {
|
|
165
|
+
const n = a[aStart++];
|
|
166
|
+
const nTag = n[$$SLOT];
|
|
167
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
168
|
+
}
|
|
121
169
|
}
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
172
|
|
|
125
|
-
const $$
|
|
173
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
126
174
|
const INNER_OWNED = {};
|
|
175
|
+
const delegatedEvents = new Set();
|
|
176
|
+
const delegatedContainers = new Map();
|
|
127
177
|
function render$1(code, element, init, options = {}) {
|
|
128
178
|
let disposer;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
179
|
+
registerDelegatedRoot(element);
|
|
180
|
+
try {
|
|
181
|
+
createRoot(dispose => {
|
|
182
|
+
disposer = dispose;
|
|
183
|
+
if (element === document) {
|
|
184
|
+
const tree = code();
|
|
185
|
+
effect(() => flatten(tree), () => {});
|
|
186
|
+
} else {
|
|
187
|
+
const tree = code();
|
|
188
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
id: options.renderId
|
|
192
|
+
});
|
|
193
|
+
} catch (err) {
|
|
194
|
+
if (disposer) disposer();
|
|
195
|
+
unregisterDelegatedRoot(element);
|
|
196
|
+
throw err;
|
|
197
|
+
}
|
|
141
198
|
return () => {
|
|
142
199
|
disposer();
|
|
200
|
+
unregisterDelegatedRoot(element);
|
|
143
201
|
element.textContent = "";
|
|
144
202
|
};
|
|
145
203
|
}
|
|
@@ -153,20 +211,66 @@ function template(html, flag) {
|
|
|
153
211
|
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
154
212
|
return fn;
|
|
155
213
|
}
|
|
156
|
-
function delegateEvents(eventNames
|
|
157
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
214
|
+
function delegateEvents(eventNames) {
|
|
158
215
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
159
216
|
const name = eventNames[i];
|
|
160
|
-
if (!
|
|
161
|
-
|
|
162
|
-
|
|
217
|
+
if (!delegatedEvents.has(name)) {
|
|
218
|
+
delegatedEvents.add(name);
|
|
219
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
163
220
|
}
|
|
164
221
|
}
|
|
165
222
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
223
|
+
function registerDelegatedRoot(root) {
|
|
224
|
+
const state = registerDelegatedContainer(root, root);
|
|
225
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
226
|
+
}
|
|
227
|
+
function unregisterDelegatedRoot(root) {
|
|
228
|
+
const state = delegatedContainers.get(root);
|
|
229
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
230
|
+
unregisterDelegatedContainer(root, root);
|
|
231
|
+
}
|
|
232
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
233
|
+
if (!container || !owner) return;
|
|
234
|
+
let state = delegatedContainers.get(container);
|
|
235
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
236
|
+
owners: new Map(),
|
|
237
|
+
handlers: new Map()
|
|
238
|
+
});
|
|
239
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
240
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
241
|
+
return state;
|
|
242
|
+
}
|
|
243
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
244
|
+
const state = delegatedContainers.get(container);
|
|
245
|
+
if (!state) return;
|
|
246
|
+
const count = state.owners.get(owner);
|
|
247
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
248
|
+
if (state.owners.size) return;
|
|
249
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
250
|
+
delegatedContainers.delete(container);
|
|
251
|
+
}
|
|
252
|
+
function attachDelegatedEvent(name, container, state) {
|
|
253
|
+
if (state.handlers.has(name)) return;
|
|
254
|
+
const handler = e => eventHandler(e, container, state);
|
|
255
|
+
state.handlers.set(name, handler);
|
|
256
|
+
container.addEventListener(name, handler);
|
|
257
|
+
}
|
|
258
|
+
function getDelegatedRoot(node) {
|
|
259
|
+
while (node) {
|
|
260
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
261
|
+
node = node._$host || node.parentNode || node.host;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function findOwner(target, state) {
|
|
265
|
+
let node = target;
|
|
266
|
+
let distance = 0;
|
|
267
|
+
while (node) {
|
|
268
|
+
if (state.owners.has(node)) return {
|
|
269
|
+
owner: node,
|
|
270
|
+
distance
|
|
271
|
+
};
|
|
272
|
+
distance++;
|
|
273
|
+
node = node._$host || node.parentNode || node.host;
|
|
170
274
|
}
|
|
171
275
|
}
|
|
172
276
|
function setProperty(node, name, value) {
|
|
@@ -211,7 +315,7 @@ function className(node, value, prev) {
|
|
|
211
315
|
node.classList.add(key);
|
|
212
316
|
}
|
|
213
317
|
}
|
|
214
|
-
function
|
|
318
|
+
function addEvent(node, name, handler, delegate) {
|
|
215
319
|
if (delegate) {
|
|
216
320
|
if (Array.isArray(handler)) {
|
|
217
321
|
node[`$$${name}`] = handler[0];
|
|
@@ -461,7 +565,17 @@ function runHydrationEvents() {
|
|
|
461
565
|
const [el, e] = events[0];
|
|
462
566
|
if (!completed.has(el)) return;
|
|
463
567
|
events.shift();
|
|
464
|
-
|
|
568
|
+
let match;
|
|
569
|
+
for (const [container, state] of delegatedContainers) {
|
|
570
|
+
if (!state.handlers.has(e.type)) continue;
|
|
571
|
+
const entry = findOwner(e.target, state);
|
|
572
|
+
if (entry && (!match || entry.distance < match.distance)) match = {
|
|
573
|
+
container,
|
|
574
|
+
state,
|
|
575
|
+
distance: entry.distance
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
if (match) eventHandler(e, match.container, match.state);
|
|
465
579
|
}
|
|
466
580
|
if (sharedConfig.done) {
|
|
467
581
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -516,7 +630,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
516
630
|
node.removeEventListener(name, h);
|
|
517
631
|
}
|
|
518
632
|
if (delegate || value) {
|
|
519
|
-
|
|
633
|
+
addEvent(node, name, value, delegate);
|
|
520
634
|
delegate && delegateEvents([name]);
|
|
521
635
|
}
|
|
522
636
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
@@ -528,14 +642,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
528
642
|
}
|
|
529
643
|
return value;
|
|
530
644
|
}
|
|
531
|
-
function eventHandler(e) {
|
|
645
|
+
function eventHandler(e, container, state) {
|
|
532
646
|
if (sharedConfig.registry && sharedConfig.events) {
|
|
533
647
|
if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
534
648
|
}
|
|
649
|
+
if (e[$$EVENT_OWNER]) return;
|
|
650
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
651
|
+
if (state && !owner) return;
|
|
652
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
535
653
|
let node = e.target;
|
|
536
654
|
const key = `$$${e.type}`;
|
|
537
655
|
const oriTarget = e.target;
|
|
538
|
-
const
|
|
656
|
+
const boundary = owner || container || e.currentTarget;
|
|
539
657
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
540
658
|
configurable: true,
|
|
541
659
|
value
|
|
@@ -551,29 +669,34 @@ function eventHandler(e) {
|
|
|
551
669
|
return true;
|
|
552
670
|
};
|
|
553
671
|
const walkUpTree = () => {
|
|
554
|
-
while (handleNode()
|
|
672
|
+
while (handleNode()) {
|
|
673
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
674
|
+
node = node._$host || node.parentNode || node.host;
|
|
675
|
+
}
|
|
555
676
|
};
|
|
556
677
|
Object.defineProperty(e, "currentTarget", {
|
|
557
678
|
configurable: true,
|
|
558
679
|
get() {
|
|
559
|
-
return node || document;
|
|
680
|
+
return node || boundary || document;
|
|
560
681
|
}
|
|
561
682
|
});
|
|
562
683
|
if (e.composedPath) {
|
|
563
684
|
const path = e.composedPath();
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
685
|
+
if (path.length) {
|
|
686
|
+
retarget(path[0]);
|
|
687
|
+
for (let i = 0; i < path.length; i++) {
|
|
688
|
+
node = path[i];
|
|
689
|
+
if (!handleNode()) break;
|
|
690
|
+
if (node._$host) {
|
|
691
|
+
node = node._$host;
|
|
692
|
+
walkUpTree();
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
575
698
|
}
|
|
576
|
-
}
|
|
699
|
+
} else walkUpTree();
|
|
577
700
|
}
|
|
578
701
|
else walkUpTree();
|
|
579
702
|
retarget(oriTarget);
|
|
@@ -593,9 +716,14 @@ function insertExpression(parent, value, current, marker) {
|
|
|
593
716
|
} else if (value.nodeType) {
|
|
594
717
|
if (Array.isArray(current)) {
|
|
595
718
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
596
|
-
} else if (current
|
|
719
|
+
} else if (current && current.nodeType) {
|
|
720
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
721
|
+
} else if (current && parent.firstChild) {
|
|
722
|
+
parent.replaceChild(value, parent.firstChild);
|
|
723
|
+
} else {
|
|
597
724
|
parent.appendChild(value);
|
|
598
|
-
}
|
|
725
|
+
}
|
|
726
|
+
if (marker) value[$$SLOT] = marker;
|
|
599
727
|
} else if (Array.isArray(value)) {
|
|
600
728
|
const currentArray = current && Array.isArray(current);
|
|
601
729
|
if (value.length === 0) {
|
|
@@ -603,7 +731,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
603
731
|
} else if (currentArray) {
|
|
604
732
|
if (current.length === 0) {
|
|
605
733
|
appendNodes(parent, value, marker);
|
|
606
|
-
} else reconcileArrays(parent, current, value);
|
|
734
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
607
735
|
} else {
|
|
608
736
|
current && cleanChildren(parent);
|
|
609
737
|
appendNodes(parent, value);
|
|
@@ -628,7 +756,11 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
628
756
|
return value;
|
|
629
757
|
}
|
|
630
758
|
function appendNodes(parent, array, marker = null) {
|
|
631
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
759
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
760
|
+
const n = array[i];
|
|
761
|
+
parent.insertBefore(n, marker);
|
|
762
|
+
if (marker) n[$$SLOT] = marker;
|
|
763
|
+
}
|
|
632
764
|
}
|
|
633
765
|
function cleanChildren(parent, current, marker, replacement) {
|
|
634
766
|
if (marker === undefined) return parent.textContent = "";
|
|
@@ -637,11 +769,13 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
637
769
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
638
770
|
const el = current[i];
|
|
639
771
|
if (replacement !== el) {
|
|
640
|
-
const
|
|
641
|
-
|
|
772
|
+
const tag = el[$$SLOT];
|
|
773
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
774
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
642
775
|
} else inserted = true;
|
|
643
776
|
}
|
|
644
777
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
778
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
645
779
|
}
|
|
646
780
|
function gatherHydratable(element, root) {
|
|
647
781
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -703,8 +837,8 @@ function Portal(props) {
|
|
|
703
837
|
const treeMarker = document.createTextNode(""),
|
|
704
838
|
startMarker = document.createTextNode(""),
|
|
705
839
|
endMarker = document.createTextNode(""),
|
|
706
|
-
mount = () => createElementProxy(props.mount || document.body, treeMarker)
|
|
707
|
-
|
|
840
|
+
mount = () => createElementProxy(props.mount || document.body, treeMarker),
|
|
841
|
+
content = createMemo(() => [startMarker, props.children]);
|
|
708
842
|
createRenderEffect(() => [mount(), content()], ([m, c]) => {
|
|
709
843
|
m.appendChild(endMarker);
|
|
710
844
|
insert(m, c, endMarker);
|
|
@@ -717,6 +851,12 @@ function Portal(props) {
|
|
|
717
851
|
}
|
|
718
852
|
};
|
|
719
853
|
});
|
|
854
|
+
createEffect(mount, m => {
|
|
855
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
856
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
857
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
858
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
859
|
+
});
|
|
720
860
|
return treeMarker;
|
|
721
861
|
}
|
|
722
862
|
function dynamic(source) {
|
|
@@ -764,4 +904,4 @@ function createElementProxy(el, marker) {
|
|
|
764
904
|
});
|
|
765
905
|
}
|
|
766
906
|
|
|
767
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements,
|
|
907
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, registerDelegatedContainer, registerDelegatedRoot, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.14",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -137,10 +137,10 @@
|
|
|
137
137
|
"seroval-plugins": "^1.1.0"
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"solid-js": "^2.0.0-beta.
|
|
140
|
+
"solid-js": "^2.0.0-beta.14"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
|
-
"solid-js": "2.0.0-beta.
|
|
143
|
+
"solid-js": "2.0.0-beta.14"
|
|
144
144
|
},
|
|
145
145
|
"scripts": {
|
|
146
146
|
"build": "npm-run-all -nl build:clean types:copy-jsx build:js",
|
package/types/client.d.ts
CHANGED
|
@@ -33,8 +33,18 @@ export function insert<T>(
|
|
|
33
33
|
init?: JSX.Element
|
|
34
34
|
): JSX.Element;
|
|
35
35
|
export function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
36
|
-
export function delegateEvents(eventNames: string[]
|
|
37
|
-
export function
|
|
36
|
+
export function delegateEvents(eventNames: string[]): void;
|
|
37
|
+
export function registerDelegatedRoot(root: MountableElement): void;
|
|
38
|
+
export function unregisterDelegatedRoot(root: MountableElement): void;
|
|
39
|
+
export function registerDelegatedContainer(
|
|
40
|
+
container: MountableElement,
|
|
41
|
+
owner?: MountableElement
|
|
42
|
+
): void;
|
|
43
|
+
export function unregisterDelegatedContainer(
|
|
44
|
+
container: MountableElement,
|
|
45
|
+
owner?: MountableElement
|
|
46
|
+
): void;
|
|
47
|
+
export function getDelegatedRoot(node: MountableElement): MountableElement | undefined;
|
|
38
48
|
export function spread<T>(node: Element, accessor: T, skipChildren?: Boolean): void;
|
|
39
49
|
export function assign(
|
|
40
50
|
node: Element,
|
|
@@ -45,17 +55,10 @@ export function assign(
|
|
|
45
55
|
): void;
|
|
46
56
|
export function setAttribute(node: Element, name: string, value: string): void;
|
|
47
57
|
export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
|
|
48
|
-
|
|
49
|
-
| Record<string, boolean>
|
|
50
|
-
| Array<string | number | boolean | null | undefined | Record<string, boolean>>;
|
|
51
|
-
export function className(
|
|
52
|
-
node: Element,
|
|
53
|
-
value: string | ClassList,
|
|
54
|
-
prev?: string | ClassList
|
|
55
|
-
): void;
|
|
58
|
+
export function className(node: Element, value: JSX.ClassValue, prev?: JSX.ClassValue): void;
|
|
56
59
|
export function setProperty(node: Element, name: string, value: any): void;
|
|
57
60
|
export function setStyleProperty(node: Element, name: string, value: any): void;
|
|
58
|
-
export function
|
|
61
|
+
export function addEvent(
|
|
59
62
|
node: Element,
|
|
60
63
|
name: string,
|
|
61
64
|
handler: EventListener | EventListenerObject | (EventListenerObject & AddEventListenerOptions),
|
package/types/jsx.d.ts
CHANGED
|
@@ -224,7 +224,8 @@ export namespace JSX {
|
|
|
224
224
|
>;
|
|
225
225
|
// end event handlers
|
|
226
226
|
|
|
227
|
-
type
|
|
227
|
+
export type ClassValue =
|
|
228
|
+
| string
|
|
228
229
|
| Record<string, boolean>
|
|
229
230
|
| Array<string | number | boolean | null | undefined | Record<string, boolean>>;
|
|
230
231
|
|
|
@@ -269,11 +270,6 @@ export namespace JSX {
|
|
|
269
270
|
|
|
270
271
|
// TODO: Should we allow this?
|
|
271
272
|
// type ClassKeys = `class:${string}`;
|
|
272
|
-
// type CSSKeys = Exclude<keyof csstype.PropertiesHyphen, `-${string}`>;
|
|
273
|
-
|
|
274
|
-
// type CSSAttributes = {
|
|
275
|
-
// [key in CSSKeys as `style:${key}`]: csstype.PropertiesHyphen[key];
|
|
276
|
-
// };
|
|
277
273
|
|
|
278
274
|
// BOOLEAN
|
|
279
275
|
|
|
@@ -859,6 +855,20 @@ export namespace JSX {
|
|
|
859
855
|
: never)
|
|
860
856
|
| (string & {});
|
|
861
857
|
|
|
858
|
+
type ExtractEventType<T> = {
|
|
859
|
+
[K in keyof T as K extends `on${infer Name}` ? Name : never]: T[K] extends EventHandlerUnion<
|
|
860
|
+
Element,
|
|
861
|
+
infer E
|
|
862
|
+
>
|
|
863
|
+
? E
|
|
864
|
+
: never;
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// EventType["click"] = MouseEvent
|
|
868
|
+
|
|
869
|
+
type EventType = ExtractEventType<EventHandlersElement<Element>> &
|
|
870
|
+
ExtractEventType<EventHandlersWindow<Element>>;
|
|
871
|
+
|
|
862
872
|
// GLOBAL ATTRIBUTES
|
|
863
873
|
|
|
864
874
|
/**
|
|
@@ -890,7 +900,7 @@ export namespace JSX {
|
|
|
890
900
|
* with reactive values directly; manually-built strings re-run the whole
|
|
891
901
|
* concatenation on every change instead of toggling the affected classes.
|
|
892
902
|
*/
|
|
893
|
-
class?:
|
|
903
|
+
class?: ClassValue | RemoveAttribute;
|
|
894
904
|
elementtiming?: string | RemoveAttribute;
|
|
895
905
|
id?: string | RemoveAttribute;
|
|
896
906
|
nonce?: string | RemoveAttribute;
|
|
@@ -1532,6 +1542,10 @@ export namespace JSX {
|
|
|
1532
1542
|
src?: string | RemoveAttribute;
|
|
1533
1543
|
|
|
1534
1544
|
onEncrypted?: EventHandlerUnion<T, MediaEncryptedEvent> | undefined;
|
|
1545
|
+
onWaitingForKey?: EventHandlerUnion<T, Event> | undefined;
|
|
1546
|
+
|
|
1547
|
+
/** @deprecated */
|
|
1548
|
+
mediagroup?: string | RemoveAttribute;
|
|
1535
1549
|
|
|
1536
1550
|
// special cases locked to properties
|
|
1537
1551
|
|
|
@@ -1866,6 +1880,11 @@ export namespace JSX {
|
|
|
1866
1880
|
width?: number | string | RemoveAttribute;
|
|
1867
1881
|
|
|
1868
1882
|
onEnterPictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
|
|
1883
|
+
onLeavePictureInPicture?: EventHandlerUnion<T, PictureInPictureEvent> | undefined;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
1887
|
+
allowpopups?: BooleanAttribute | RemoveAttribute;
|
|
1869
1888
|
disableblinkfeatures?: string | RemoveAttribute;
|
|
1870
1889
|
disablewebsecurity?: BooleanAttribute | RemoveAttribute;
|
|
1871
1890
|
enableblinkfeatures?: string | RemoveAttribute;
|
|
@@ -1968,7 +1987,7 @@ export namespace JSX {
|
|
|
1968
1987
|
* with reactive values directly; manually-built strings re-run the whole
|
|
1969
1988
|
* concatenation on every change instead of toggling the affected classes.
|
|
1970
1989
|
*/
|
|
1971
|
-
class?:
|
|
1990
|
+
class?: ClassValue | RemoveAttribute;
|
|
1972
1991
|
style?: CSSProperties | string | RemoveAttribute;
|
|
1973
1992
|
}
|
|
1974
1993
|
interface TransformableSVGAttributes {
|
|
@@ -2140,6 +2159,29 @@ export namespace JSX {
|
|
|
2140
2159
|
interface AnimationElementSVGAttributes<T>
|
|
2141
2160
|
extends SVGAttributes<T>, ExternalResourceSVGAttributes, ConditionalProcessingSVGAttributes {
|
|
2142
2161
|
onBegin?: EventHandlerUnion<T, TimeEvent> | undefined;
|
|
2162
|
+
onEnd?: EventHandlerUnion<T, TimeEvent> | undefined;
|
|
2163
|
+
onRepeat?: EventHandlerUnion<T, TimeEvent> | undefined;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
interface ContainerElementSVGAttributes<T>
|
|
2167
|
+
extends
|
|
2168
|
+
SVGAttributes<T>,
|
|
2169
|
+
ShapeElementSVGAttributes<T>,
|
|
2170
|
+
Pick<
|
|
2171
|
+
PresentationSVGAttributes,
|
|
2172
|
+
| "clip-path"
|
|
2173
|
+
| "mask"
|
|
2174
|
+
| "cursor"
|
|
2175
|
+
| "opacity"
|
|
2176
|
+
| "filter"
|
|
2177
|
+
| "enable-background"
|
|
2178
|
+
| "color-interpolation"
|
|
2179
|
+
| "color-rendering"
|
|
2180
|
+
> {}
|
|
2181
|
+
|
|
2182
|
+
interface FilterPrimitiveElementSVGAttributes<T>
|
|
2183
|
+
extends SVGAttributes<T>, Pick<PresentationSVGAttributes, "color-interpolation-filters"> {
|
|
2184
|
+
height?: number | string | RemoveAttribute;
|
|
2143
2185
|
result?: string | RemoveAttribute;
|
|
2144
2186
|
width?: number | string | RemoveAttribute;
|
|
2145
2187
|
x?: number | string | RemoveAttribute;
|