@solidjs/web 2.0.0-experimental.0 → 2.0.0-experimental.10

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
@@ -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,
@@ -108,8 +83,10 @@ function render(code, element, init, options = {}) {
108
83
  let disposer;
109
84
  solidJs.createRoot(dispose => {
110
85
  disposer = dispose;
111
- element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
112
- }, options.owner);
86
+ element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
87
+ }, {
88
+ id: options.renderId
89
+ });
113
90
  return () => {
114
91
  disposer();
115
92
  element.textContent = "";
@@ -141,20 +118,20 @@ function clearDelegatedEvents(document = window.document) {
141
118
  }
142
119
  }
143
120
  function setProperty(node, name, value) {
121
+ if (isHydrating(node)) return;
144
122
  node[name] = value;
145
123
  }
146
124
  function setAttribute(node, name, value) {
147
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
125
+ if (isHydrating(node)) return;
126
+ if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
148
127
  }
149
128
  function setAttributeNS(node, namespace, name, value) {
150
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
151
- }
152
- function setBoolAttribute(node, name, value) {
153
129
  if (isHydrating(node)) return;
154
- value ? node.setAttribute(name, "") : node.removeAttribute(name);
130
+ if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
155
131
  }
156
132
  function className(node, value, isSVG, prev) {
157
- if (value == null) {
133
+ if (isHydrating(node)) return;
134
+ if (value == null || value === false) {
158
135
  prev && node.removeAttribute("class");
159
136
  return;
160
137
  }
@@ -211,6 +188,9 @@ function style(node, value, prev) {
211
188
  }
212
189
  for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
213
190
  }
191
+ function setStyleProperty(node, name, value) {
192
+ value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
193
+ }
214
194
  function spread(node, props = {}, isSVG, skipChildren) {
215
195
  const prevProps = {};
216
196
  if (!skipChildren) {
@@ -271,21 +251,19 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
271
251
  }
272
252
  function hydrate$1(code, element, options = {}) {
273
253
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
254
+ options.renderId ||= "";
274
255
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
275
256
  solidJs.sharedConfig.events = globalThis._$HY.events;
276
257
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
277
258
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
278
259
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
279
260
  solidJs.sharedConfig.registry = new Map();
280
- solidJs.sharedConfig.context = {
281
- id: options.renderId || "",
282
- count: 0
283
- };
261
+ solidJs.sharedConfig.hydrating = true;
284
262
  try {
285
263
  gatherHydratable(element, options.renderId);
286
264
  return render(code, element, [...element.childNodes], options);
287
265
  } finally {
288
- solidJs.sharedConfig.context = null;
266
+ solidJs.sharedConfig.hydrating = false;
289
267
  }
290
268
  }
291
269
  function getNextElement(template) {
@@ -346,7 +324,7 @@ function runHydrationEvents() {
346
324
  }
347
325
  }
348
326
  function isHydrating(node) {
349
- return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
327
+ return solidJs.sharedConfig.hydrating && !solidJs.sharedConfig.done && (!node || node.isConnected);
350
328
  }
351
329
  function toggleClassKey(node, key, value) {
352
330
  const classNames = key.trim().split(/\s+/);
@@ -355,16 +333,19 @@ function toggleClassKey(node, key, value) {
355
333
  function classListToObject(classList) {
356
334
  if (Array.isArray(classList)) {
357
335
  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
- }
336
+ flattenClassList(classList, result);
362
337
  return result;
363
338
  }
364
339
  return classList;
365
340
  }
341
+ function flattenClassList(list, result) {
342
+ for (let i = 0, len = list.length; i < len; i++) {
343
+ const item = list[i];
344
+ 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;
345
+ }
346
+ }
366
347
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
367
- let propAlias, forceProp;
348
+ let forceProp;
368
349
  if (prop === "style") return style(node, value, prev), value;
369
350
  if (prop === "class") return className(node, value, isSVG, prev), value;
370
351
  if (value === prev) return prev;
@@ -385,12 +366,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
385
366
  addEventListener(node, name, value, delegate);
386
367
  delegate && delegateEvents([name]);
387
368
  }
388
- } else if (prop.slice(0, 5) === "attr:") {
389
- setAttribute(node, prop.slice(5), value);
390
- } else if (prop.slice(0, 5) === "bool:") {
391
- setBoolAttribute(node, prop.slice(5), value);
392
- } 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;
369
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
370
+ if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
371
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
394
372
  } else {
395
373
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
396
374
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -449,6 +427,7 @@ function eventHandler(e) {
449
427
  retarget(oriTarget);
450
428
  }
451
429
  function insertExpression(parent, value, current, marker) {
430
+ if (isHydrating(parent)) return;
452
431
  if (value === current) return;
453
432
  const t = typeof value,
454
433
  multi = marker !== undefined;
@@ -485,7 +464,7 @@ function normalize(value, current, multi, doNotUnwrap) {
485
464
  doNotUnwrap
486
465
  });
487
466
  if (doNotUnwrap && typeof value === "function") return value;
488
- if (multi && value != null && !Array.isArray(value)) value = [value];
467
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
489
468
  if (Array.isArray(value)) {
490
469
  for (let i = 0, len = value.length; i < len; i++) {
491
470
  const item = value[i],
@@ -513,10 +492,10 @@ function cleanChildren(parent, current, marker, replacement) {
513
492
  } else if (replacement) parent.insertBefore(replacement, marker);
514
493
  }
515
494
  function gatherHydratable(element, root) {
516
- const templates = element.querySelectorAll(`*[data-hk]`);
495
+ const templates = element.querySelectorAll(`*[_hk]`);
517
496
  for (let i = 0; i < templates.length; i++) {
518
497
  const node = templates[i];
519
- const key = node.getAttribute("data-hk");
498
+ const key = node.getAttribute("_hk");
520
499
  if ((!root || key.startsWith(root)) && !solidJs.sharedConfig.registry.has(key)) solidJs.sharedConfig.registry.set(key, node);
521
500
  }
522
501
  }
@@ -524,7 +503,7 @@ function getHydrationKey() {
524
503
  return solidJs.sharedConfig.getNextContextId();
525
504
  }
526
505
  function NoHydration(props) {
527
- return solidJs.sharedConfig.context ? undefined : props.children;
506
+ return solidJs.sharedConfig.hydrating ? undefined : props.children;
528
507
  }
529
508
  function Hydration(props) {
530
509
  return props.children;
@@ -557,8 +536,10 @@ function escape(html) {}
557
536
  const isServer = false;
558
537
  const isDev = false;
559
538
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
560
- function createElement(tagName, isSVG = false) {
561
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
539
+ function createElement(tagName, isSVG = false, is = undefined) {
540
+ return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
541
+ is
542
+ });
562
543
  }
563
544
  const hydrate = (...args) => {
564
545
  solidJs.enableHydration();
@@ -601,22 +582,25 @@ function createElementProxy(el, marker) {
601
582
  }
602
583
  });
603
584
  }
604
- function Dynamic(props) {
605
- const others = solidJs.omit(props, "component");
606
- const cached = solidJs.createMemo(() => props.component);
585
+ function createDynamic(component, props) {
586
+ const cached = solidJs.createMemo(component);
607
587
  return solidJs.createMemo(() => {
608
588
  const component = cached();
609
589
  switch (typeof component) {
610
590
  case "function":
611
- return solidJs.untrack(() => component(others));
591
+ return solidJs.untrack(() => component(props));
612
592
  case "string":
613
593
  const isSvg = SVGElements.has(component);
614
- const el = solidJs.sharedConfig.context ? getNextElement() : createElement(component, isSvg);
615
- spread(el, others, isSvg);
594
+ const el = solidJs.sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, solidJs.untrack(() => props.is));
595
+ spread(el, props, isSvg);
616
596
  return el;
617
597
  }
618
598
  });
619
599
  }
600
+ function Dynamic(props) {
601
+ const others = solidJs.omit(props, "component");
602
+ return createDynamic(() => props.component, others);
603
+ }
620
604
 
621
605
  Object.defineProperty(exports, "ErrorBoundary", {
622
606
  enumerable: true,
@@ -654,10 +638,6 @@ Object.defineProperty(exports, "getOwner", {
654
638
  enumerable: true,
655
639
  get: function () { return solidJs.getOwner; }
656
640
  });
657
- Object.defineProperty(exports, "memo", {
658
- enumerable: true,
659
- get: function () { return solidJs.createMemo; }
660
- });
661
641
  Object.defineProperty(exports, "mergeProps", {
662
642
  enumerable: true,
663
643
  get: function () { return solidJs.merge; }
@@ -683,6 +663,7 @@ exports.addEventListener = addEventListener;
683
663
  exports.assign = assign;
684
664
  exports.className = className;
685
665
  exports.clearDelegatedEvents = clearDelegatedEvents;
666
+ exports.createDynamic = createDynamic;
686
667
  exports.delegateEvents = delegateEvents;
687
668
  exports.dynamicProperty = dynamicProperty;
688
669
  exports.escape = escape;
@@ -692,12 +673,12 @@ exports.getHydrationKey = getHydrationKey;
692
673
  exports.getNextElement = getNextElement;
693
674
  exports.getNextMarker = getNextMarker;
694
675
  exports.getNextMatch = getNextMatch;
695
- exports.getPropAlias = getPropAlias;
696
676
  exports.getRequestEvent = voidFn;
697
677
  exports.hydrate = hydrate;
698
678
  exports.insert = insert;
699
679
  exports.isDev = isDev;
700
680
  exports.isServer = isServer;
681
+ exports.memo = memo;
701
682
  exports.render = render;
702
683
  exports.renderToStream = renderToStream;
703
684
  exports.renderToString = renderToString;
@@ -706,8 +687,8 @@ exports.resolveSSRNode = resolveSSRNode;
706
687
  exports.runHydrationEvents = runHydrationEvents;
707
688
  exports.setAttribute = setAttribute;
708
689
  exports.setAttributeNS = setAttributeNS;
709
- exports.setBoolAttribute = setBoolAttribute;
710
690
  exports.setProperty = setProperty;
691
+ exports.setStyleProperty = setStyleProperty;
711
692
  exports.spread = spread;
712
693
  exports.ssr = ssr;
713
694
  exports.ssrAttribute = ssrAttribute;