@solidjs/web 2.0.0-experimental.1 → 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;
package/dist/web.js CHANGED
@@ -1,38 +1,9 @@
1
- import { createRoot, untrack, createRenderEffect, sharedConfig, flatten, enableHydration, createMemo, omit } from 'solid-js';
2
- export { ErrorBoundary, For, Match, Show, Suspense, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createMemo, createRoot, flatten, untrack, createRenderEffect, sharedConfig, enableHydration, omit } from 'solid-js';
2
+ export { ErrorBoundary, For, Match, Show, Suspense, Switch, createComponent, createRenderEffect as effect, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
 
4
- 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"];
5
- const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
4
+ const Properties = /*#__PURE__*/new Set([
5
+ "value", "checked", "selected", "muted"]);
6
6
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
7
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
8
- class: "className",
9
- formnovalidate: {
10
- $: "formNoValidate",
11
- BUTTON: 1,
12
- INPUT: 1
13
- },
14
- ismap: {
15
- $: "isMap",
16
- IMG: 1
17
- },
18
- nomodule: {
19
- $: "noModule",
20
- SCRIPT: 1
21
- },
22
- playsinline: {
23
- $: "playsInline",
24
- VIDEO: 1
25
- },
26
- readonly: {
27
- $: "readOnly",
28
- INPUT: 1,
29
- TEXTAREA: 1
30
- }
31
- });
32
- function getPropAlias(prop, tagName) {
33
- const a = PropAliases[prop];
34
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
35
- }
36
7
  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"]);
37
8
  const SVGElements = /*#__PURE__*/new Set([
38
9
  "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",
@@ -43,7 +14,11 @@ const SVGNamespace = {
43
14
  xlink: "http://www.w3.org/1999/xlink",
44
15
  xml: "http://www.w3.org/XML/1998/namespace"
45
16
  };
46
- 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"]);
17
+ 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
+ "webview",
19
+ "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
20
+
21
+ const memo = fn => createMemo(() => fn());
47
22
 
48
23
  function reconcileArrays(parentNode, a, b) {
49
24
  let bLength = b.length,
@@ -107,8 +82,10 @@ function render(code, element, init, options = {}) {
107
82
  let disposer;
108
83
  createRoot(dispose => {
109
84
  disposer = dispose;
110
- element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
111
- }, options.owner);
85
+ element === document ? flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
86
+ }, {
87
+ id: options.renderId
88
+ });
112
89
  return () => {
113
90
  disposer();
114
91
  element.textContent = "";
@@ -140,20 +117,20 @@ function clearDelegatedEvents(document = window.document) {
140
117
  }
141
118
  }
142
119
  function setProperty(node, name, value) {
120
+ if (isHydrating(node)) return;
143
121
  node[name] = value;
144
122
  }
145
123
  function setAttribute(node, name, value) {
146
- if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
124
+ if (isHydrating(node)) return;
125
+ if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
147
126
  }
148
127
  function setAttributeNS(node, namespace, name, value) {
149
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
150
- }
151
- function setBoolAttribute(node, name, value) {
152
128
  if (isHydrating(node)) return;
153
- value ? node.setAttribute(name, "") : node.removeAttribute(name);
129
+ if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
154
130
  }
155
131
  function className(node, value, isSVG, prev) {
156
- if (value == null) {
132
+ if (isHydrating(node)) return;
133
+ if (value == null || value === false) {
157
134
  prev && node.removeAttribute("class");
158
135
  return;
159
136
  }
@@ -210,6 +187,9 @@ function style(node, value, prev) {
210
187
  }
211
188
  for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
212
189
  }
190
+ function setStyleProperty(node, name, value) {
191
+ value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
192
+ }
213
193
  function spread(node, props = {}, isSVG, skipChildren) {
214
194
  const prevProps = {};
215
195
  if (!skipChildren) {
@@ -270,21 +250,19 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
270
250
  }
271
251
  function hydrate$1(code, element, options = {}) {
272
252
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
253
+ options.renderId ||= "";
273
254
  sharedConfig.completed = globalThis._$HY.completed;
274
255
  sharedConfig.events = globalThis._$HY.events;
275
256
  sharedConfig.load = id => globalThis._$HY.r[id];
276
257
  sharedConfig.has = id => id in globalThis._$HY.r;
277
258
  sharedConfig.gather = root => gatherHydratable(element, root);
278
259
  sharedConfig.registry = new Map();
279
- sharedConfig.context = {
280
- id: options.renderId || "",
281
- count: 0
282
- };
260
+ sharedConfig.hydrating = true;
283
261
  try {
284
262
  gatherHydratable(element, options.renderId);
285
263
  return render(code, element, [...element.childNodes], options);
286
264
  } finally {
287
- sharedConfig.context = null;
265
+ sharedConfig.hydrating = false;
288
266
  }
289
267
  }
290
268
  function getNextElement(template) {
@@ -345,7 +323,7 @@ function runHydrationEvents() {
345
323
  }
346
324
  }
347
325
  function isHydrating(node) {
348
- return !!sharedConfig.context && !sharedConfig.done && (!node || node.isConnected);
326
+ return sharedConfig.hydrating && !sharedConfig.done && (!node || node.isConnected);
349
327
  }
350
328
  function toggleClassKey(node, key, value) {
351
329
  const classNames = key.trim().split(/\s+/);
@@ -354,16 +332,19 @@ function toggleClassKey(node, key, value) {
354
332
  function classListToObject(classList) {
355
333
  if (Array.isArray(classList)) {
356
334
  const result = {};
357
- for (let i = 0, len = classList.length; i < len; i++) {
358
- const key = classList[i];
359
- if (typeof key === "object" && key != null) Object.assign(result, key);else if (key || key === 0) result[key] = true;
360
- }
335
+ flattenClassList(classList, result);
361
336
  return result;
362
337
  }
363
338
  return classList;
364
339
  }
340
+ function flattenClassList(list, result) {
341
+ for (let i = 0, len = list.length; i < len; i++) {
342
+ const item = list[i];
343
+ 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;
344
+ }
345
+ }
365
346
  function assignProp(node, prop, value, prev, isSVG, skipRef) {
366
- let propAlias, forceProp;
347
+ let forceProp;
367
348
  if (prop === "style") return style(node, value, prev), value;
368
349
  if (prop === "class") return className(node, value, isSVG, prev), value;
369
350
  if (value === prev) return prev;
@@ -384,12 +365,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
384
365
  addEventListener(node, name, value, delegate);
385
366
  delegate && delegateEvents([name]);
386
367
  }
387
- } else if (prop.slice(0, 5) === "attr:") {
388
- setAttribute(node, prop.slice(5), value);
389
- } else if (prop.slice(0, 5) === "bool:") {
390
- setBoolAttribute(node, prop.slice(5), value);
391
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && (propAlias = getPropAlias(prop, node.tagName)) || Properties.has(prop)) {
392
- if (forceProp) prop = prop.slice(5);else node[propAlias || prop] = value;
368
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
369
+ if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
370
+ if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
393
371
  } else {
394
372
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
395
373
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
@@ -448,6 +426,7 @@ function eventHandler(e) {
448
426
  retarget(oriTarget);
449
427
  }
450
428
  function insertExpression(parent, value, current, marker) {
429
+ if (isHydrating(parent)) return;
451
430
  if (value === current) return;
452
431
  const t = typeof value,
453
432
  multi = marker !== undefined;
@@ -484,7 +463,7 @@ function normalize(value, current, multi, doNotUnwrap) {
484
463
  doNotUnwrap
485
464
  });
486
465
  if (doNotUnwrap && typeof value === "function") return value;
487
- if (multi && value != null && !Array.isArray(value)) value = [value];
466
+ if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
488
467
  if (Array.isArray(value)) {
489
468
  for (let i = 0, len = value.length; i < len; i++) {
490
469
  const item = value[i],
@@ -512,10 +491,10 @@ function cleanChildren(parent, current, marker, replacement) {
512
491
  } else if (replacement) parent.insertBefore(replacement, marker);
513
492
  }
514
493
  function gatherHydratable(element, root) {
515
- const templates = element.querySelectorAll(`*[data-hk]`);
494
+ const templates = element.querySelectorAll(`*[_hk]`);
516
495
  for (let i = 0; i < templates.length; i++) {
517
496
  const node = templates[i];
518
- const key = node.getAttribute("data-hk");
497
+ const key = node.getAttribute("_hk");
519
498
  if ((!root || key.startsWith(root)) && !sharedConfig.registry.has(key)) sharedConfig.registry.set(key, node);
520
499
  }
521
500
  }
@@ -523,7 +502,7 @@ function getHydrationKey() {
523
502
  return sharedConfig.getNextContextId();
524
503
  }
525
504
  function NoHydration(props) {
526
- return sharedConfig.context ? undefined : props.children;
505
+ return sharedConfig.hydrating ? undefined : props.children;
527
506
  }
528
507
  function Hydration(props) {
529
508
  return props.children;
@@ -556,8 +535,10 @@ function escape(html) {}
556
535
  const isServer = false;
557
536
  const isDev = false;
558
537
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
559
- function createElement(tagName, isSVG = false) {
560
- return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
538
+ function createElement(tagName, isSVG = false, is = undefined) {
539
+ return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName, {
540
+ is
541
+ });
561
542
  }
562
543
  const hydrate = (...args) => {
563
544
  enableHydration();
@@ -600,21 +581,24 @@ function createElementProxy(el, marker) {
600
581
  }
601
582
  });
602
583
  }
603
- function Dynamic(props) {
604
- const others = omit(props, "component");
605
- const cached = createMemo(() => props.component);
584
+ function createDynamic(component, props) {
585
+ const cached = createMemo(component);
606
586
  return createMemo(() => {
607
587
  const component = cached();
608
588
  switch (typeof component) {
609
589
  case "function":
610
- return untrack(() => component(others));
590
+ return untrack(() => component(props));
611
591
  case "string":
612
592
  const isSvg = SVGElements.has(component);
613
- const el = sharedConfig.context ? getNextElement() : createElement(component, isSvg);
614
- spread(el, others, isSvg);
593
+ const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
594
+ spread(el, props, isSvg);
615
595
  return el;
616
596
  }
617
597
  });
618
598
  }
599
+ function Dynamic(props) {
600
+ const others = omit(props, "component");
601
+ return createDynamic(() => props.component, others);
602
+ }
619
603
 
620
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, assign, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getPropAlias, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setBoolAttribute, setProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use, voidFn as useAssets };
604
+ export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use, voidFn as useAssets };
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.1",
4
+ "version": "2.0.0-experimental.10",
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.1"
78
+ "solid-js": "^2.0.0-experimental.10"
79
79
  },
80
80
  "devDependencies": {
81
- "solid-js": "2.0.0-experimental.1"
81
+ "solid-js": "2.0.0-experimental.10"
82
82
  },
83
83
  "scripts": {
84
84
  "build": "npm-run-all -nl build:*",
package/types/client.d.ts CHANGED
@@ -5,7 +5,6 @@ export const DelegatedEvents: Set<string>;
5
5
  export const DOMElements: Set<string>;
6
6
  export const SVGElements: Set<string>;
7
7
  export const SVGNamespace: Record<string, string>;
8
- export function getPropAlias(prop: string, tagName: string): string | undefined;
9
8
 
10
9
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
11
10
  export function render(code: () => JSX.Element, element: MountableElement): () => void;
@@ -31,7 +30,6 @@ export function spread<T>(
31
30
  export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
32
31
  export function setAttribute(node: Element, name: string, value: string): void;
33
32
  export function setAttributeNS(node: Element, namespace: string, name: string, value: string): void;
34
- export function setBoolAttribute(node: Element, name: string, value: any): void;
35
33
  type ClassList =
36
34
  | Record<string, boolean>
37
35
  | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
package/types/core.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, createMemo as memo, sharedConfig, untrack, merge as mergeProps, flatten } from "solid-js";
1
+ export { getOwner, createComponent, createRoot as root, createRenderEffect as effect, sharedConfig, untrack, merge as mergeProps, flatten, ssrHandleError, ssrRunInScope } from "solid-js";
2
+ export declare const memo: (fn: any) => import("solid-js").Accessor<any>;