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

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
@@ -46,6 +46,8 @@ const SVGNamespace = {
46
46
  };
47
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"]);
48
48
 
49
+ const memo = fn => solidJs.createMemo(() => fn());
50
+
49
51
  function reconcileArrays(parentNode, a, b) {
50
52
  let bLength = b.length,
51
53
  aEnd = a.length,
@@ -111,8 +113,10 @@ function render(code, element, init, options = {}) {
111
113
  let disposer;
112
114
  solidJs.createRoot(dispose => {
113
115
  disposer = dispose;
114
- element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
115
- }, options.owner);
116
+ element === document ? solidJs.flatten(code) : insert(element, code(), element.firstChild ? null : undefined, init);
117
+ }, {
118
+ id: options.renderId
119
+ });
116
120
  return () => {
117
121
  disposer();
118
122
  element.textContent = "";
@@ -145,12 +149,15 @@ function clearDelegatedEvents(document = window.document) {
145
149
  }
146
150
  }
147
151
  function setProperty(node, name, value) {
152
+ if (isHydrating(node)) return;
148
153
  node[name] = value;
149
154
  }
150
155
  function setAttribute(node, name, value) {
156
+ if (isHydrating(node)) return;
151
157
  if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
152
158
  }
153
159
  function setAttributeNS(node, namespace, name, value) {
160
+ if (isHydrating(node)) return;
154
161
  if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
155
162
  }
156
163
  function setBoolAttribute(node, name, value) {
@@ -158,6 +165,7 @@ function setBoolAttribute(node, name, value) {
158
165
  value ? node.setAttribute(name, "") : node.removeAttribute(name);
159
166
  }
160
167
  function className(node, value, isSVG, prev) {
168
+ if (isHydrating(node)) return;
161
169
  if (value == null) {
162
170
  prev && node.removeAttribute("class");
163
171
  return;
@@ -275,21 +283,19 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
275
283
  }
276
284
  function hydrate$1(code, element, options = {}) {
277
285
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
286
+ options.renderId ||= "";
278
287
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
279
288
  solidJs.sharedConfig.events = globalThis._$HY.events;
280
289
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
281
290
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
282
291
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
283
292
  solidJs.sharedConfig.registry = new Map();
284
- solidJs.sharedConfig.context = {
285
- id: options.renderId || "",
286
- count: 0
287
- };
293
+ solidJs.sharedConfig.hydrating = true;
288
294
  try {
289
295
  gatherHydratable(element, options.renderId);
290
296
  return render(code, element, [...element.childNodes], options);
291
297
  } finally {
292
- solidJs.sharedConfig.context = null;
298
+ solidJs.sharedConfig.hydrating = false;
293
299
  }
294
300
  }
295
301
  function getNextElement(template) {
@@ -354,7 +360,7 @@ function runHydrationEvents() {
354
360
  }
355
361
  }
356
362
  function isHydrating(node) {
357
- return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
363
+ return solidJs.sharedConfig.hydrating && !solidJs.sharedConfig.done && (!node || node.isConnected);
358
364
  }
359
365
  function toggleClassKey(node, key, value) {
360
366
  const classNames = key.trim().split(/\s+/);
@@ -401,7 +407,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
401
407
  } else if (prop.slice(0, 5) === "bool:") {
402
408
  setBoolAttribute(node, prop.slice(5), value);
403
409
  } 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);
410
+ if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
405
411
  if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[propAlias || prop] = value;
406
412
  } else {
407
413
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
@@ -461,6 +467,7 @@ function eventHandler(e) {
461
467
  retarget(oriTarget);
462
468
  }
463
469
  function insertExpression(parent, value, current, marker) {
470
+ if (isHydrating(parent)) return;
464
471
  if (value === current) return;
465
472
  const t = typeof value,
466
473
  multi = marker !== undefined;
@@ -525,10 +532,10 @@ function cleanChildren(parent, current, marker, replacement) {
525
532
  } else if (replacement) parent.insertBefore(replacement, marker);
526
533
  }
527
534
  function gatherHydratable(element, root) {
528
- const templates = element.querySelectorAll(`*[data-hk]`);
535
+ const templates = element.querySelectorAll(`*[_hk]`);
529
536
  for (let i = 0; i < templates.length; i++) {
530
537
  const node = templates[i];
531
- const key = node.getAttribute("data-hk");
538
+ const key = node.getAttribute("_hk");
532
539
  if ((!root || key.startsWith(root)) && !solidJs.sharedConfig.registry.has(key)) solidJs.sharedConfig.registry.set(key, node);
533
540
  }
534
541
  }
@@ -536,7 +543,7 @@ function getHydrationKey() {
536
543
  return solidJs.sharedConfig.getNextContextId();
537
544
  }
538
545
  function NoHydration(props) {
539
- return solidJs.sharedConfig.context ? undefined : props.children;
546
+ return solidJs.sharedConfig.hydrating ? undefined : props.children;
540
547
  }
541
548
  function Hydration(props) {
542
549
  return props.children;
@@ -672,10 +679,6 @@ Object.defineProperty(exports, "getOwner", {
672
679
  enumerable: true,
673
680
  get: function () { return solidJs.getOwner; }
674
681
  });
675
- Object.defineProperty(exports, "memo", {
676
- enumerable: true,
677
- get: function () { return solidJs.createMemo; }
678
- });
679
682
  Object.defineProperty(exports, "mergeProps", {
680
683
  enumerable: true,
681
684
  get: function () { return solidJs.merge; }
@@ -717,6 +720,7 @@ exports.hydrate = hydrate;
717
720
  exports.insert = insert;
718
721
  exports.isDev = isDev;
719
722
  exports.isServer = isServer;
723
+ exports.memo = memo;
720
724
  exports.render = render;
721
725
  exports.renderToStream = renderToStream;
722
726
  exports.renderToString = renderToString;