@solidjs/web 2.0.0-experimental.2 → 2.0.0-experimental.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.cjs CHANGED
@@ -363,14 +363,17 @@ function toggleClassKey(node, key, value) {
363
363
  function classListToObject(classList) {
364
364
  if (Array.isArray(classList)) {
365
365
  const result = {};
366
- for (let i = 0, len = classList.length; i < len; i++) {
367
- const key = classList[i];
368
- if (typeof key === "object" && key != null) Object.assign(result, key);else if (key || key === 0) result[key] = true;
369
- }
366
+ flattenClassList(classList, result);
370
367
  return result;
371
368
  }
372
369
  return classList;
373
370
  }
371
+ function flattenClassList(list, result) {
372
+ for (let i = 0, len = list.length; i < len; i++) {
373
+ const item = list[i];
374
+ 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;
375
+ }
376
+ }
374
377
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
375
378
  let propAlias, forceProp;
376
379
  if (prop === "style") return style(node, value, prev), value;
@@ -398,7 +401,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
398
401
  } else if (prop.slice(0, 5) === "bool:") {
399
402
  setBoolAttribute(node, prop.slice(5), value);
400
403
  } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && (propAlias = getPropAlias(prop, node.tagName)) || Properties.has(prop)) {
401
- if (forceProp) prop = prop.slice(5);else node[propAlias || prop] = value;
404
+ if (forceProp) prop = prop.slice(5);
405
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[propAlias || prop] = value;
402
406
  } else {
403
407
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
404
408
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -493,7 +497,7 @@ function normalize(value, current, multi, doNotUnwrap) {
493
497
  doNotUnwrap
494
498
  });
495
499
  if (doNotUnwrap && typeof value === "function") return value;
496
- if (multi && value != null && !Array.isArray(value)) value = [value];
500
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
497
501
  if (Array.isArray(value)) {
498
502
  for (let i = 0, len = value.length; i < len; i++) {
499
503
  const item = value[i],
package/dist/dev.js CHANGED
@@ -830,15 +830,19 @@ function toggleClassKey(node, key, value) {
830
830
  function classListToObject(classList) {
831
831
  if (Array.isArray(classList)) {
832
832
  const result = {};
833
- for (let i = 0, len = classList.length; i < len; i++) {
834
- const key = classList[i];
835
- if (typeof key === "object" && key != null) Object.assign(result, key);
836
- else if (key || key === 0) result[key] = true;
837
- }
833
+ flattenClassList(classList, result);
838
834
  return result;
839
835
  }
840
836
  return classList;
841
837
  }
838
+ function flattenClassList(list, result) {
839
+ for (let i = 0, len = list.length; i < len; i++) {
840
+ const item = list[i];
841
+ if (Array.isArray(item)) flattenClassList(item, result);
842
+ else if (typeof item === "object" && item != null) Object.assign(result, item);
843
+ else if (item || item === 0) result[item] = true;
844
+ }
845
+ }
842
846
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
843
847
  let propAlias, forceProp;
844
848
  if (prop === "style") return style(node, value, prev), value;
@@ -872,6 +876,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
872
876
  Properties.has(prop)
873
877
  ) {
874
878
  if (forceProp) prop = prop.slice(5);
879
+ if (prop === "value" && node.nodeName === "SELECT")
880
+ queueMicrotask(() => (node.value = value)) || (node.value = value);
875
881
  else node[propAlias || prop] = value;
876
882
  } else {
877
883
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
@@ -972,7 +978,7 @@ function normalize(value, current, multi, doNotUnwrap) {
972
978
  doNotUnwrap
973
979
  });
974
980
  if (doNotUnwrap && typeof value === "function") return value;
975
- if (multi && value != null && !Array.isArray(value)) value = [value];
981
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
976
982
  if (Array.isArray(value)) {
977
983
  for (let i = 0, len = value.length; i < len; i++) {
978
984
  const item = value[i],
package/dist/server.cjs CHANGED
@@ -369,6 +369,8 @@ function ssr(t, ...nodes) {
369
369
  }
370
370
  function ssrClassName(value) {
371
371
  if (!value) return "";
372
+ if (typeof value === "string") return escape(value, true);
373
+ value = classListToObject(value);
372
374
  let classKeys = Object.keys(value),
373
375
  result = "";
374
376
  for (let i = 0, len = classKeys.length; i < len; i++) {
@@ -403,7 +405,7 @@ function ssrElement(tag, props, children, needsId) {
403
405
  for (let i = 0; i < keys.length; i++) {
404
406
  const prop = keys[i];
405
407
  if (ChildProperties.has(prop)) {
406
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
408
+ if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
407
409
  continue;
408
410
  }
409
411
  const value = props[prop];
@@ -421,7 +423,7 @@ function ssrElement(tag, props, children, needsId) {
421
423
  } else if (prop.slice(0, 5) === "attr:") {
422
424
  result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
423
425
  } else {
424
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
426
+ result += `${escape(prop)}="${escape(value, true)}"`;
425
427
  }
426
428
  if (i !== keys.length - 1) result += " ";
427
429
  }
@@ -503,6 +505,29 @@ function resolveSSRNode(node, top) {
503
505
  if (t === "function") return resolveSSRNode(node());
504
506
  return String(node);
505
507
  }
508
+ function mergeProps(...sources) {
509
+ const target = {};
510
+ for (let i = 0; i < sources.length; i++) {
511
+ let source = sources[i];
512
+ if (typeof source === "function") source = source();
513
+ if (source) {
514
+ const descriptors = Object.getOwnPropertyDescriptors(source);
515
+ for (const key in descriptors) {
516
+ if (key in target) continue;
517
+ Object.defineProperty(target, key, {
518
+ enumerable: true,
519
+ get() {
520
+ for (let i = sources.length - 1; i >= 0; i--) {
521
+ const v = (sources[i] || {})[key];
522
+ if (v !== undefined) return v;
523
+ }
524
+ }
525
+ });
526
+ }
527
+ }
528
+ }
529
+ return target;
530
+ }
506
531
  function getHydrationKey() {
507
532
  const hydrate = solidJs.sharedConfig.context;
508
533
  return hydrate && !hydrate.noHydrate && solidJs.sharedConfig.getNextContextId();
@@ -579,6 +604,20 @@ function replacePlaceholder(html, key, value) {
579
604
  const last = html.indexOf(close, first + marker.length);
580
605
  return html.slice(0, first) + value + html.slice(last + close.length);
581
606
  }
607
+ function classListToObject(classList) {
608
+ if (Array.isArray(classList)) {
609
+ const result = {};
610
+ flattenClassList(classList, result);
611
+ return result;
612
+ }
613
+ return classList;
614
+ }
615
+ function flattenClassList(list, result) {
616
+ for (let i = 0, len = list.length; i < len; i++) {
617
+ const item = list[i];
618
+ 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;
619
+ }
620
+ }
582
621
  const RequestContext = Symbol();
583
622
  function getRequestEvent() {
584
623
  return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.log("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
@@ -602,11 +641,11 @@ function createDynamic(component, props) {
602
641
  }
603
642
  }
604
643
  function Dynamic(props) {
605
- const [, others] = solidJs.splitProps(props, ["component"]);
644
+ const others = solidJs.omit(props, "component");
606
645
  return createDynamic(() => props.component, others);
607
646
  }
608
647
  function Portal(props) {
609
- return "";
648
+ throw new Error("Portal is not supported on the server");
610
649
  }
611
650
 
612
651
  Object.defineProperty(exports, "ErrorBoundary", {
@@ -617,14 +656,14 @@ Object.defineProperty(exports, "For", {
617
656
  enumerable: true,
618
657
  get: function () { return solidJs.For; }
619
658
  });
620
- Object.defineProperty(exports, "Index", {
621
- enumerable: true,
622
- get: function () { return solidJs.Index; }
623
- });
624
659
  Object.defineProperty(exports, "Match", {
625
660
  enumerable: true,
626
661
  get: function () { return solidJs.Match; }
627
662
  });
663
+ Object.defineProperty(exports, "Repeat", {
664
+ enumerable: true,
665
+ get: function () { return solidJs.Repeat; }
666
+ });
628
667
  Object.defineProperty(exports, "Show", {
629
668
  enumerable: true,
630
669
  get: function () { return solidJs.Show; }
@@ -633,10 +672,6 @@ Object.defineProperty(exports, "Suspense", {
633
672
  enumerable: true,
634
673
  get: function () { return solidJs.Suspense; }
635
674
  });
636
- Object.defineProperty(exports, "SuspenseList", {
637
- enumerable: true,
638
- get: function () { return solidJs.SuspenseList; }
639
- });
640
675
  Object.defineProperty(exports, "Switch", {
641
676
  enumerable: true,
642
677
  get: function () { return solidJs.Switch; }
@@ -657,10 +692,6 @@ Object.defineProperty(exports, "memo", {
657
692
  enumerable: true,
658
693
  get: function () { return solidJs.createMemo; }
659
694
  });
660
- Object.defineProperty(exports, "mergeProps", {
661
- enumerable: true,
662
- get: function () { return solidJs.mergeProps; }
663
- });
664
695
  Object.defineProperty(exports, "untrack", {
665
696
  enumerable: true,
666
697
  get: function () { return solidJs.untrack; }
@@ -697,6 +728,7 @@ exports.hydrate = notSup;
697
728
  exports.insert = notSup;
698
729
  exports.isDev = isDev;
699
730
  exports.isServer = isServer;
731
+ exports.mergeProps = mergeProps;
700
732
  exports.render = notSup;
701
733
  exports.renderToStream = renderToStream;
702
734
  exports.renderToString = renderToString;
package/dist/server.js CHANGED
@@ -1,18 +1,16 @@
1
- import { sharedConfig, createRoot, splitProps } from "solid-js";
1
+ import { sharedConfig, createRoot, omit } from "solid-js";
2
2
  export {
3
3
  ErrorBoundary,
4
4
  For,
5
- Index,
6
5
  Match,
6
+ Repeat,
7
7
  Show,
8
8
  Suspense,
9
- SuspenseList,
10
9
  Switch,
11
10
  createComponent,
12
11
  createRenderEffect as effect,
13
12
  getOwner,
14
13
  createMemo as memo,
15
- mergeProps,
16
14
  untrack
17
15
  } from "solid-js";
18
16
  import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
@@ -816,6 +814,8 @@ function ssr(t, ...nodes) {
816
814
  }
817
815
  function ssrClassName(value) {
818
816
  if (!value) return "";
817
+ if (typeof value === "string") return escape(value, true);
818
+ value = classListToObject(value);
819
819
  let classKeys = Object.keys(value),
820
820
  result = "";
821
821
  for (let i = 0, len = classKeys.length; i < len; i++) {
@@ -852,7 +852,10 @@ function ssrElement(tag, props, children, needsId) {
852
852
  const prop = keys[i];
853
853
  if (ChildProperties.has(prop)) {
854
854
  if (children === undefined && !skipChildren)
855
- children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
855
+ children =
856
+ tag === "script" || tag === "style" || prop === "innerHTML"
857
+ ? props[prop]
858
+ : escape(props[prop]);
856
859
  continue;
857
860
  }
858
861
  const value = props[prop];
@@ -876,7 +879,7 @@ function ssrElement(tag, props, children, needsId) {
876
879
  } else if (prop.slice(0, 5) === "attr:") {
877
880
  result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
878
881
  } else {
879
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
882
+ result += `${escape(prop)}="${escape(value, true)}"`;
880
883
  }
881
884
  if (i !== keys.length - 1) result += " ";
882
885
  }
@@ -960,6 +963,29 @@ function resolveSSRNode(node, top) {
960
963
  if (t === "function") return resolveSSRNode(node());
961
964
  return String(node);
962
965
  }
966
+ function mergeProps(...sources) {
967
+ const target = {};
968
+ for (let i = 0; i < sources.length; i++) {
969
+ let source = sources[i];
970
+ if (typeof source === "function") source = source();
971
+ if (source) {
972
+ const descriptors = Object.getOwnPropertyDescriptors(source);
973
+ for (const key in descriptors) {
974
+ if (key in target) continue;
975
+ Object.defineProperty(target, key, {
976
+ enumerable: true,
977
+ get() {
978
+ for (let i = sources.length - 1; i >= 0; i--) {
979
+ const v = (sources[i] || {})[key];
980
+ if (v !== undefined) return v;
981
+ }
982
+ }
983
+ });
984
+ }
985
+ }
986
+ }
987
+ return target;
988
+ }
963
989
  function getHydrationKey() {
964
990
  const hydrate = sharedConfig.context;
965
991
  return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
@@ -1037,6 +1063,22 @@ function replacePlaceholder(html, key, value) {
1037
1063
  const last = html.indexOf(close, first + marker.length);
1038
1064
  return html.slice(0, first) + value + html.slice(last + close.length);
1039
1065
  }
1066
+ function classListToObject(classList) {
1067
+ if (Array.isArray(classList)) {
1068
+ const result = {};
1069
+ flattenClassList(classList, result);
1070
+ return result;
1071
+ }
1072
+ return classList;
1073
+ }
1074
+ function flattenClassList(list, result) {
1075
+ for (let i = 0, len = list.length; i < len; i++) {
1076
+ const item = list[i];
1077
+ if (Array.isArray(item)) flattenClassList(item, result);
1078
+ else if (typeof item === "object" && item != null) Object.assign(result, item);
1079
+ else if (item || item === 0) result[item] = true;
1080
+ }
1081
+ }
1040
1082
  const RequestContext = Symbol();
1041
1083
  function getRequestEvent() {
1042
1084
  return globalThis[RequestContext]
@@ -1069,11 +1111,11 @@ function createDynamic(component, props) {
1069
1111
  }
1070
1112
  }
1071
1113
  function Dynamic(props) {
1072
- const [, others] = splitProps(props, ["component"]);
1114
+ const others = omit(props, "component");
1073
1115
  return createDynamic(() => props.component, others);
1074
1116
  }
1075
1117
  function Portal(props) {
1076
- return "";
1118
+ throw new Error("Portal is not supported on the server");
1077
1119
  }
1078
1120
 
1079
1121
  export {
@@ -1109,6 +1151,7 @@ export {
1109
1151
  notSup as insert,
1110
1152
  isDev,
1111
1153
  isServer,
1154
+ mergeProps,
1112
1155
  notSup as render,
1113
1156
  renderToStream,
1114
1157
  renderToString,
package/dist/web.cjs CHANGED
@@ -355,14 +355,17 @@ function toggleClassKey(node, key, value) {
355
355
  function classListToObject(classList) {
356
356
  if (Array.isArray(classList)) {
357
357
  const result = {};
358
- for (let i = 0, len = classList.length; i < len; i++) {
359
- const key = classList[i];
360
- if (typeof key === "object" && key != null) Object.assign(result, key);else if (key || key === 0) result[key] = true;
361
- }
358
+ flattenClassList(classList, result);
362
359
  return result;
363
360
  }
364
361
  return classList;
365
362
  }
363
+ function flattenClassList(list, result) {
364
+ for (let i = 0, len = list.length; i < len; i++) {
365
+ const item = list[i];
366
+ 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;
367
+ }
368
+ }
366
369
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
367
370
  let propAlias, forceProp;
368
371
  if (prop === "style") return style(node, value, prev), value;
@@ -390,7 +393,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
390
393
  } else if (prop.slice(0, 5) === "bool:") {
391
394
  setBoolAttribute(node, prop.slice(5), value);
392
395
  } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && (propAlias = getPropAlias(prop, node.tagName)) || Properties.has(prop)) {
393
- if (forceProp) prop = prop.slice(5);else node[propAlias || prop] = value;
396
+ if (forceProp) prop = prop.slice(5);
397
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[propAlias || prop] = value;
394
398
  } else {
395
399
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
396
400
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -485,7 +489,7 @@ function normalize(value, current, multi, doNotUnwrap) {
485
489
  doNotUnwrap
486
490
  });
487
491
  if (doNotUnwrap && typeof value === "function") return value;
488
- if (multi && value != null && !Array.isArray(value)) value = [value];
492
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
489
493
  if (Array.isArray(value)) {
490
494
  for (let i = 0, len = value.length; i < len; i++) {
491
495
  const item = value[i],
package/dist/web.js CHANGED
@@ -812,15 +812,19 @@ function toggleClassKey(node, key, value) {
812
812
  function classListToObject(classList) {
813
813
  if (Array.isArray(classList)) {
814
814
  const result = {};
815
- for (let i = 0, len = classList.length; i < len; i++) {
816
- const key = classList[i];
817
- if (typeof key === "object" && key != null) Object.assign(result, key);
818
- else if (key || key === 0) result[key] = true;
819
- }
815
+ flattenClassList(classList, result);
820
816
  return result;
821
817
  }
822
818
  return classList;
823
819
  }
820
+ function flattenClassList(list, result) {
821
+ for (let i = 0, len = list.length; i < len; i++) {
822
+ const item = list[i];
823
+ if (Array.isArray(item)) flattenClassList(item, result);
824
+ else if (typeof item === "object" && item != null) Object.assign(result, item);
825
+ else if (item || item === 0) result[item] = true;
826
+ }
827
+ }
824
828
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
825
829
  let propAlias, forceProp;
826
830
  if (prop === "style") return style(node, value, prev), value;
@@ -854,6 +858,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
854
858
  Properties.has(prop)
855
859
  ) {
856
860
  if (forceProp) prop = prop.slice(5);
861
+ if (prop === "value" && node.nodeName === "SELECT")
862
+ queueMicrotask(() => (node.value = value)) || (node.value = value);
857
863
  else node[propAlias || prop] = value;
858
864
  } else {
859
865
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
@@ -954,7 +960,7 @@ function normalize(value, current, multi, doNotUnwrap) {
954
960
  doNotUnwrap
955
961
  });
956
962
  if (doNotUnwrap && typeof value === "function") return value;
957
- if (multi && value != null && !Array.isArray(value)) value = [value];
963
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
958
964
  if (Array.isArray(value)) {
959
965
  for (let i = 0, len = value.length; i < len; i++) {
960
966
  const item = value[i],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/web",
3
3
  "description": "Solid's web runtime for the browser and the server",
4
- "version": "2.0.0-experimental.2",
4
+ "version": "2.0.0-experimental.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -75,10 +75,10 @@
75
75
  "seroval-plugins": "^1.1.0"
76
76
  },
77
77
  "peerDependencies": {
78
- "solid-js": "^2.0.0-experimental.2"
78
+ "solid-js": "^2.0.0-experimental.4"
79
79
  },
80
80
  "devDependencies": {
81
- "solid-js": "2.0.0-experimental.2"
81
+ "solid-js": "2.0.0-experimental.4"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "npm-run-all -nl build:*",