@solidjs/web 2.0.0-beta.0 → 2.0.0-beta.10

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,8 +1,34 @@
1
- import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, createRoot, flatten, omit, $DEVCOMP, enableHydration } from 'solid-js';
2
- export { Errored, For, Loading, Match, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
3
3
 
4
- const Properties = /*#__PURE__*/new Set([
5
- "value", "checked", "selected", "muted"]);
4
+ const DOMWithState = {
5
+ INPUT: {
6
+ value: 1,
7
+ defaultValue: 2,
8
+ checked: 1,
9
+ defaultChecked: 2
10
+ },
11
+ SELECT: {
12
+ value: 1
13
+ },
14
+ OPTION: {
15
+ value: 1,
16
+ selected: 1,
17
+ defaultSelected: 2
18
+ },
19
+ TEXTAREA: {
20
+ value: 1,
21
+ defaultValue: 2
22
+ },
23
+ VIDEO: {
24
+ muted: 1,
25
+ defaultMuted: 2
26
+ },
27
+ AUDIO: {
28
+ muted: 1,
29
+ defaultMuted: 2
30
+ }
31
+ };
6
32
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
7
33
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
8
34
  const SVGElements = /*#__PURE__*/new Set([
@@ -10,17 +36,26 @@ const SVGElements = /*#__PURE__*/new Set([
10
36
  "set", "stop",
11
37
  "svg", "switch", "symbol", "text", "textPath",
12
38
  "tref", "tspan", "use", "view", "vkern"]);
13
- const SVGNamespace = {
39
+ 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"]);
40
+ const Namespaces = {
41
+ svg: "http://www.w3.org/2000/svg",
42
+ mathml: "http://www.w3.org/1998/Math/MathML",
14
43
  xlink: "http://www.w3.org/1999/xlink",
15
44
  xml: "http://www.w3.org/XML/1998/namespace"
16
45
  };
46
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
47
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
17
48
  const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
18
49
  "webview",
19
50
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
20
51
 
21
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
52
+ const transparentOptions = {
22
53
  transparent: true
23
- });
54
+ };
55
+ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
56
+ transparent: true,
57
+ ...options
58
+ } : transparentOptions);
24
59
  const memo = fn => createMemo(() => fn());
25
60
 
26
61
  function reconcileArrays(parentNode, a, b) {
@@ -81,32 +116,40 @@ function reconcileArrays(parentNode, a, b) {
81
116
  }
82
117
 
83
118
  const $$EVENTS = "_$DX_DELEGATE";
84
- function render(code, element, init, options = {}) {
119
+ const INNER_OWNED = {};
120
+ function render$1(code, element, init, options = {}) {
85
121
  if (!element) {
86
122
  throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
87
123
  }
124
+ const renderRoot = getChildRoot(element);
88
125
  let disposer;
89
126
  createRoot(dispose => {
90
127
  disposer = dispose;
91
- element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
128
+ if (element === document) {
129
+ const tree = code();
130
+ effect(() => flatten(tree), () => {});
131
+ } else {
132
+ const tree = code();
133
+ insert(element, () => tree, renderRoot.firstChild ? null : undefined, init, options.insertOptions);
134
+ }
92
135
  }, {
93
136
  id: options.renderId
94
137
  });
95
138
  return () => {
96
139
  disposer();
97
- element.textContent = "";
140
+ renderRoot.textContent = "";
98
141
  };
99
142
  }
100
- function template(html, isImportNode, isSVG, isMathML) {
143
+ function create(html, bypassGuard, flag) {
144
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
145
+ const t = document.createElement("template");
146
+ t.innerHTML = html;
147
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
148
+ }
149
+ function template(html, flag) {
101
150
  let node;
102
- const create = bypassGuard => {
103
- if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
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 => untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
109
- fn._html = html;
151
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
152
+ fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
110
153
  return fn;
111
154
  }
112
155
  function delegateEvents(eventNames, document = window.document) {
@@ -135,16 +178,16 @@ function setAttribute(node, name, value) {
135
178
  }
136
179
  function setAttributeNS(node, namespace, name, value) {
137
180
  if (isHydrating(node)) return;
138
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
181
+ if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
139
182
  }
140
- function className(node, value, isSVG, prev) {
183
+ function className(node, value, prev) {
141
184
  if (isHydrating(node)) return;
142
185
  if (value == null || value === false) {
143
186
  prev && node.removeAttribute("class");
144
187
  return;
145
188
  }
146
189
  if (typeof value === "string") {
147
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
190
+ value !== prev && node.setAttribute("class", value);
148
191
  return;
149
192
  }
150
193
  if (typeof prev === "string") {
@@ -187,7 +230,6 @@ function style(node, value, prev) {
187
230
  if (typeof value === "string") return nodeStyle.cssText = value;
188
231
  typeof prev === "string" && (nodeStyle.cssText = prev = undefined);
189
232
  prev || (prev = {});
190
- value || (value = {});
191
233
  let v, s;
192
234
  for (s in value) {
193
235
  v = value[s];
@@ -199,14 +241,9 @@ function style(node, value, prev) {
199
241
  function setStyleProperty(node, name, value) {
200
242
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
201
243
  }
202
- function spread(node, props = {}, isSVG, skipChildren) {
244
+ function spread(node, props = {}, skipChildren) {
203
245
  const prevProps = {};
204
- if (!skipChildren) {
205
- effect(() => normalize(props.children, prevProps.children), value => {
206
- insertExpression(node, value, prevProps.children);
207
- prevProps.children = value;
208
- });
209
- }
246
+ if (!skipChildren) insert(node, () => props.children);
210
247
  effect(() => {
211
248
  const r = props.ref;
212
249
  (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
@@ -218,7 +255,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
218
255
  newProps[prop] = props[prop];
219
256
  }
220
257
  return newProps;
221
- }, props => assign(node, props, isSVG, true, prevProps, true));
258
+ }, props => assign(node, props, true, prevProps, true));
222
259
  return prevProps;
223
260
  }
224
261
  function dynamicProperty(props, key) {
@@ -238,41 +275,79 @@ function ref(fn, element) {
238
275
  const resolved = untrack(fn);
239
276
  runWithOwner(null, () => applyRef(resolved, element));
240
277
  }
241
- function insert(parent, accessor, marker, initial) {
278
+ function insert(parent, accessor, marker, initial, options) {
279
+ const childRoot = getChildRoot(parent);
242
280
  const multi = marker !== undefined;
243
281
  if (multi && !initial) initial = [];
244
- if (isHydrating(parent) && Array.isArray(initial)) {
245
- let j = 0;
246
- for (let i = 0; i < initial.length; i++) {
247
- if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
282
+ if (isHydrating(parent)) {
283
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
284
+ if (Array.isArray(initial)) {
285
+ let j = 0;
286
+ for (let i = 0; i < initial.length; i++) {
287
+ if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
288
+ }
289
+ initial.length = j;
248
290
  }
249
- initial.length = j;
250
291
  }
251
292
  if (typeof accessor !== "function") {
252
293
  accessor = normalize(accessor, initial, multi, true);
253
294
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
254
295
  }
255
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
256
- }
257
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
296
+ if (multi && initial.length === 0) {
297
+ const placeholder = document.createTextNode("");
298
+ childRoot.insertBefore(placeholder, marker);
299
+ initial = [placeholder];
300
+ }
301
+ let current = initial;
302
+ effect(() => {
303
+ const value = normalize(accessor(), current, multi, true);
304
+ if (typeof value !== "function") return value;
305
+ effect(() => normalize(value, current, multi), inner => {
306
+ insertExpression(parent, inner, current, marker);
307
+ current = inner;
308
+ }, options);
309
+ return INNER_OWNED;
310
+ }, value => {
311
+ if (value === INNER_OWNED) return;
312
+ insertExpression(parent, value, current, marker);
313
+ current = value;
314
+ }, options);
315
+ }
316
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
317
+ const nodeName = node.nodeName;
258
318
  props || (props = {});
259
319
  for (const prop in prevProps) {
260
320
  if (!(prop in props)) {
261
321
  if (prop === "children") continue;
262
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
322
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
263
323
  }
264
324
  }
265
325
  for (const prop in props) {
266
326
  if (prop === "children") {
267
- if (!skipChildren) insertExpression(node, props.children);
327
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
268
328
  continue;
269
329
  }
270
- const value = props[prop];
271
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
330
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
331
+ }
332
+ }
333
+ function loadModuleAssets(mapping) {
334
+ const hy = globalThis._$HY;
335
+ if (!hy) return;
336
+ const pending = [];
337
+ for (const moduleUrl in mapping) {
338
+ if (hy.modules[moduleUrl]) continue;
339
+ const entryUrl = mapping[moduleUrl];
340
+ if (!hy.loading[moduleUrl]) {
341
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
342
+ hy.modules[moduleUrl] = mod;
343
+ });
344
+ }
345
+ pending.push(hy.loading[moduleUrl]);
272
346
  }
347
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
273
348
  }
274
349
  function hydrate$1(code, element, options = {}) {
275
- if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
350
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
276
351
  options.renderId ||= "";
277
352
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
278
353
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -281,6 +356,7 @@ function hydrate$1(code, element, options = {}) {
281
356
  sharedConfig.load = id => globalThis._$HY.r[id];
282
357
  sharedConfig.has = id => id in globalThis._$HY.r;
283
358
  sharedConfig.gather = root => gatherHydratable(element, root);
359
+ sharedConfig.loadModuleAssets = loadModuleAssets;
284
360
  sharedConfig.cleanupFragment = id => {
285
361
  const tpl = document.getElementById("pl-" + id);
286
362
  if (tpl) {
@@ -302,14 +378,34 @@ function hydrate$1(code, element, options = {}) {
302
378
  {
303
379
  sharedConfig.verifyHydration = () => {
304
380
  if (sharedConfig.registry && sharedConfig.registry.size) {
305
- const orphaned = [...sharedConfig.registry.values()];
381
+ const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
382
+ sharedConfig.registry.clear();
383
+ if (!orphaned.length) return;
306
384
  console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
307
385
  }
308
386
  };
309
387
  }
388
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
389
+ if (rootMapping && typeof rootMapping === "object") {
390
+ const p = loadModuleAssets(rootMapping);
391
+ if (p) {
392
+ gatherHydratable(element, options.renderId);
393
+ let disposer;
394
+ p.then(() => {
395
+ try {
396
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
397
+ } finally {
398
+ sharedConfig.hydrating = false;
399
+ }
400
+ }, () => {
401
+ sharedConfig.hydrating = false;
402
+ });
403
+ return () => disposer && disposer();
404
+ }
405
+ }
310
406
  try {
311
407
  gatherHydratable(element, options.renderId);
312
- return render(code, element, [...element.childNodes], options);
408
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
313
409
  } finally {
314
410
  sharedConfig.hydrating = false;
315
411
  }
@@ -358,7 +454,7 @@ function getNextMarker(start) {
358
454
  return [end, current];
359
455
  }
360
456
  function getFirstChild(node, expectedTag) {
361
- const child = node.firstChild;
457
+ const child = getChildRoot(node).firstChild;
362
458
  if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
363
459
  const isMissing = !child || child.nodeType !== 1;
364
460
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
@@ -368,20 +464,21 @@ function getFirstChild(node, expectedTag) {
368
464
  function getNextSibling(node, expectedTag) {
369
465
  const sibling = node.nextSibling;
370
466
  if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
371
- const parent = node.parentElement;
467
+ const parent = node.parentNode;
372
468
  const isMissing = !sibling || sibling.nodeType !== 1;
373
469
  console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
374
470
  }
375
471
  return sibling;
376
472
  }
377
473
  function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
474
+ if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
378
475
  const children = [];
379
- let child = parent.firstChild;
476
+ let child = getChildRoot(parent).firstChild;
380
477
  while (child) {
381
478
  if (child.nodeType === 1) children.push(child);
382
479
  child = child.nextSibling;
383
480
  }
384
- const pTag = parent.localName;
481
+ const pTag = parent.localName || "#fragment";
385
482
  if (isMissing) {
386
483
  const tags = children.map(c => `<${c.localName}>`).join("");
387
484
  return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
@@ -426,6 +523,9 @@ function runHydrationEvents() {
426
523
  function isHydrating(node) {
427
524
  return sharedConfig.hydrating && (!node || node.isConnected);
428
525
  }
526
+ function getChildRoot(node) {
527
+ return node && node.localName === "template" ? node.content : node;
528
+ }
429
529
  function toggleClassKey(node, key, value) {
430
530
  const classNames = key.trim().split(/\s+/);
431
531
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
@@ -444,18 +544,20 @@ function flattenClassList(list, result) {
444
544
  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;
445
545
  }
446
546
  }
447
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
448
- let forceProp;
547
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
449
548
  if (prop === "style") return style(node, value, prev), value;
450
- if (prop === "class") return className(node, value, isSVG, prev), value;
451
- if (value === prev) return prev;
549
+ if (prop === "class") return className(node, value, prev), value;
550
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
452
551
  if (prop === "ref") {
453
552
  if (!skipRef && value) ref(() => value, node);
454
- } else if (prop.slice(0, 3) === "on:") {
553
+ return value;
554
+ }
555
+ const hasNamespace = prop.indexOf(":") > -1;
556
+ if (hasNamespace && prop.slice(0, 3) === "on:") {
455
557
  const e = prop.slice(3);
456
558
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
457
559
  value && node.addEventListener(e, value, typeof value !== "function" && value);
458
- } else if (prop.slice(0, 2) === "on") {
560
+ } else if (!hasNamespace && prop.slice(0, 2) === "on") {
459
561
  const name = prop.slice(2).toLowerCase();
460
562
  const delegate = DelegatedEvents.has(name);
461
563
  if (!delegate && prev) {
@@ -466,11 +568,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
466
568
  addEventListener(node, name, value, delegate);
467
569
  delegate && delegateEvents([name]);
468
570
  }
469
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
470
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
471
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
571
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
572
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
573
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
472
574
  } else {
473
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
575
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
474
576
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
475
577
  }
476
578
  return value;
@@ -528,21 +630,22 @@ function eventHandler(e) {
528
630
  function insertExpression(parent, value, current, marker) {
529
631
  if (isHydrating(parent)) return;
530
632
  if (value === current) return;
633
+ const childRoot = getChildRoot(parent);
531
634
  const t = typeof value,
532
635
  multi = marker !== undefined;
533
636
  if (t === "string" || t === "number") {
534
637
  const tc = typeof current;
535
638
  if (tc === "string" || tc === "number") {
536
- parent.firstChild.data = value;
537
- } else parent.textContent = value;
639
+ childRoot.firstChild.data = value;
640
+ } else childRoot.textContent = value;
538
641
  } else if (value === undefined) {
539
642
  cleanChildren(parent, current, marker);
540
643
  } else if (value.nodeType) {
541
644
  if (Array.isArray(current)) {
542
645
  cleanChildren(parent, current, multi ? marker : null, value);
543
- } else if (current === undefined || !parent.firstChild) {
544
- parent.appendChild(value);
545
- } else parent.replaceChild(value, parent.firstChild);
646
+ } else if (current === undefined || !childRoot.firstChild) {
647
+ childRoot.appendChild(value);
648
+ } else childRoot.replaceChild(value, childRoot.firstChild);
546
649
  } else if (Array.isArray(value)) {
547
650
  const currentArray = current && Array.isArray(current);
548
651
  if (value.length === 0) {
@@ -550,7 +653,7 @@ function insertExpression(parent, value, current, marker) {
550
653
  } else if (currentArray) {
551
654
  if (current.length === 0) {
552
655
  appendNodes(parent, value, marker);
553
- } else reconcileArrays(parent, current, value);
656
+ } else reconcileArrays(childRoot, current, value);
554
657
  } else {
555
658
  current && cleanChildren(parent);
556
659
  appendNodes(parent, value);
@@ -575,9 +678,11 @@ function normalize(value, current, multi, doNotUnwrap) {
575
678
  return value;
576
679
  }
577
680
  function appendNodes(parent, array, marker = null) {
681
+ parent = getChildRoot(parent);
578
682
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
579
683
  }
580
684
  function cleanChildren(parent, current, marker, replacement) {
685
+ parent = getChildRoot(parent);
581
686
  if (marker === undefined) return parent.textContent = "";
582
687
  if (current.length) {
583
688
  let inserted = false;
@@ -601,12 +706,6 @@ function gatherHydratable(element, root) {
601
706
  function getHydrationKey() {
602
707
  return sharedConfig.getNextContextId();
603
708
  }
604
- function NoHydration(props) {
605
- return sharedConfig.hydrating ? undefined : props.children;
606
- }
607
- function Hydration(props) {
608
- return props.children;
609
- }
610
709
  const voidFn = () => undefined;
611
710
  const RequestContext = Symbol();
612
711
 
@@ -632,13 +731,23 @@ function ssrHydrationKey() {}
632
731
  function resolveSSRNode(node) {}
633
732
  function escape(html) {}
634
733
 
734
+ const mergeProps = merge;
635
735
  const isServer = false;
636
736
  const isDev = true;
637
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
638
- function createElement(tagName, isSVG = false, is = undefined) {
639
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
640
- is
641
- });
737
+ function render(code, element, init, options = {}) {
738
+ enforceLoadingBoundary(true);
739
+ try {
740
+ const dispose = render$1(code, element, init, {
741
+ ...options,
742
+ insertOptions: {
743
+ schedule: true
744
+ }
745
+ });
746
+ flush();
747
+ return dispose;
748
+ } finally {
749
+ enforceLoadingBoundary(false);
750
+ }
642
751
  }
643
752
  const hydrate = (...args) => {
644
753
  enableHydration();
@@ -664,6 +773,36 @@ function Portal(props) {
664
773
  });
665
774
  return treeMarker;
666
775
  }
776
+ function dynamic(source) {
777
+ const cached = createMemo(source, {
778
+ lazy: true
779
+ });
780
+ return props => {
781
+ return createMemo(() => {
782
+ const component = cached();
783
+ switch (typeof component) {
784
+ case "function":
785
+ Object.assign(component, {
786
+ [$DEVCOMP]: true
787
+ });
788
+ return untrack(() => component(props));
789
+ case "string":
790
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
791
+ spread(el, props);
792
+ return el;
793
+ }
794
+ });
795
+ };
796
+ }
797
+ function Dynamic(props) {
798
+ const Comp = dynamic(() => props.component);
799
+ return createComponent(Comp, omit(props, "component"));
800
+ }
801
+ function createElement(tagName, is = undefined) {
802
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
803
+ is
804
+ });
805
+ }
667
806
  function createElementProxy(el, marker) {
668
807
  return new Proxy(el, {
669
808
  get(target, prop) {
@@ -681,27 +820,5 @@ function createElementProxy(el, marker) {
681
820
  }
682
821
  });
683
822
  }
684
- function createDynamic(component, props) {
685
- const cached = createMemo(component);
686
- return createMemo(() => {
687
- const component = cached();
688
- switch (typeof component) {
689
- case "function":
690
- Object.assign(component, {
691
- [$DEVCOMP]: true
692
- });
693
- return untrack(() => component(props));
694
- case "string":
695
- const isSvg = SVGElements.has(component);
696
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
697
- spread(el, props, isSvg);
698
- return el;
699
- }
700
- });
701
- }
702
- function Dynamic(props) {
703
- const others = omit(props, "component");
704
- return createDynamic(() => props.component, others);
705
- }
706
823
 
707
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, 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 };
824
+ 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 };