solid-js 1.4.3 → 1.4.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/web/dist/web.js CHANGED
@@ -2,8 +2,8 @@ import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydrati
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps } from 'solid-js';
3
3
 
4
4
  const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
5
- const Properties = new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
6
- const ChildProperties = new Set(["innerHTML", "textContent", "innerText", "children"]);
5
+ const Properties = /*#__PURE__*/new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
6
+ const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
7
7
  const Aliases = {
8
8
  className: "class",
9
9
  htmlFor: "for"
@@ -16,8 +16,8 @@ const PropAliases = {
16
16
  playsinline: "playsInline",
17
17
  readonly: "readOnly"
18
18
  };
19
- const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
20
- const SVGElements = new Set([
19
+ 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"]);
20
+ const SVGElements = /*#__PURE__*/new Set([
21
21
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "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",
22
22
  "set", "stop",
23
23
  "svg", "switch", "symbol", "text", "textPath",
@@ -26,7 +26,7 @@ const SVGNamespace = {
26
26
  xlink: "http://www.w3.org/1999/xlink",
27
27
  xml: "http://www.w3.org/XML/1998/namespace"
28
28
  };
29
- const DOMElements = 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"]);
29
+ 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"]);
30
30
 
31
31
  function memo(fn, equals) {
32
32
  return createMemo(fn, undefined, !equals ? {
@@ -142,7 +142,8 @@ function addEventListener(node, name, handler, delegate) {
142
142
  node[`$$${name}Data`] = handler[1];
143
143
  } else node[`$$${name}`] = handler;
144
144
  } else if (Array.isArray(handler)) {
145
- node.addEventListener(name, e => handler[0](handler[1], e));
145
+ const handlerFn = handler[0];
146
+ node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
146
147
  } else node.addEventListener(name, handler);
147
148
  }
148
149
  function classList(node, value, prev = {}) {
@@ -306,14 +307,24 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
306
307
  value(node);
307
308
  }
308
309
  } else if (prop.slice(0, 3) === "on:") {
309
- node.addEventListener(prop.slice(3), value);
310
+ const e = prop.slice(3);
311
+ prev && node.removeEventListener(e, prev);
312
+ value && node.addEventListener(e, value);
310
313
  } else if (prop.slice(0, 10) === "oncapture:") {
311
- node.addEventListener(prop.slice(10), value, true);
314
+ const e = prop.slice(10);
315
+ prev && node.removeEventListener(e, prev, true);
316
+ value && node.addEventListener(e, value, true);
312
317
  } else if (prop.slice(0, 2) === "on") {
313
318
  const name = prop.slice(2).toLowerCase();
314
319
  const delegate = DelegatedEvents.has(name);
315
- addEventListener(node, name, value, delegate);
316
- delegate && delegateEvents([name]);
320
+ if (!delegate && prev) {
321
+ const h = Array.isArray(prev) ? prev[0] : prev;
322
+ node.removeEventListener(name, h);
323
+ }
324
+ if (delegate || value) {
325
+ addEventListener(node, name, value, delegate);
326
+ delegate && delegateEvents([name]);
327
+ }
317
328
  } else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
318
329
  if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
319
330
  } else {
@@ -345,7 +356,7 @@ function eventHandler(e) {
345
356
  const handler = node[key];
346
357
  if (handler && !node.disabled) {
347
358
  const data = node[`${key}Data`];
348
- data !== undefined ? handler(data, e) : handler(e);
359
+ data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
349
360
  if (e.cancelBubble) return;
350
361
  }
351
362
  node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
@@ -393,7 +404,8 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
393
404
  return () => current;
394
405
  } else if (Array.isArray(value)) {
395
406
  const array = [];
396
- if (normalizeIncomingArray(array, value, unwrapArray)) {
407
+ const currentArray = current && Array.isArray(current);
408
+ if (normalizeIncomingArray(array, value, current, unwrapArray)) {
397
409
  createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
398
410
  return () => current;
399
411
  }
@@ -405,7 +417,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
405
417
  if (array.length === 0) {
406
418
  current = cleanChildren(parent, current, marker);
407
419
  if (multi) return current;
408
- } else if (Array.isArray(current)) {
420
+ } else if (currentArray) {
409
421
  if (current.length === 0) {
410
422
  appendNodes(parent, array, marker);
411
423
  } else reconcileArrays(parent, current, array);
@@ -426,26 +438,29 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
426
438
  } else ;
427
439
  return current;
428
440
  }
429
- function normalizeIncomingArray(normalized, array, unwrap) {
441
+ function normalizeIncomingArray(normalized, array, current, unwrap) {
430
442
  let dynamic = false;
431
443
  for (let i = 0, len = array.length; i < len; i++) {
432
444
  let item = array[i],
433
- t;
445
+ prev = current && current[i];
434
446
  if (item instanceof Node) {
435
447
  normalized.push(item);
436
448
  } else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
437
- dynamic = normalizeIncomingArray(normalized, item) || dynamic;
438
- } else if ((t = typeof item) === "string") {
439
- normalized.push(document.createTextNode(item));
440
- } else if (t === "function") {
449
+ dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
450
+ } else if ((typeof item) === "function") {
441
451
  if (unwrap) {
442
452
  while (typeof item === "function") item = item();
443
- dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
453
+ dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], prev) || dynamic;
444
454
  } else {
445
455
  normalized.push(item);
446
456
  dynamic = true;
447
457
  }
448
- } else normalized.push(document.createTextNode(item.toString()));
458
+ } else {
459
+ const value = String(item);
460
+ if (prev && prev.nodeType === 3 && prev.data === value) {
461
+ normalized.push(prev);
462
+ } else normalized.push(document.createTextNode(value));
463
+ }
449
464
  }
450
465
  return dynamic;
451
466
  }
@@ -504,7 +519,7 @@ function resolveSSRNode(node) {}
504
519
  function ssrClassList(value) {}
505
520
  function ssrStyle(value) {}
506
521
  function ssrSpread(accessor) {}
507
- function ssrBoolean(key, value) {}
522
+ function ssrAttribute(key, value) {}
508
523
  function ssrHydrationKey() {}
509
524
  function escape(html) {}
510
525
  function generateHydrationScript() {}
@@ -557,8 +572,9 @@ function Portal(props) {
557
572
  }
558
573
  function Dynamic(props) {
559
574
  const [p, others] = splitProps(props, ["component"]);
575
+ const cached = createMemo(() => p.component);
560
576
  return createMemo(() => {
561
- const component = p.component;
577
+ const component = cached();
562
578
  switch (typeof component) {
563
579
  case "function":
564
580
  return untrack(() => component(others));
@@ -571,4 +587,4 @@ function Dynamic(props) {
571
587
  });
572
588
  }
573
589
 
574
- export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
590
+ export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
@@ -12,10 +12,13 @@ export declare const hydrate: typeof hydrateCore;
12
12
  *
13
13
  * @description https://www.solidjs.com/docs/latest/api#%3Cportal%3E
14
14
  */
15
- export declare function Portal(props: {
15
+ export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
16
16
  mount?: Node;
17
- useShadow?: boolean;
18
- isSVG?: boolean;
17
+ useShadow?: T;
18
+ isSVG?: S;
19
+ ref?: (S extends true ? SVGGElement : HTMLDivElement) | ((el: (T extends true ? {
20
+ readonly shadowRoot: ShadowRoot;
21
+ } : {}) & (S extends true ? SVGGElement : HTMLDivElement)) => void);
19
22
  children: JSX.Element;
20
23
  }): Text;
21
24
  declare type DynamicProps<T> = T & {
@@ -33,7 +33,7 @@ export declare function ssrStyle(value: {
33
33
  [k: string]: string;
34
34
  }): string;
35
35
  export declare function ssrSpread(accessor: any): () => string;
36
- export declare function ssrBoolean(key: string, value: boolean): string;
36
+ export declare function ssrAttribute(key: string, value: boolean): string;
37
37
  export declare function ssrHydrationKey(): string;
38
38
  export declare function escape(html: string): string;
39
39
  export declare function generateHydrationScript(): string;