@solidjs/web 2.0.0-beta.12 → 2.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createEffect, $DEVCOMP, enableHydration, enforceLoadingBoundary, 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
- after = a[aEnd - 1].nextSibling,
73
- map = null;
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
- const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
86
- while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
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
- if (!map || !map.has(a[aStart])) a[aStart].remove();
90
- aStart++;
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,38 +141,67 @@ function reconcileArrays(parentNode, a, b) {
113
141
  sequence++;
114
142
  }
115
143
  if (sequence > index - bStart) {
116
- const node = a[aStart];
117
- while (bStart < index) parentNode.insertBefore(b[bStart++], node);
118
- } else parentNode.replaceChild(b[bStart++], a[aStart++]);
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 a[aStart++].remove();
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 $$EVENTS = "_$DX_DELEGATE";
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
  if (!element) {
129
179
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
130
180
  }
131
- const renderRoot = getChildRoot(element);
132
181
  let disposer;
133
- createRoot(dispose => {
134
- disposer = dispose;
135
- if (element === document) {
136
- const tree = code();
137
- effect(() => flatten(tree), () => {});
138
- } else {
139
- const tree = code();
140
- insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
141
- }
142
- }, {
143
- id: options.renderId
144
- });
182
+ registerDelegatedRoot(element);
183
+ try {
184
+ createRoot(dispose => {
185
+ disposer = dispose;
186
+ if (element === document) {
187
+ const tree = code();
188
+ effect(() => flatten(tree), () => {});
189
+ } else {
190
+ const tree = code();
191
+ insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
192
+ }
193
+ }, {
194
+ id: options.renderId
195
+ });
196
+ } catch (err) {
197
+ if (disposer) disposer();
198
+ unregisterDelegatedRoot(element);
199
+ throw err;
200
+ }
145
201
  return () => {
146
202
  disposer();
147
- renderRoot.textContent = "";
203
+ unregisterDelegatedRoot(element);
204
+ element.textContent = "";
148
205
  };
149
206
  }
150
207
  function create(html, bypassGuard, flag) {
@@ -159,20 +216,66 @@ function template(html, flag) {
159
216
  fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
160
217
  return fn;
161
218
  }
162
- function delegateEvents(eventNames, document = window.document) {
163
- const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
219
+ function delegateEvents(eventNames) {
164
220
  for (let i = 0, l = eventNames.length; i < l; i++) {
165
221
  const name = eventNames[i];
166
- if (!e.has(name)) {
167
- e.add(name);
168
- document.addEventListener(name, eventHandler);
222
+ if (!delegatedEvents.has(name)) {
223
+ delegatedEvents.add(name);
224
+ delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
169
225
  }
170
226
  }
171
227
  }
172
- function clearDelegatedEvents(document = window.document) {
173
- if (document[$$EVENTS]) {
174
- for (let name of document[$$EVENTS].keys()) document.removeEventListener(name, eventHandler);
175
- delete document[$$EVENTS];
228
+ function registerDelegatedRoot(root) {
229
+ const state = registerDelegatedContainer(root, root);
230
+ if (state) state.roots = (state.roots || 0) + 1;
231
+ }
232
+ function unregisterDelegatedRoot(root) {
233
+ const state = delegatedContainers.get(root);
234
+ if (state) state.roots > 1 ? state.roots-- : delete state.roots;
235
+ unregisterDelegatedContainer(root, root);
236
+ }
237
+ function registerDelegatedContainer(container, owner = container) {
238
+ if (!container || !owner) return;
239
+ let state = delegatedContainers.get(container);
240
+ if (!state) delegatedContainers.set(container, state = {
241
+ owners: new Map(),
242
+ handlers: new Map()
243
+ });
244
+ state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
245
+ delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
246
+ return state;
247
+ }
248
+ function unregisterDelegatedContainer(container, owner = container) {
249
+ const state = delegatedContainers.get(container);
250
+ if (!state) return;
251
+ const count = state.owners.get(owner);
252
+ if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
253
+ if (state.owners.size) return;
254
+ state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
255
+ delegatedContainers.delete(container);
256
+ }
257
+ function attachDelegatedEvent(name, container, state) {
258
+ if (state.handlers.has(name)) return;
259
+ const handler = e => eventHandler(e, container, state);
260
+ state.handlers.set(name, handler);
261
+ container.addEventListener(name, handler);
262
+ }
263
+ function getDelegatedRoot(node) {
264
+ while (node) {
265
+ if (delegatedContainers.get(node)?.roots) return node;
266
+ node = node._$host || node.parentNode || node.host;
267
+ }
268
+ }
269
+ function findOwner(target, state) {
270
+ let node = target;
271
+ let distance = 0;
272
+ while (node) {
273
+ if (state.owners.has(node)) return {
274
+ owner: node,
275
+ distance
276
+ };
277
+ distance++;
278
+ node = node._$host || node.parentNode || node.host;
176
279
  }
177
280
  }
178
281
  function setProperty(node, name, value) {
@@ -217,7 +320,7 @@ function className(node, value, prev) {
217
320
  node.classList.add(key);
218
321
  }
219
322
  }
220
- function addEventListener(node, name, handler, delegate) {
323
+ function addEvent(node, name, handler, delegate) {
221
324
  if (delegate) {
222
325
  if (Array.isArray(handler)) {
223
326
  node[`$$${name}`] = handler[0];
@@ -283,11 +386,10 @@ function ref(fn, element) {
283
386
  runWithOwner(null, () => applyRef(resolved, element));
284
387
  }
285
388
  function insert(parent, accessor, marker, initial, options) {
286
- const childRoot = getChildRoot(parent);
287
389
  const multi = marker !== undefined;
288
390
  if (multi && !initial) initial = [];
289
391
  if (isHydrating(parent)) {
290
- if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
392
+ if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
291
393
  if (Array.isArray(initial)) {
292
394
  let j = 0;
293
395
  for (let i = 0; i < initial.length; i++) {
@@ -302,7 +404,7 @@ function insert(parent, accessor, marker, initial, options) {
302
404
  }
303
405
  if (multi && initial.length === 0) {
304
406
  const placeholder = document.createTextNode("");
305
- childRoot.insertBefore(placeholder, marker);
407
+ parent.insertBefore(placeholder, marker);
306
408
  initial = [placeholder];
307
409
  }
308
410
  let current = initial;
@@ -357,7 +459,7 @@ function loadModuleAssets(mapping) {
357
459
  return pending.length ? Promise.all(pending).then(() => {}) : undefined;
358
460
  }
359
461
  function hydrate$1(code, element, options = {}) {
360
- if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
462
+ if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
361
463
  options.renderId ||= "";
362
464
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
363
465
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -403,7 +505,7 @@ function hydrate$1(code, element, options = {}) {
403
505
  let disposer;
404
506
  p.then(() => {
405
507
  try {
406
- disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
508
+ disposer = render$1(code, element, [...element.childNodes], options);
407
509
  } finally {
408
510
  sharedConfig.hydrating = false;
409
511
  }
@@ -415,7 +517,7 @@ function hydrate$1(code, element, options = {}) {
415
517
  }
416
518
  try {
417
519
  gatherHydratable(element, options.renderId);
418
- return render$1(code, element, [...getChildRoot(element).childNodes], options);
520
+ return render$1(code, element, [...element.childNodes], options);
419
521
  } finally {
420
522
  sharedConfig.hydrating = false;
421
523
  }
@@ -464,7 +566,7 @@ function getNextMarker(start) {
464
566
  return [end, current];
465
567
  }
466
568
  function getFirstChild(node, expectedTag) {
467
- const child = getChildRoot(node).firstChild;
569
+ const child = node.firstChild;
468
570
  if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
469
571
  const isMissing = !child || child.nodeType !== 1;
470
572
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
@@ -483,7 +585,7 @@ function getNextSibling(node, expectedTag) {
483
585
  function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
484
586
  if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
485
587
  const children = [];
486
- let child = getChildRoot(parent).firstChild;
588
+ let child = parent.firstChild;
487
589
  while (child) {
488
590
  if (child.nodeType === 1) children.push(child);
489
591
  child = child.nextSibling;
@@ -520,7 +622,17 @@ function runHydrationEvents() {
520
622
  const [el, e] = events[0];
521
623
  if (!completed.has(el)) return;
522
624
  events.shift();
523
- eventHandler(e);
625
+ let match;
626
+ for (const [container, state] of delegatedContainers) {
627
+ if (!state.handlers.has(e.type)) continue;
628
+ const entry = findOwner(e.target, state);
629
+ if (entry && (!match || entry.distance < match.distance)) match = {
630
+ container,
631
+ state,
632
+ distance: entry.distance
633
+ };
634
+ }
635
+ if (match) eventHandler(e, match.container, match.state);
524
636
  }
525
637
  if (sharedConfig.done) {
526
638
  sharedConfig.events = _$HY.events = null;
@@ -533,9 +645,6 @@ function runHydrationEvents() {
533
645
  function isHydrating(node) {
534
646
  return sharedConfig.hydrating && (!node || node.isConnected);
535
647
  }
536
- function getChildRoot(node) {
537
- return node && node.localName === "template" ? node.content : node;
538
- }
539
648
  function classListToObject(classList) {
540
649
  if (Array.isArray(classList)) {
541
650
  const result = {};
@@ -570,11 +679,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
570
679
  return value;
571
680
  }
572
681
  const hasNamespace = prop.indexOf(":") > -1;
573
- if (hasNamespace && prop.slice(0, 3) === "on:") {
574
- const e = prop.slice(3);
575
- prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
576
- value && node.addEventListener(e, value, typeof value !== "function" && value);
577
- } else if (!hasNamespace && prop.slice(0, 2) === "on") {
682
+ if (!hasNamespace && prop.slice(0, 2) === "on") {
578
683
  const name = prop.slice(2).toLowerCase();
579
684
  const delegate = DelegatedEvents.has(name);
580
685
  if (!delegate && prev) {
@@ -582,7 +687,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
582
687
  node.removeEventListener(name, h);
583
688
  }
584
689
  if (delegate || value) {
585
- addEventListener(node, name, value, delegate);
690
+ addEvent(node, name, value, delegate);
586
691
  delegate && delegateEvents([name]);
587
692
  }
588
693
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
@@ -594,14 +699,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
594
699
  }
595
700
  return value;
596
701
  }
597
- function eventHandler(e) {
702
+ function eventHandler(e, container, state) {
598
703
  if (sharedConfig.registry && sharedConfig.events) {
599
704
  if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
600
705
  }
706
+ if (e[$$EVENT_OWNER]) return;
707
+ const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
708
+ if (state && !owner) return;
709
+ e[$$EVENT_OWNER] = owner || true;
601
710
  let node = e.target;
602
711
  const key = `$$${e.type}`;
603
712
  const oriTarget = e.target;
604
- const oriCurrentTarget = e.currentTarget;
713
+ const boundary = owner || container || e.currentTarget;
605
714
  const retarget = value => Object.defineProperty(e, "target", {
606
715
  configurable: true,
607
716
  value
@@ -617,29 +726,34 @@ function eventHandler(e) {
617
726
  return true;
618
727
  };
619
728
  const walkUpTree = () => {
620
- while (handleNode() && (node = node._$host || node.parentNode || node.host));
729
+ while (handleNode()) {
730
+ if (node === boundary || node.parentNode === boundary) break;
731
+ node = node._$host || node.parentNode || node.host;
732
+ }
621
733
  };
622
734
  Object.defineProperty(e, "currentTarget", {
623
735
  configurable: true,
624
736
  get() {
625
- return node || document;
737
+ return node || boundary || document;
626
738
  }
627
739
  });
628
740
  if (e.composedPath) {
629
741
  const path = e.composedPath();
630
- retarget(path[0]);
631
- for (let i = 0; i < path.length - 2; i++) {
632
- node = path[i];
633
- if (!handleNode()) break;
634
- if (node._$host) {
635
- node = node._$host;
636
- walkUpTree();
637
- break;
638
- }
639
- if (node.parentNode === oriCurrentTarget) {
640
- break;
742
+ if (path.length) {
743
+ retarget(path[0]);
744
+ for (let i = 0; i < path.length; i++) {
745
+ node = path[i];
746
+ if (!handleNode()) break;
747
+ if (node._$host) {
748
+ node = node._$host;
749
+ walkUpTree();
750
+ break;
751
+ }
752
+ if (node === boundary || node.parentNode === boundary) {
753
+ break;
754
+ }
641
755
  }
642
- }
756
+ } else walkUpTree();
643
757
  }
644
758
  else walkUpTree();
645
759
  retarget(oriTarget);
@@ -647,22 +761,26 @@ function eventHandler(e) {
647
761
  function insertExpression(parent, value, current, marker) {
648
762
  if (isHydrating(parent)) return;
649
763
  if (value === current) return;
650
- const childRoot = getChildRoot(parent);
651
764
  const t = typeof value,
652
765
  multi = marker !== undefined;
653
766
  if (t === "string" || t === "number") {
654
767
  const tc = typeof current;
655
768
  if (tc === "string" || tc === "number") {
656
- childRoot.firstChild.data = value;
657
- } else childRoot.textContent = value;
769
+ parent.firstChild.data = value;
770
+ } else parent.textContent = value;
658
771
  } else if (value === undefined) {
659
772
  cleanChildren(parent, current, marker);
660
773
  } else if (value.nodeType) {
661
774
  if (Array.isArray(current)) {
662
775
  cleanChildren(parent, current, multi ? marker : null, value);
663
- } else if (current === undefined || !childRoot.firstChild) {
664
- childRoot.appendChild(value);
665
- } else childRoot.replaceChild(value, childRoot.firstChild);
776
+ } else if (current && current.nodeType) {
777
+ current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
778
+ } else if (current && parent.firstChild) {
779
+ parent.replaceChild(value, parent.firstChild);
780
+ } else {
781
+ parent.appendChild(value);
782
+ }
783
+ if (marker) value[$$SLOT] = marker;
666
784
  } else if (Array.isArray(value)) {
667
785
  const currentArray = current && Array.isArray(current);
668
786
  if (value.length === 0) {
@@ -670,7 +788,7 @@ function insertExpression(parent, value, current, marker) {
670
788
  } else if (currentArray) {
671
789
  if (current.length === 0) {
672
790
  appendNodes(parent, value, marker);
673
- } else reconcileArrays(childRoot, current, value);
791
+ } else reconcileArrays(parent, current, value, marker);
674
792
  } else {
675
793
  current && cleanChildren(parent);
676
794
  appendNodes(parent, value);
@@ -695,22 +813,26 @@ function normalize(value, current, multi, doNotUnwrap) {
695
813
  return value;
696
814
  }
697
815
  function appendNodes(parent, array, marker = null) {
698
- parent = getChildRoot(parent);
699
- for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
816
+ for (let i = 0, len = array.length; i < len; i++) {
817
+ const n = array[i];
818
+ parent.insertBefore(n, marker);
819
+ if (marker) n[$$SLOT] = marker;
820
+ }
700
821
  }
701
822
  function cleanChildren(parent, current, marker, replacement) {
702
- parent = getChildRoot(parent);
703
823
  if (marker === undefined) return parent.textContent = "";
704
824
  if (current.length) {
705
825
  let inserted = false;
706
826
  for (let i = current.length - 1; i >= 0; i--) {
707
827
  const el = current[i];
708
828
  if (replacement !== el) {
709
- const isParent = el.parentNode === parent;
710
- if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
829
+ const tag = el[$$SLOT];
830
+ const owns = el.parentNode === parent && (!tag || tag === marker);
831
+ if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
711
832
  } else inserted = true;
712
833
  }
713
834
  } else if (replacement) parent.insertBefore(replacement, marker);
835
+ if (replacement && marker) replacement[$$SLOT] = marker;
714
836
  }
715
837
  function gatherHydratable(element, root) {
716
838
  const templates = element.querySelectorAll(`*[_hk]`);
@@ -774,8 +896,8 @@ function Portal(props) {
774
896
  const treeMarker = document.createTextNode(""),
775
897
  startMarker = document.createTextNode(""),
776
898
  endMarker = document.createTextNode(""),
777
- mount = () => createElementProxy(props.mount || document.body, treeMarker);
778
- let content = createMemo(() => [startMarker, props.children]);
899
+ mount = () => createElementProxy(props.mount || document.body, treeMarker),
900
+ content = createMemo(() => [startMarker, props.children]);
779
901
  createRenderEffect(() => [mount(), content()], ([m, c]) => {
780
902
  m.appendChild(endMarker);
781
903
  insert(m, c, endMarker);
@@ -788,6 +910,12 @@ function Portal(props) {
788
910
  }
789
911
  };
790
912
  });
913
+ createEffect(mount, m => {
914
+ const ownerRoot = getDelegatedRoot(treeMarker);
915
+ if (!ownerRoot || ownerRoot.contains(m)) return;
916
+ registerDelegatedContainer(m, ownerRoot);
917
+ return () => unregisterDelegatedContainer(m, ownerRoot);
918
+ });
791
919
  return treeMarker;
792
920
  }
793
921
  function dynamic(source) {
@@ -838,4 +966,4 @@ function createElementProxy(el, marker) {
838
966
  });
839
967
  }
840
968
 
841
- export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, mergeProps, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
969
+ 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/dist/server.cjs CHANGED
@@ -4,6 +4,34 @@ var solidJs = require('solid-js');
4
4
  var seroval = require('seroval');
5
5
  var web = require('seroval-plugins/web');
6
6
 
7
+ const DOMWithState = {
8
+ INPUT: {
9
+ value: 1,
10
+ defaultValue: 2,
11
+ checked: 1,
12
+ defaultChecked: 2
13
+ },
14
+ SELECT: {
15
+ value: 1
16
+ },
17
+ OPTION: {
18
+ value: 1,
19
+ selected: 1,
20
+ defaultSelected: 2
21
+ },
22
+ TEXTAREA: {
23
+ value: 1,
24
+ defaultValue: 2
25
+ },
26
+ VIDEO: {
27
+ muted: 1,
28
+ defaultMuted: 2
29
+ },
30
+ AUDIO: {
31
+ muted: 1,
32
+ defaultMuted: 2
33
+ }
34
+ };
7
35
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
8
36
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
9
37
  const SVGElements = /*#__PURE__*/new Set([
@@ -952,6 +980,9 @@ function getAssets() {
952
980
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
953
981
  return out;
954
982
  }
983
+ function Assets(props) {
984
+ useAssets(() => props.children);
985
+ }
955
986
  function generateHydrationScript({
956
987
  eventNames = ["click", "input"],
957
988
  nonce
@@ -1228,8 +1259,10 @@ Object.defineProperty(exports, "untrack", {
1228
1259
  enumerable: true,
1229
1260
  get: function () { return solidJs.untrack; }
1230
1261
  });
1262
+ exports.Assets = Assets;
1231
1263
  exports.ChildProperties = ChildProperties;
1232
1264
  exports.DOMElements = DOMElements;
1265
+ exports.DOMWithState = DOMWithState;
1233
1266
  exports.DelegatedEvents = DelegatedEvents;
1234
1267
  exports.Dynamic = Dynamic;
1235
1268
  exports.HydrationScript = HydrationScript;
@@ -1240,7 +1273,7 @@ exports.RawTextElements = RawTextElements;
1240
1273
  exports.RequestContext = RequestContext;
1241
1274
  exports.SVGElements = SVGElements;
1242
1275
  exports.VoidElements = VoidElements;
1243
- exports.addEventListener = notSup;
1276
+ exports.addEvent = notSup;
1244
1277
  exports.applyRef = applyRef;
1245
1278
  exports.assign = notSup;
1246
1279
  exports.className = notSup;
@@ -1251,6 +1284,7 @@ exports.effect = effect;
1251
1284
  exports.escape = escape;
1252
1285
  exports.generateHydrationScript = generateHydrationScript;
1253
1286
  exports.getAssets = getAssets;
1287
+ exports.getDelegatedRoot = notSup;
1254
1288
  exports.getHydrationKey = getHydrationKey;
1255
1289
  exports.getNextElement = notSup;
1256
1290
  exports.getNextMarker = notSup;
@@ -1262,6 +1296,9 @@ exports.isDev = isDev;
1262
1296
  exports.isServer = isServer;
1263
1297
  exports.memo = memo;
1264
1298
  exports.mergeProps = mergeProps;
1299
+ exports.ref = notSup;
1300
+ exports.registerDelegatedContainer = notSup;
1301
+ exports.registerDelegatedRoot = notSup;
1265
1302
  exports.render = notSup;
1266
1303
  exports.renderToStream = renderToStream;
1267
1304
  exports.renderToString = renderToString;
@@ -1270,6 +1307,7 @@ exports.runHydrationEvents = notSup;
1270
1307
  exports.setAttribute = notSup;
1271
1308
  exports.setAttributeNS = notSup;
1272
1309
  exports.setProperty = notSup;
1310
+ exports.setStyleProperty = notSup;
1273
1311
  exports.spread = notSup;
1274
1312
  exports.ssr = ssr;
1275
1313
  exports.ssrAttribute = ssrAttribute;
@@ -1281,4 +1319,6 @@ exports.ssrStyle = ssrStyle;
1281
1319
  exports.ssrStyleProperty = ssrStyleProperty;
1282
1320
  exports.style = notSup;
1283
1321
  exports.template = notSup;
1322
+ exports.unregisterDelegatedContainer = notSup;
1323
+ exports.unregisterDelegatedRoot = notSup;
1284
1324
  exports.useAssets = useAssets;