@solidjs/web 2.0.0-beta.5 → 2.0.0-beta.7

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/web.cjs CHANGED
@@ -6,23 +6,29 @@ var signals = require('@solidjs/signals');
6
6
  const DOMWithState = {
7
7
  INPUT: {
8
8
  value: 1,
9
- checked: 1
9
+ defaultValue: 2,
10
+ checked: 1,
11
+ defaultChecked: 2
10
12
  },
11
13
  SELECT: {
12
14
  value: 1
13
15
  },
14
16
  OPTION: {
15
17
  value: 1,
16
- selected: 1
18
+ selected: 1,
19
+ defaultSelected: 2
17
20
  },
18
21
  TEXTAREA: {
19
- value: 1
22
+ value: 1,
23
+ defaultValue: 2
20
24
  },
21
25
  VIDEO: {
22
- muted: 1
26
+ muted: 1,
27
+ defaultMuted: 2
23
28
  },
24
29
  AUDIO: {
25
- muted: 1
30
+ muted: 1,
31
+ defaultMuted: 2
26
32
  }
27
33
  };
28
34
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
@@ -33,7 +39,9 @@ const SVGElements = /*#__PURE__*/new Set([
33
39
  "svg", "switch", "symbol", "text", "textPath",
34
40
  "tref", "tspan", "use", "view", "vkern"]);
35
41
  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"]);
36
- const SVGNamespace = {
42
+ const Namespaces = {
43
+ svg: "http://www.w3.org/2000/svg",
44
+ mathml: "http://www.w3.org/1998/Math/MathML",
37
45
  xlink: "http://www.w3.org/1999/xlink",
38
46
  xml: "http://www.w3.org/XML/1998/namespace"
39
47
  };
@@ -41,10 +49,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
41
49
  "webview",
42
50
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
43
51
 
44
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
52
+ const effect = (fn, effectFn) => solidJs.createRenderEffect(fn, effectFn, {
45
53
  transparent: true
46
54
  });
47
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
55
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
48
56
  transparent: true
49
57
  }) : solidJs.createMemo(() => fn());
50
58
 
@@ -107,16 +115,17 @@ function reconcileArrays(parentNode, a, b) {
107
115
 
108
116
  const $$EVENTS = "_$DX_DELEGATE";
109
117
  function render$1(code, element, init, options = {}) {
118
+ const renderRoot = getChildRoot(element);
110
119
  let disposer;
111
120
  solidJs.createRoot(dispose => {
112
121
  disposer = dispose;
113
- element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
122
+ element === document ? solidJs.flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
114
123
  }, {
115
124
  id: options.renderId
116
125
  });
117
126
  return () => {
118
127
  disposer();
119
- element.textContent = "";
128
+ renderRoot.textContent = "";
120
129
  };
121
130
  }
122
131
  function create(html, bypassGuard, flag) {
@@ -254,10 +263,11 @@ function ref(fn, element) {
254
263
  solidJs.runWithOwner(null, () => applyRef(resolved, element));
255
264
  }
256
265
  function insert(parent, accessor, marker, initial) {
266
+ const childRoot = getChildRoot(parent);
257
267
  const multi = marker !== undefined;
258
268
  if (multi && !initial) initial = [];
259
269
  if (isHydrating(parent)) {
260
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
270
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
261
271
  if (Array.isArray(initial)) {
262
272
  let j = 0;
263
273
  for (let i = 0; i < initial.length; i++) {
@@ -273,10 +283,10 @@ function insert(parent, accessor, marker, initial) {
273
283
  accessor = memo(accessor, true);
274
284
  if (multi && initial.length === 0) {
275
285
  const placeholder = document.createTextNode("");
276
- parent.insertBefore(placeholder, marker);
286
+ childRoot.insertBefore(placeholder, marker);
277
287
  initial = [placeholder];
278
288
  }
279
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
289
+ effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker));
280
290
  }
281
291
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
282
292
  const nodeName = node.nodeName;
@@ -284,19 +294,35 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
284
294
  for (const prop in prevProps) {
285
295
  if (!(prop in props)) {
286
296
  if (prop === "children") continue;
287
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
297
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
288
298
  }
289
299
  }
290
300
  for (const prop in props) {
291
301
  if (prop === "children") {
292
- if (!skipChildren) insertExpression(node, props.children);
302
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
293
303
  continue;
294
304
  }
295
- prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
305
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
296
306
  }
297
307
  }
308
+ function loadModuleAssets(mapping) {
309
+ const hy = globalThis._$HY;
310
+ if (!hy) return;
311
+ const pending = [];
312
+ for (const moduleUrl in mapping) {
313
+ if (hy.modules[moduleUrl]) continue;
314
+ const entryUrl = mapping[moduleUrl];
315
+ if (!hy.loading[moduleUrl]) {
316
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
317
+ hy.modules[moduleUrl] = mod;
318
+ });
319
+ }
320
+ pending.push(hy.loading[moduleUrl]);
321
+ }
322
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
323
+ }
298
324
  function hydrate$1(code, element, options = {}) {
299
- if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
325
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
300
326
  options.renderId ||= "";
301
327
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
302
328
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -305,6 +331,7 @@ function hydrate$1(code, element, options = {}) {
305
331
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
306
332
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
307
333
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
334
+ solidJs.sharedConfig.loadModuleAssets = loadModuleAssets;
308
335
  solidJs.sharedConfig.cleanupFragment = id => {
309
336
  const tpl = document.getElementById("pl-" + id);
310
337
  if (tpl) {
@@ -323,9 +350,27 @@ function hydrate$1(code, element, options = {}) {
323
350
  };
324
351
  solidJs.sharedConfig.registry = new Map();
325
352
  solidJs.sharedConfig.hydrating = true;
353
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
354
+ if (rootMapping && typeof rootMapping === "object") {
355
+ const p = loadModuleAssets(rootMapping);
356
+ if (p) {
357
+ gatherHydratable(element, options.renderId);
358
+ let disposer;
359
+ p.then(() => {
360
+ try {
361
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
362
+ } finally {
363
+ solidJs.sharedConfig.hydrating = false;
364
+ }
365
+ }, () => {
366
+ solidJs.sharedConfig.hydrating = false;
367
+ });
368
+ return () => disposer && disposer();
369
+ }
370
+ }
326
371
  try {
327
372
  gatherHydratable(element, options.renderId);
328
- return render$1(code, element, [...element.childNodes], options);
373
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
329
374
  } finally {
330
375
  solidJs.sharedConfig.hydrating = false;
331
376
  }
@@ -368,7 +413,7 @@ function getNextMarker(start) {
368
413
  return [end, current];
369
414
  }
370
415
  function getFirstChild(node, expectedTag) {
371
- const child = node.firstChild;
416
+ const child = getChildRoot(node).firstChild;
372
417
  return child;
373
418
  }
374
419
  function getNextSibling(node, expectedTag) {
@@ -401,6 +446,9 @@ function runHydrationEvents() {
401
446
  function isHydrating(node) {
402
447
  return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
403
448
  }
449
+ function getChildRoot(node) {
450
+ return node && node.localName === "template" ? node.content : node;
451
+ }
404
452
  function toggleClassKey(node, key, value) {
405
453
  const classNames = key.trim().split(/\s+/);
406
454
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
@@ -419,10 +467,10 @@ function flattenClassList(list, result) {
419
467
  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;
420
468
  }
421
469
  }
422
- function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
470
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
423
471
  if (prop === "style") return style(node, value, prev), value;
424
472
  if (prop === "class") return className(node, value, prev), value;
425
- if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
473
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
426
474
  if (prop === "ref") {
427
475
  if (!skipRef && value) ref(() => value, node);
428
476
  return value;
@@ -432,7 +480,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
432
480
  const e = prop.slice(3);
433
481
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
434
482
  value && node.addEventListener(e, value, typeof value !== "function" && value);
435
- } else if (prop.slice(0, 2) === "on") {
483
+ } else if (!hasNamespace && prop.slice(0, 2) === "on") {
436
484
  const name = prop.slice(2).toLowerCase();
437
485
  const delegate = DelegatedEvents.has(name);
438
486
  if (!delegate && prev) {
@@ -443,11 +491,11 @@ function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
443
491
  addEventListener(node, name, value, delegate);
444
492
  delegate && delegateEvents([name]);
445
493
  }
446
- } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
494
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
447
495
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
448
496
  if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
449
497
  } else {
450
- const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
498
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
451
499
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
452
500
  }
453
501
  return value;
@@ -505,21 +553,22 @@ function eventHandler(e) {
505
553
  function insertExpression(parent, value, current, marker) {
506
554
  if (isHydrating(parent)) return;
507
555
  if (value === current) return;
556
+ const childRoot = getChildRoot(parent);
508
557
  const t = typeof value,
509
558
  multi = marker !== undefined;
510
559
  if (t === "string" || t === "number") {
511
560
  const tc = typeof current;
512
561
  if (tc === "string" || tc === "number") {
513
- parent.firstChild.data = value;
514
- } else parent.textContent = value;
562
+ childRoot.firstChild.data = value;
563
+ } else childRoot.textContent = value;
515
564
  } else if (value === undefined) {
516
565
  cleanChildren(parent, current, marker);
517
566
  } else if (value.nodeType) {
518
567
  if (Array.isArray(current)) {
519
568
  cleanChildren(parent, current, multi ? marker : null, value);
520
- } else if (current === undefined || !parent.firstChild) {
521
- parent.appendChild(value);
522
- } else parent.replaceChild(value, parent.firstChild);
569
+ } else if (current === undefined || !childRoot.firstChild) {
570
+ childRoot.appendChild(value);
571
+ } else childRoot.replaceChild(value, childRoot.firstChild);
523
572
  } else if (Array.isArray(value)) {
524
573
  const currentArray = current && Array.isArray(current);
525
574
  if (value.length === 0) {
@@ -527,7 +576,7 @@ function insertExpression(parent, value, current, marker) {
527
576
  } else if (currentArray) {
528
577
  if (current.length === 0) {
529
578
  appendNodes(parent, value, marker);
530
- } else reconcileArrays(parent, current, value);
579
+ } else reconcileArrays(childRoot, current, value);
531
580
  } else {
532
581
  current && cleanChildren(parent);
533
582
  appendNodes(parent, value);
@@ -552,9 +601,11 @@ function normalize(value, current, multi, doNotUnwrap) {
552
601
  return value;
553
602
  }
554
603
  function appendNodes(parent, array, marker = null) {
604
+ parent = getChildRoot(parent);
555
605
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
556
606
  }
557
607
  function cleanChildren(parent, current, marker, replacement) {
608
+ parent = getChildRoot(parent);
558
609
  if (marker === undefined) return parent.textContent = "";
559
610
  if (current.length) {
560
611
  let inserted = false;
@@ -609,9 +660,8 @@ function render(...args) {
609
660
  }
610
661
  const isServer = false;
611
662
  const isDev = false;
612
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
613
- function createElement(tagName, isSVG = false, is = undefined) {
614
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
663
+ function createElement(tagName, is = undefined) {
664
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
615
665
  is
616
666
  });
617
667
  }
@@ -664,9 +714,8 @@ function createDynamic(component, props) {
664
714
  case "function":
665
715
  return solidJs.untrack(() => component(props));
666
716
  case "string":
667
- const isSvg = SVGElements.has(component);
668
- const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
669
- spread(el, props, isSvg);
717
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, solidJs.untrack(() => props.is));
718
+ spread(el, props);
670
719
  return el;
671
720
  }
672
721
  });
@@ -700,6 +749,14 @@ Object.defineProperty(exports, "NoHydration", {
700
749
  enumerable: true,
701
750
  get: function () { return solidJs.NoHydration; }
702
751
  });
752
+ Object.defineProperty(exports, "Repeat", {
753
+ enumerable: true,
754
+ get: function () { return solidJs.Repeat; }
755
+ });
756
+ Object.defineProperty(exports, "Reveal", {
757
+ enumerable: true,
758
+ get: function () { return solidJs.Reveal; }
759
+ });
703
760
  Object.defineProperty(exports, "Show", {
704
761
  enumerable: true,
705
762
  get: function () { return solidJs.Show; }
@@ -732,10 +789,10 @@ exports.DelegatedEvents = DelegatedEvents;
732
789
  exports.Dynamic = Dynamic;
733
790
  exports.HydrationScript = voidFn;
734
791
  exports.MathMLElements = MathMLElements;
792
+ exports.Namespaces = Namespaces;
735
793
  exports.Portal = Portal;
736
794
  exports.RequestContext = RequestContext;
737
795
  exports.SVGElements = SVGElements;
738
- exports.SVGNamespace = SVGNamespace;
739
796
  exports.addEventListener = addEventListener;
740
797
  exports.applyRef = applyRef;
741
798
  exports.assign = assign;
package/dist/web.js CHANGED
@@ -1,27 +1,33 @@
1
1
  import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, enableHydration } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
  import { createMemo } from '@solidjs/signals';
4
4
 
5
5
  const DOMWithState = {
6
6
  INPUT: {
7
7
  value: 1,
8
- checked: 1
8
+ defaultValue: 2,
9
+ checked: 1,
10
+ defaultChecked: 2
9
11
  },
10
12
  SELECT: {
11
13
  value: 1
12
14
  },
13
15
  OPTION: {
14
16
  value: 1,
15
- selected: 1
17
+ selected: 1,
18
+ defaultSelected: 2
16
19
  },
17
20
  TEXTAREA: {
18
- value: 1
21
+ value: 1,
22
+ defaultValue: 2
19
23
  },
20
24
  VIDEO: {
21
- muted: 1
25
+ muted: 1,
26
+ defaultMuted: 2
22
27
  },
23
28
  AUDIO: {
24
- muted: 1
29
+ muted: 1,
30
+ defaultMuted: 2
25
31
  }
26
32
  };
27
33
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
@@ -32,7 +38,9 @@ const SVGElements = /*#__PURE__*/new Set([
32
38
  "svg", "switch", "symbol", "text", "textPath",
33
39
  "tref", "tspan", "use", "view", "vkern"]);
34
40
  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"]);
35
- const SVGNamespace = {
41
+ const Namespaces = {
42
+ svg: "http://www.w3.org/2000/svg",
43
+ mathml: "http://www.w3.org/1998/Math/MathML",
36
44
  xlink: "http://www.w3.org/1999/xlink",
37
45
  xml: "http://www.w3.org/XML/1998/namespace"
38
46
  };
@@ -40,10 +48,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
40
48
  "webview",
41
49
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
42
50
 
43
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
51
+ const effect = (fn, effectFn) => createRenderEffect(fn, effectFn, {
44
52
  transparent: true
45
53
  });
46
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), undefined, {
54
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
47
55
  transparent: true
48
56
  }) : createMemo$1(() => fn());
49
57
 
@@ -106,16 +114,17 @@ function reconcileArrays(parentNode, a, b) {
106
114
 
107
115
  const $$EVENTS = "_$DX_DELEGATE";
108
116
  function render$1(code, element, init, options = {}) {
117
+ const renderRoot = getChildRoot(element);
109
118
  let disposer;
110
119
  createRoot(dispose => {
111
120
  disposer = dispose;
112
- element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
121
+ element === document ? flatten(code) : insert(element, code(), renderRoot.firstChild ? null : undefined, init);
113
122
  }, {
114
123
  id: options.renderId
115
124
  });
116
125
  return () => {
117
126
  disposer();
118
- element.textContent = "";
127
+ renderRoot.textContent = "";
119
128
  };
120
129
  }
121
130
  function create(html, bypassGuard, flag) {
@@ -253,10 +262,11 @@ function ref(fn, element) {
253
262
  runWithOwner(null, () => applyRef(resolved, element));
254
263
  }
255
264
  function insert(parent, accessor, marker, initial) {
265
+ const childRoot = getChildRoot(parent);
256
266
  const multi = marker !== undefined;
257
267
  if (multi && !initial) initial = [];
258
268
  if (isHydrating(parent)) {
259
- if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
269
+ if (!multi && initial === undefined && parent) initial = [...childRoot.childNodes];
260
270
  if (Array.isArray(initial)) {
261
271
  let j = 0;
262
272
  for (let i = 0; i < initial.length; i++) {
@@ -272,10 +282,10 @@ function insert(parent, accessor, marker, initial) {
272
282
  accessor = memo(accessor, true);
273
283
  if (multi && initial.length === 0) {
274
284
  const placeholder = document.createTextNode("");
275
- parent.insertBefore(placeholder, marker);
285
+ childRoot.insertBefore(placeholder, marker);
276
286
  initial = [placeholder];
277
287
  }
278
- effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
288
+ effect((prev = initial) => normalize(accessor, prev, multi), (value, current = initial) => insertExpression(parent, value, current, marker));
279
289
  }
280
290
  function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
281
291
  const nodeName = node.nodeName;
@@ -283,19 +293,35 @@ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
283
293
  for (const prop in prevProps) {
284
294
  if (!(prop in props)) {
285
295
  if (prop === "children") continue;
286
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName, prevProps);
296
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
287
297
  }
288
298
  }
289
299
  for (const prop in props) {
290
300
  if (prop === "children") {
291
- if (!skipChildren) insertExpression(node, props.children);
301
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
292
302
  continue;
293
303
  }
294
- prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName, props);
304
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
305
+ }
306
+ }
307
+ function loadModuleAssets(mapping) {
308
+ const hy = globalThis._$HY;
309
+ if (!hy) return;
310
+ const pending = [];
311
+ for (const moduleUrl in mapping) {
312
+ if (hy.modules[moduleUrl]) continue;
313
+ const entryUrl = mapping[moduleUrl];
314
+ if (!hy.loading[moduleUrl]) {
315
+ hy.loading[moduleUrl] = import(entryUrl).then(mod => {
316
+ hy.modules[moduleUrl] = mod;
317
+ });
318
+ }
319
+ pending.push(hy.loading[moduleUrl]);
295
320
  }
321
+ return pending.length ? Promise.all(pending).then(() => {}) : undefined;
296
322
  }
297
323
  function hydrate$1(code, element, options = {}) {
298
- if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
324
+ if (globalThis._$HY.done) return render$1(code, element, [...getChildRoot(element).childNodes], options);
299
325
  options.renderId ||= "";
300
326
  if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
301
327
  if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
@@ -304,6 +330,7 @@ function hydrate$1(code, element, options = {}) {
304
330
  sharedConfig.load = id => globalThis._$HY.r[id];
305
331
  sharedConfig.has = id => id in globalThis._$HY.r;
306
332
  sharedConfig.gather = root => gatherHydratable(element, root);
333
+ sharedConfig.loadModuleAssets = loadModuleAssets;
307
334
  sharedConfig.cleanupFragment = id => {
308
335
  const tpl = document.getElementById("pl-" + id);
309
336
  if (tpl) {
@@ -322,9 +349,27 @@ function hydrate$1(code, element, options = {}) {
322
349
  };
323
350
  sharedConfig.registry = new Map();
324
351
  sharedConfig.hydrating = true;
352
+ const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
353
+ if (rootMapping && typeof rootMapping === "object") {
354
+ const p = loadModuleAssets(rootMapping);
355
+ if (p) {
356
+ gatherHydratable(element, options.renderId);
357
+ let disposer;
358
+ p.then(() => {
359
+ try {
360
+ disposer = render$1(code, element, [...getChildRoot(element).childNodes], options);
361
+ } finally {
362
+ sharedConfig.hydrating = false;
363
+ }
364
+ }, () => {
365
+ sharedConfig.hydrating = false;
366
+ });
367
+ return () => disposer && disposer();
368
+ }
369
+ }
325
370
  try {
326
371
  gatherHydratable(element, options.renderId);
327
- return render$1(code, element, [...element.childNodes], options);
372
+ return render$1(code, element, [...getChildRoot(element).childNodes], options);
328
373
  } finally {
329
374
  sharedConfig.hydrating = false;
330
375
  }
@@ -367,7 +412,7 @@ function getNextMarker(start) {
367
412
  return [end, current];
368
413
  }
369
414
  function getFirstChild(node, expectedTag) {
370
- const child = node.firstChild;
415
+ const child = getChildRoot(node).firstChild;
371
416
  return child;
372
417
  }
373
418
  function getNextSibling(node, expectedTag) {
@@ -400,6 +445,9 @@ function runHydrationEvents() {
400
445
  function isHydrating(node) {
401
446
  return sharedConfig.hydrating && (!node || node.isConnected);
402
447
  }
448
+ function getChildRoot(node) {
449
+ return node && node.localName === "template" ? node.content : node;
450
+ }
403
451
  function toggleClassKey(node, key, value) {
404
452
  const classNames = key.trim().split(/\s+/);
405
453
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
@@ -418,10 +466,10 @@ function flattenClassList(list, result) {
418
466
  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;
419
467
  }
420
468
  }
421
- function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
469
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
422
470
  if (prop === "style") return style(node, value, prev), value;
423
471
  if (prop === "class") return className(node, value, prev), value;
424
- if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
472
+ if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
425
473
  if (prop === "ref") {
426
474
  if (!skipRef && value) ref(() => value, node);
427
475
  return value;
@@ -431,7 +479,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
431
479
  const e = prop.slice(3);
432
480
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
433
481
  value && node.addEventListener(e, value, typeof value !== "function" && value);
434
- } else if (prop.slice(0, 2) === "on") {
482
+ } else if (!hasNamespace && prop.slice(0, 2) === "on") {
435
483
  const name = prop.slice(2).toLowerCase();
436
484
  const delegate = DelegatedEvents.has(name);
437
485
  if (!delegate && prev) {
@@ -442,11 +490,11 @@ function assignProp(node, prop, value, prev, skipRef, nodeName, props) {
442
490
  addEventListener(node, name, value, delegate);
443
491
  delegate && delegateEvents([name]);
444
492
  }
445
- } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop] && !("prop:" + prop in props)) {
493
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
446
494
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
447
495
  if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
448
496
  } else {
449
- const ns = hasNamespace && SVGNamespace[prop.split(":")[0]];
497
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
450
498
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
451
499
  }
452
500
  return value;
@@ -504,21 +552,22 @@ function eventHandler(e) {
504
552
  function insertExpression(parent, value, current, marker) {
505
553
  if (isHydrating(parent)) return;
506
554
  if (value === current) return;
555
+ const childRoot = getChildRoot(parent);
507
556
  const t = typeof value,
508
557
  multi = marker !== undefined;
509
558
  if (t === "string" || t === "number") {
510
559
  const tc = typeof current;
511
560
  if (tc === "string" || tc === "number") {
512
- parent.firstChild.data = value;
513
- } else parent.textContent = value;
561
+ childRoot.firstChild.data = value;
562
+ } else childRoot.textContent = value;
514
563
  } else if (value === undefined) {
515
564
  cleanChildren(parent, current, marker);
516
565
  } else if (value.nodeType) {
517
566
  if (Array.isArray(current)) {
518
567
  cleanChildren(parent, current, multi ? marker : null, value);
519
- } else if (current === undefined || !parent.firstChild) {
520
- parent.appendChild(value);
521
- } else parent.replaceChild(value, parent.firstChild);
568
+ } else if (current === undefined || !childRoot.firstChild) {
569
+ childRoot.appendChild(value);
570
+ } else childRoot.replaceChild(value, childRoot.firstChild);
522
571
  } else if (Array.isArray(value)) {
523
572
  const currentArray = current && Array.isArray(current);
524
573
  if (value.length === 0) {
@@ -526,7 +575,7 @@ function insertExpression(parent, value, current, marker) {
526
575
  } else if (currentArray) {
527
576
  if (current.length === 0) {
528
577
  appendNodes(parent, value, marker);
529
- } else reconcileArrays(parent, current, value);
578
+ } else reconcileArrays(childRoot, current, value);
530
579
  } else {
531
580
  current && cleanChildren(parent);
532
581
  appendNodes(parent, value);
@@ -551,9 +600,11 @@ function normalize(value, current, multi, doNotUnwrap) {
551
600
  return value;
552
601
  }
553
602
  function appendNodes(parent, array, marker = null) {
603
+ parent = getChildRoot(parent);
554
604
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
555
605
  }
556
606
  function cleanChildren(parent, current, marker, replacement) {
607
+ parent = getChildRoot(parent);
557
608
  if (marker === undefined) return parent.textContent = "";
558
609
  if (current.length) {
559
610
  let inserted = false;
@@ -608,9 +659,8 @@ function render(...args) {
608
659
  }
609
660
  const isServer = false;
610
661
  const isDev = false;
611
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
612
- function createElement(tagName, isSVG = false, is = undefined) {
613
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
662
+ function createElement(tagName, is = undefined) {
663
+ return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
614
664
  is
615
665
  });
616
666
  }
@@ -663,9 +713,8 @@ function createDynamic(component, props) {
663
713
  case "function":
664
714
  return untrack(() => component(props));
665
715
  case "string":
666
- const isSvg = SVGElements.has(component);
667
- const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
668
- spread(el, props, isSvg);
716
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
717
+ spread(el, props);
669
718
  return el;
670
719
  }
671
720
  });
@@ -675,4 +724,4 @@ function Dynamic(props) {
675
724
  return createDynamic(() => props.component, others);
676
725
  }
677
726
 
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 };
727
+ export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RequestContext, SVGElements, 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 };