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

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
@@ -2,38 +2,9 @@
2
2
 
3
3
  var solidJs = require('solid-js');
4
4
 
5
- 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"];
6
- const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
5
+ const Properties = /*#__PURE__*/new Set([
6
+ "value", "checked", "selected", "muted"]);
7
7
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
8
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
9
- class: "className",
10
- formnovalidate: {
11
- $: "formNoValidate",
12
- BUTTON: 1,
13
- INPUT: 1
14
- },
15
- ismap: {
16
- $: "isMap",
17
- IMG: 1
18
- },
19
- nomodule: {
20
- $: "noModule",
21
- SCRIPT: 1
22
- },
23
- playsinline: {
24
- $: "playsInline",
25
- VIDEO: 1
26
- },
27
- readonly: {
28
- $: "readOnly",
29
- INPUT: 1,
30
- TEXTAREA: 1
31
- }
32
- });
33
- function getPropAlias(prop, tagName) {
34
- const a = PropAliases[prop];
35
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
36
- }
37
8
  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"]);
38
9
  const SVGElements = /*#__PURE__*/new Set([
39
10
  "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",
@@ -44,7 +15,11 @@ const SVGNamespace = {
44
15
  xlink: "http://www.w3.org/1999/xlink",
45
16
  xml: "http://www.w3.org/XML/1998/namespace"
46
17
  };
47
- 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
+ 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",
19
+ "webview",
20
+ "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
21
+
22
+ const memo = fn => solidJs.createMemo(() => fn());
48
23
 
49
24
  function reconcileArrays(parentNode, a, b) {
50
25
  let bLength = b.length,
@@ -111,8 +86,10 @@ function render(code, element, init, options = {}) {
111
86
  let disposer;
112
87
  solidJs.createRoot(dispose => {
113
88
  disposer = dispose;
114
- element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
115
- }, options.owner);
89
+ element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
90
+ }, {
91
+ id: options.renderId
92
+ });
116
93
  return () => {
117
94
  disposer();
118
95
  element.textContent = "";
@@ -145,20 +122,20 @@ function clearDelegatedEvents(document = window.document) {
145
122
  }
146
123
  }
147
124
  function setProperty(node, name, value) {
125
+ if (isHydrating(node)) return;
148
126
  node[name] = value;
149
127
  }
150
128
  function setAttribute(node, name, value) {
151
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
129
+ if (isHydrating(node)) return;
130
+ if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
152
131
  }
153
132
  function setAttributeNS(node, namespace, name, value) {
154
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
155
- }
156
- function setBoolAttribute(node, name, value) {
157
133
  if (isHydrating(node)) return;
158
- value ? node.setAttribute(name, "") : node.removeAttribute(name);
134
+ if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
159
135
  }
160
136
  function className(node, value, isSVG, prev) {
161
- if (value == null) {
137
+ if (isHydrating(node)) return;
138
+ if (value == null || value === false) {
162
139
  prev && node.removeAttribute("class");
163
140
  return;
164
141
  }
@@ -215,6 +192,9 @@ function style(node, value, prev) {
215
192
  }
216
193
  for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
217
194
  }
195
+ function setStyleProperty(node, name, value) {
196
+ value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
197
+ }
218
198
  function spread(node, props = {}, isSVG, skipChildren) {
219
199
  const prevProps = {};
220
200
  if (!skipChildren) {
@@ -275,21 +255,19 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
275
255
  }
276
256
  function hydrate$1(code, element, options = {}) {
277
257
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
258
+ options.renderId ||= "";
278
259
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
279
260
  solidJs.sharedConfig.events = globalThis._$HY.events;
280
261
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
281
262
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
282
263
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
283
264
  solidJs.sharedConfig.registry = new Map();
284
- solidJs.sharedConfig.context = {
285
- id: options.renderId || "",
286
- count: 0
287
- };
265
+ solidJs.sharedConfig.hydrating = true;
288
266
  try {
289
267
  gatherHydratable(element, options.renderId);
290
268
  return render(code, element, [...element.childNodes], options);
291
269
  } finally {
292
- solidJs.sharedConfig.context = null;
270
+ solidJs.sharedConfig.hydrating = false;
293
271
  }
294
272
  }
295
273
  function getNextElement(template) {
@@ -354,7 +332,7 @@ function runHydrationEvents() {
354
332
  }
355
333
  }
356
334
  function isHydrating(node) {
357
- return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
335
+ return solidJs.sharedConfig.hydrating && !solidJs.sharedConfig.done && (!node || node.isConnected);
358
336
  }
359
337
  function toggleClassKey(node, key, value) {
360
338
  const classNames = key.trim().split(/\s+/);
@@ -375,7 +353,7 @@ function flattenClassList(list, result) {
375
353
  }
376
354
  }
377
355
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
378
- let propAlias, forceProp;
356
+ let forceProp;
379
357
  if (prop === "style") return style(node, value, prev), value;
380
358
  if (prop === "class") return className(node, value, isSVG, prev), value;
381
359
  if (value === prev) return prev;
@@ -396,13 +374,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
396
374
  addEventListener(node, name, value, delegate);
397
375
  delegate && delegateEvents([name]);
398
376
  }
399
- } else if (prop.slice(0, 5) === "attr:") {
400
- setAttribute(node, prop.slice(5), value);
401
- } else if (prop.slice(0, 5) === "bool:") {
402
- setBoolAttribute(node, prop.slice(5), value);
403
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && (propAlias = getPropAlias(prop, node.tagName)) || Properties.has(prop)) {
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;
377
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
378
+ if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
379
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
406
380
  } else {
407
381
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
408
382
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -461,6 +435,7 @@ function eventHandler(e) {
461
435
  retarget(oriTarget);
462
436
  }
463
437
  function insertExpression(parent, value, current, marker) {
438
+ if (isHydrating(parent)) return;
464
439
  if (value === current) return;
465
440
  const t = typeof value,
466
441
  multi = marker !== undefined;
@@ -525,10 +500,10 @@ function cleanChildren(parent, current, marker, replacement) {
525
500
  } else if (replacement) parent.insertBefore(replacement, marker);
526
501
  }
527
502
  function gatherHydratable(element, root) {
528
- const templates = element.querySelectorAll(`*[data-hk]`);
503
+ const templates = element.querySelectorAll(`*[_hk]`);
529
504
  for (let i = 0; i < templates.length; i++) {
530
505
  const node = templates[i];
531
- const key = node.getAttribute("data-hk");
506
+ const key = node.getAttribute("_hk");
532
507
  if ((!root || key.startsWith(root)) && !solidJs.sharedConfig.registry.has(key)) solidJs.sharedConfig.registry.set(key, node);
533
508
  }
534
509
  }
@@ -536,7 +511,7 @@ function getHydrationKey() {
536
511
  return solidJs.sharedConfig.getNextContextId();
537
512
  }
538
513
  function NoHydration(props) {
539
- return solidJs.sharedConfig.context ? undefined : props.children;
514
+ return solidJs.sharedConfig.hydrating ? undefined : props.children;
540
515
  }
541
516
  function Hydration(props) {
542
517
  return props.children;
@@ -569,8 +544,10 @@ function escape(html) {}
569
544
  const isServer = false;
570
545
  const isDev = true;
571
546
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
572
- function createElement(tagName, isSVG = false) {
573
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
547
+ function createElement(tagName, isSVG = false, is = undefined) {
548
+ return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
549
+ is
550
+ });
574
551
  }
575
552
  const hydrate = (...args) => {
576
553
  solidJs.enableHydration();
@@ -625,7 +602,7 @@ function createDynamic(component, props) {
625
602
  return solidJs.untrack(() => component(props));
626
603
  case "string":
627
604
  const isSvg = SVGElements.has(component);
628
- const el = solidJs.sharedConfig.context ? getNextElement() : createElement(component, isSvg);
605
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
629
606
  spread(el, props, isSvg);
630
607
  return el;
631
608
  }
@@ -672,10 +649,6 @@ Object.defineProperty(exports, "getOwner", {
672
649
  enumerable: true,
673
650
  get: function () { return solidJs.getOwner; }
674
651
  });
675
- Object.defineProperty(exports, "memo", {
676
- enumerable: true,
677
- get: function () { return solidJs.createMemo; }
678
- });
679
652
  Object.defineProperty(exports, "mergeProps", {
680
653
  enumerable: true,
681
654
  get: function () { return solidJs.merge; }
@@ -711,12 +684,12 @@ exports.getHydrationKey = getHydrationKey;
711
684
  exports.getNextElement = getNextElement;
712
685
  exports.getNextMarker = getNextMarker;
713
686
  exports.getNextMatch = getNextMatch;
714
- exports.getPropAlias = getPropAlias;
715
687
  exports.getRequestEvent = voidFn;
716
688
  exports.hydrate = hydrate;
717
689
  exports.insert = insert;
718
690
  exports.isDev = isDev;
719
691
  exports.isServer = isServer;
692
+ exports.memo = memo;
720
693
  exports.render = render;
721
694
  exports.renderToStream = renderToStream;
722
695
  exports.renderToString = renderToString;
@@ -725,8 +698,8 @@ exports.resolveSSRNode = resolveSSRNode;
725
698
  exports.runHydrationEvents = runHydrationEvents;
726
699
  exports.setAttribute = setAttribute;
727
700
  exports.setAttributeNS = setAttributeNS;
728
- exports.setBoolAttribute = setBoolAttribute;
729
701
  exports.setProperty = setProperty;
702
+ exports.setStyleProperty = setStyleProperty;
730
703
  exports.spread = spread;
731
704
  exports.ssr = ssr;
732
705
  exports.ssrAttribute = ssrAttribute;