@solidjs/web 2.0.0-experimental.1 → 2.0.0-experimental.3

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/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
  }
@@ -579,6 +581,20 @@ function replacePlaceholder(html, key, value) {
579
581
  const last = html.indexOf(close, first + marker.length);
580
582
  return html.slice(0, first) + value + html.slice(last + close.length);
581
583
  }
584
+ function classListToObject(classList) {
585
+ if (Array.isArray(classList)) {
586
+ const result = {};
587
+ flattenClassList(classList, result);
588
+ return result;
589
+ }
590
+ return classList;
591
+ }
592
+ function flattenClassList(list, result) {
593
+ for (let i = 0, len = list.length; i < len; i++) {
594
+ const item = list[i];
595
+ 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;
596
+ }
597
+ }
582
598
  const RequestContext = Symbol();
583
599
  function getRequestEvent() {
584
600
  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;
@@ -592,16 +608,19 @@ function notSup() {
592
608
 
593
609
  const isServer = true;
594
610
  const isDev = false;
595
- function Dynamic(props) {
596
- const [p, others] = solidJs.splitProps(props, ["component"]);
597
- const comp = p.component,
611
+ function createDynamic(component, props) {
612
+ const comp = component(),
598
613
  t = typeof comp;
599
614
  if (comp) {
600
- if (t === "function") return comp(others);else if (t === "string") {
601
- return ssrElement(comp, others, undefined, true);
615
+ if (t === "function") return comp(props);else if (t === "string") {
616
+ return ssrElement(comp, props, undefined, true);
602
617
  }
603
618
  }
604
619
  }
620
+ function Dynamic(props) {
621
+ const [, others] = solidJs.splitProps(props, ["component"]);
622
+ return createDynamic(() => props.component, others);
623
+ }
605
624
  function Portal(props) {
606
625
  return "";
607
626
  }
@@ -678,6 +697,7 @@ exports.SVGNamespace = SVGNamespace;
678
697
  exports.addEventListener = notSup;
679
698
  exports.assign = notSup;
680
699
  exports.className = notSup;
700
+ exports.createDynamic = createDynamic;
681
701
  exports.delegateEvents = notSup;
682
702
  exports.dynamicProperty = notSup;
683
703
  exports.escape = escape;