solid-js 1.8.23 → 1.9.0

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/web/dist/dev.js CHANGED
@@ -571,7 +571,7 @@ function render(code, element, init, options = {}) {
571
571
  element.textContent = "";
572
572
  };
573
573
  }
574
- function template(html, isCE, isSVG) {
574
+ function template(html, isImportNode, isSVG) {
575
575
  let node;
576
576
  const create = () => {
577
577
  if (isHydrating())
@@ -582,7 +582,7 @@ function template(html, isCE, isSVG) {
582
582
  t.innerHTML = html;
583
583
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
584
584
  };
585
- const fn = isCE
585
+ const fn = isImportNode
586
586
  ? () => untrack(() => document.importNode(node || (node = create()), true))
587
587
  : () => (node || (node = create())).cloneNode(true);
588
588
  fn.cloneNode = fn;
@@ -618,6 +618,10 @@ function setAttributeNS(node, namespace, name, value) {
618
618
  if (value == null) node.removeAttributeNS(namespace, name);
619
619
  else node.setAttributeNS(namespace, name, value);
620
620
  }
621
+ function setBoolAttribute(node, name, value) {
622
+ if (isHydrating(node)) return;
623
+ value ? node.setAttribute(name, "") : node.removeAttribute(name);
624
+ }
621
625
  function className(node, value) {
622
626
  if (isHydrating(node)) return;
623
627
  if (value == null) node.removeAttribute("class");
@@ -632,7 +636,7 @@ function addEventListener(node, name, handler, delegate) {
632
636
  } else if (Array.isArray(handler)) {
633
637
  const handlerFn = handler[0];
634
638
  node.addEventListener(name, (handler[0] = e => handlerFn.call(node, handler[1], e)));
635
- } else node.addEventListener(name, handler);
639
+ } else node.addEventListener(name, handler, typeof handler !== "function" && handler);
636
640
  }
637
641
  function classList(node, value, prev = {}) {
638
642
  const classKeys = Object.keys(value || {}),
@@ -708,7 +712,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
708
712
  for (const prop in prevProps) {
709
713
  if (!(prop in props)) {
710
714
  if (prop === "children") continue;
711
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
715
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
712
716
  }
713
717
  }
714
718
  for (const prop in props) {
@@ -717,7 +721,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
717
721
  continue;
718
722
  }
719
723
  const value = props[prop];
720
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
724
+ prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
721
725
  }
722
726
  }
723
727
  function hydrate$1(code, element, options = {}) {
@@ -744,8 +748,14 @@ function getNextElement(template) {
744
748
  key,
745
749
  hydrating = isHydrating();
746
750
  if (!hydrating || !(node = sharedConfig.registry.get((key = getHydrationKey())))) {
747
- if (hydrating)
748
- throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
751
+ if (hydrating) {
752
+ sharedConfig.done = true;
753
+ throw new Error(
754
+ `Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${
755
+ template ? template().outerHTML : ""
756
+ }`
757
+ );
758
+ }
749
759
  return template();
750
760
  }
751
761
  if (sharedConfig.completed) sharedConfig.completed.add(node);
@@ -807,7 +817,7 @@ function toggleClassKey(node, key, value) {
807
817
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++)
808
818
  node.classList.toggle(classNames[i], value);
809
819
  }
810
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
820
+ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
811
821
  let isCE, isProp, isChildProp, propAlias, forceProp;
812
822
  if (prop === "style") return style(node, value, prev);
813
823
  if (prop === "classList") return classList(node, value, prev);
@@ -816,8 +826,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
816
826
  if (!skipRef) value(node);
817
827
  } else if (prop.slice(0, 3) === "on:") {
818
828
  const e = prop.slice(3);
819
- prev && node.removeEventListener(e, prev);
820
- value && node.addEventListener(e, value);
829
+ prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
830
+ value && node.addEventListener(e, value, typeof value !== "function" && value);
821
831
  } else if (prop.slice(0, 10) === "oncapture:") {
822
832
  const e = prop.slice(10);
823
833
  prev && node.removeEventListener(e, prev, true);
@@ -835,12 +845,14 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
835
845
  }
836
846
  } else if (prop.slice(0, 5) === "attr:") {
837
847
  setAttribute(node, prop.slice(5), value);
848
+ } else if (prop.slice(0, 5) === "bool:") {
849
+ setBoolAttribute(node, prop.slice(5), value);
838
850
  } else if (
839
851
  (forceProp = prop.slice(0, 5) === "prop:") ||
840
852
  (isChildProp = ChildProperties.has(prop)) ||
841
853
  (!isSVG &&
842
854
  ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop)))) ||
843
- (isCE = node.nodeName.includes("-"))
855
+ (isCE = node.nodeName.includes("-") || "is" in props)
844
856
  ) {
845
857
  if (forceProp) {
846
858
  prop = prop.slice(5);
@@ -860,14 +872,28 @@ function eventHandler(e) {
860
872
  if (sharedConfig.registry && sharedConfig.events) {
861
873
  if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
862
874
  }
875
+ let node = e.target;
863
876
  const key = `$$${e.type}`;
864
- let node = (e.composedPath && e.composedPath()[0]) || e.target;
865
- if (e.target !== node) {
877
+ const oriTarget = e.target;
878
+ const oriCurrentTarget = e.currentTarget;
879
+ const retarget = value =>
866
880
  Object.defineProperty(e, "target", {
867
881
  configurable: true,
868
- value: node
882
+ value
869
883
  });
870
- }
884
+ const handleNode = () => {
885
+ const handler = node[key];
886
+ if (handler && !node.disabled) {
887
+ const data = node[`${key}Data`];
888
+ data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
889
+ if (e.cancelBubble) return;
890
+ }
891
+ node.host && node.contains(e.target) && !node.host._$host && retarget(node.host);
892
+ return true;
893
+ };
894
+ const walkUpTree = () => {
895
+ while (handleNode() && (node = node._$host || node.parentNode || node.host));
896
+ };
871
897
  Object.defineProperty(e, "currentTarget", {
872
898
  configurable: true,
873
899
  get() {
@@ -875,15 +901,23 @@ function eventHandler(e) {
875
901
  }
876
902
  });
877
903
  if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
878
- while (node) {
879
- const handler = node[key];
880
- if (handler && !node.disabled) {
881
- const data = node[`${key}Data`];
882
- data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
883
- if (e.cancelBubble) return;
904
+ if (e.composedPath) {
905
+ const path = e.composedPath();
906
+ retarget(path[0]);
907
+ for (let i = 0; i < path.length - 2; i++) {
908
+ node = path[i];
909
+ if (!handleNode()) break;
910
+ if (node._$host) {
911
+ node = node._$host;
912
+ walkUpTree();
913
+ break;
914
+ }
915
+ if (node.parentNode === oriCurrentTarget) {
916
+ break;
917
+ }
884
918
  }
885
- node = node._$host || node.parentNode || node.host;
886
- }
919
+ } else walkUpTree();
920
+ retarget(oriTarget);
887
921
  }
888
922
  function insertExpression(parent, value, current, marker, unwrapArray) {
889
923
  const hydrating = isHydrating(parent);
@@ -1186,6 +1220,7 @@ export {
1186
1220
  runHydrationEvents,
1187
1221
  setAttribute,
1188
1222
  setAttributeNS,
1223
+ setBoolAttribute,
1189
1224
  setProperty,
1190
1225
  spread,
1191
1226
  ssr,
@@ -6,11 +6,52 @@ var web = require('seroval-plugins/web');
6
6
 
7
7
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
8
8
  const BooleanAttributes = /*#__PURE__*/new Set(booleans);
9
+ const Properties = /*#__PURE__*/new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
9
10
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
10
11
  const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
11
12
  className: "class",
12
13
  htmlFor: "for"
13
14
  });
15
+ const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
16
+ class: "className",
17
+ formnovalidate: {
18
+ $: "formNoValidate",
19
+ BUTTON: 1,
20
+ INPUT: 1
21
+ },
22
+ ismap: {
23
+ $: "isMap",
24
+ IMG: 1
25
+ },
26
+ nomodule: {
27
+ $: "noModule",
28
+ SCRIPT: 1
29
+ },
30
+ playsinline: {
31
+ $: "playsInline",
32
+ VIDEO: 1
33
+ },
34
+ readonly: {
35
+ $: "readOnly",
36
+ INPUT: 1,
37
+ TEXTAREA: 1
38
+ }
39
+ });
40
+ function getPropAlias(prop, tagName) {
41
+ const a = PropAliases[prop];
42
+ return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
43
+ }
44
+ 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"]);
45
+ const SVGElements = /*#__PURE__*/new Set([
46
+ "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",
47
+ "set", "stop",
48
+ "svg", "switch", "symbol", "text", "textPath",
49
+ "tref", "tspan", "use", "view", "vkern"]);
50
+ const SVGNamespace = {
51
+ xlink: "http://www.w3.org/1999/xlink",
52
+ xml: "http://www.w3.org/XML/1998/namespace"
53
+ };
54
+ 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"]);
14
55
 
15
56
  const ES2017FLAG = seroval.Feature.AggregateError
16
57
  | seroval.Feature.BigIntTypedArray;
@@ -603,22 +644,25 @@ function ssrSpread(props, isSVG, skipChildren) {
603
644
  } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
604
645
  continue;
605
646
  } else {
606
- if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
607
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
647
+ if (prop.slice(0, 5) === "bool:") {
648
+ if (!value) continue;
649
+ prop = prop.slice(5);
650
+ result += `${escape(prop)}`;
651
+ } else {
652
+ if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
653
+ result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
654
+ }
608
655
  }
609
656
  if (i !== keys.length - 1) result += " ";
610
657
  }
611
658
  return result;
612
659
  }
660
+ function notSup() {
661
+ throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
662
+ }
613
663
 
614
664
  const isServer = true;
615
665
  const isDev = false;
616
- function render() {}
617
- function hydrate() {}
618
- function insert() {}
619
- function spread() {}
620
- function addEventListener() {}
621
- function delegateEvents() {}
622
666
  function Dynamic(props) {
623
667
  const [p, others] = solidJs.splitProps(props, ["component"]);
624
668
  const comp = p.component,
@@ -669,36 +713,71 @@ Object.defineProperty(exports, 'createComponent', {
669
713
  enumerable: true,
670
714
  get: function () { return solidJs.createComponent; }
671
715
  });
716
+ Object.defineProperty(exports, 'effect', {
717
+ enumerable: true,
718
+ get: function () { return solidJs.createRenderEffect; }
719
+ });
720
+ Object.defineProperty(exports, 'getOwner', {
721
+ enumerable: true,
722
+ get: function () { return solidJs.getOwner; }
723
+ });
724
+ Object.defineProperty(exports, 'memo', {
725
+ enumerable: true,
726
+ get: function () { return solidJs.createMemo; }
727
+ });
672
728
  Object.defineProperty(exports, 'mergeProps', {
673
729
  enumerable: true,
674
730
  get: function () { return solidJs.mergeProps; }
675
731
  });
732
+ Object.defineProperty(exports, 'untrack', {
733
+ enumerable: true,
734
+ get: function () { return solidJs.untrack; }
735
+ });
736
+ exports.Aliases = Aliases;
676
737
  exports.Assets = Assets;
738
+ exports.ChildProperties = ChildProperties;
739
+ exports.DOMElements = DOMElements;
740
+ exports.DelegatedEvents = DelegatedEvents;
677
741
  exports.Dynamic = Dynamic;
678
742
  exports.Hydration = Hydration;
679
743
  exports.HydrationScript = HydrationScript;
680
744
  exports.NoHydration = NoHydration;
681
745
  exports.Portal = Portal;
746
+ exports.Properties = Properties;
682
747
  exports.RequestContext = RequestContext;
683
- exports.addEventListener = addEventListener;
684
- exports.delegateEvents = delegateEvents;
748
+ exports.SVGElements = SVGElements;
749
+ exports.SVGNamespace = SVGNamespace;
750
+ exports.addEventListener = notSup;
751
+ exports.assign = notSup;
752
+ exports.classList = notSup;
753
+ exports.className = notSup;
754
+ exports.delegateEvents = notSup;
755
+ exports.dynamicProperty = notSup;
685
756
  exports.escape = escape;
686
757
  exports.generateHydrationScript = generateHydrationScript;
687
758
  exports.getAssets = getAssets;
688
759
  exports.getHydrationKey = getHydrationKey;
760
+ exports.getNextElement = notSup;
761
+ exports.getNextMarker = notSup;
762
+ exports.getNextMatch = notSup;
763
+ exports.getPropAlias = getPropAlias;
689
764
  exports.getRequestEvent = getRequestEvent;
690
- exports.hydrate = hydrate;
691
- exports.insert = insert;
765
+ exports.hydrate = notSup;
766
+ exports.insert = notSup;
692
767
  exports.isDev = isDev;
693
768
  exports.isServer = isServer;
694
769
  exports.pipeToNodeWritable = pipeToNodeWritable;
695
770
  exports.pipeToWritable = pipeToWritable;
696
- exports.render = render;
771
+ exports.render = notSup;
697
772
  exports.renderToStream = renderToStream;
698
773
  exports.renderToString = renderToString;
699
774
  exports.renderToStringAsync = renderToStringAsync;
700
775
  exports.resolveSSRNode = resolveSSRNode;
701
- exports.spread = spread;
776
+ exports.runHydrationEvents = notSup;
777
+ exports.setAttribute = notSup;
778
+ exports.setAttributeNS = notSup;
779
+ exports.setProperty = notSup;
780
+ exports.spread = notSup;
702
781
  exports.ssr = ssr;
703
782
  exports.ssrAttribute = ssrAttribute;
704
783
  exports.ssrClassList = ssrClassList;
@@ -706,4 +785,6 @@ exports.ssrElement = ssrElement;
706
785
  exports.ssrHydrationKey = ssrHydrationKey;
707
786
  exports.ssrSpread = ssrSpread;
708
787
  exports.ssrStyle = ssrStyle;
788
+ exports.style = notSup;
789
+ exports.template = notSup;
709
790
  exports.useAssets = useAssets;