solid-js 1.8.23 → 1.9.0

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.
@@ -9,7 +9,11 @@ export {
9
9
  SuspenseList,
10
10
  Switch,
11
11
  createComponent,
12
- mergeProps
12
+ createRenderEffect as effect,
13
+ getOwner,
14
+ createMemo as memo,
15
+ mergeProps,
16
+ untrack
13
17
  } from "solid-js";
14
18
  import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
15
19
  import {
@@ -53,6 +57,16 @@ const booleans = [
53
57
  "selected"
54
58
  ];
55
59
  const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
60
+ const Properties = /*#__PURE__*/ new Set([
61
+ "className",
62
+ "value",
63
+ "readOnly",
64
+ "formNoValidate",
65
+ "isMap",
66
+ "noModule",
67
+ "playsInline",
68
+ ...booleans
69
+ ]);
56
70
  const ChildProperties = /*#__PURE__*/ new Set([
57
71
  "innerHTML",
58
72
  "textContent",
@@ -63,6 +77,423 @@ const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
63
77
  className: "class",
64
78
  htmlFor: "for"
65
79
  });
80
+ const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
81
+ class: "className",
82
+ formnovalidate: {
83
+ $: "formNoValidate",
84
+ BUTTON: 1,
85
+ INPUT: 1
86
+ },
87
+ ismap: {
88
+ $: "isMap",
89
+ IMG: 1
90
+ },
91
+ nomodule: {
92
+ $: "noModule",
93
+ SCRIPT: 1
94
+ },
95
+ playsinline: {
96
+ $: "playsInline",
97
+ VIDEO: 1
98
+ },
99
+ readonly: {
100
+ $: "readOnly",
101
+ INPUT: 1,
102
+ TEXTAREA: 1
103
+ }
104
+ });
105
+ function getPropAlias(prop, tagName) {
106
+ const a = PropAliases[prop];
107
+ return typeof a === "object" ? (a[tagName] ? a["$"] : undefined) : a;
108
+ }
109
+ const DelegatedEvents = /*#__PURE__*/ new Set([
110
+ "beforeinput",
111
+ "click",
112
+ "dblclick",
113
+ "contextmenu",
114
+ "focusin",
115
+ "focusout",
116
+ "input",
117
+ "keydown",
118
+ "keyup",
119
+ "mousedown",
120
+ "mousemove",
121
+ "mouseout",
122
+ "mouseover",
123
+ "mouseup",
124
+ "pointerdown",
125
+ "pointermove",
126
+ "pointerout",
127
+ "pointerover",
128
+ "pointerup",
129
+ "touchend",
130
+ "touchmove",
131
+ "touchstart"
132
+ ]);
133
+ const SVGElements = /*#__PURE__*/ new Set([
134
+ "altGlyph",
135
+ "altGlyphDef",
136
+ "altGlyphItem",
137
+ "animate",
138
+ "animateColor",
139
+ "animateMotion",
140
+ "animateTransform",
141
+ "circle",
142
+ "clipPath",
143
+ "color-profile",
144
+ "cursor",
145
+ "defs",
146
+ "desc",
147
+ "ellipse",
148
+ "feBlend",
149
+ "feColorMatrix",
150
+ "feComponentTransfer",
151
+ "feComposite",
152
+ "feConvolveMatrix",
153
+ "feDiffuseLighting",
154
+ "feDisplacementMap",
155
+ "feDistantLight",
156
+ "feDropShadow",
157
+ "feFlood",
158
+ "feFuncA",
159
+ "feFuncB",
160
+ "feFuncG",
161
+ "feFuncR",
162
+ "feGaussianBlur",
163
+ "feImage",
164
+ "feMerge",
165
+ "feMergeNode",
166
+ "feMorphology",
167
+ "feOffset",
168
+ "fePointLight",
169
+ "feSpecularLighting",
170
+ "feSpotLight",
171
+ "feTile",
172
+ "feTurbulence",
173
+ "filter",
174
+ "font",
175
+ "font-face",
176
+ "font-face-format",
177
+ "font-face-name",
178
+ "font-face-src",
179
+ "font-face-uri",
180
+ "foreignObject",
181
+ "g",
182
+ "glyph",
183
+ "glyphRef",
184
+ "hkern",
185
+ "image",
186
+ "line",
187
+ "linearGradient",
188
+ "marker",
189
+ "mask",
190
+ "metadata",
191
+ "missing-glyph",
192
+ "mpath",
193
+ "path",
194
+ "pattern",
195
+ "polygon",
196
+ "polyline",
197
+ "radialGradient",
198
+ "rect",
199
+ "set",
200
+ "stop",
201
+ "svg",
202
+ "switch",
203
+ "symbol",
204
+ "text",
205
+ "textPath",
206
+ "tref",
207
+ "tspan",
208
+ "use",
209
+ "view",
210
+ "vkern"
211
+ ]);
212
+ const SVGNamespace = {
213
+ xlink: "http://www.w3.org/1999/xlink",
214
+ xml: "http://www.w3.org/XML/1998/namespace"
215
+ };
216
+ const DOMElements = /*#__PURE__*/ new Set([
217
+ "html",
218
+ "base",
219
+ "head",
220
+ "link",
221
+ "meta",
222
+ "style",
223
+ "title",
224
+ "body",
225
+ "address",
226
+ "article",
227
+ "aside",
228
+ "footer",
229
+ "header",
230
+ "main",
231
+ "nav",
232
+ "section",
233
+ "body",
234
+ "blockquote",
235
+ "dd",
236
+ "div",
237
+ "dl",
238
+ "dt",
239
+ "figcaption",
240
+ "figure",
241
+ "hr",
242
+ "li",
243
+ "ol",
244
+ "p",
245
+ "pre",
246
+ "ul",
247
+ "a",
248
+ "abbr",
249
+ "b",
250
+ "bdi",
251
+ "bdo",
252
+ "br",
253
+ "cite",
254
+ "code",
255
+ "data",
256
+ "dfn",
257
+ "em",
258
+ "i",
259
+ "kbd",
260
+ "mark",
261
+ "q",
262
+ "rp",
263
+ "rt",
264
+ "ruby",
265
+ "s",
266
+ "samp",
267
+ "small",
268
+ "span",
269
+ "strong",
270
+ "sub",
271
+ "sup",
272
+ "time",
273
+ "u",
274
+ "var",
275
+ "wbr",
276
+ "area",
277
+ "audio",
278
+ "img",
279
+ "map",
280
+ "track",
281
+ "video",
282
+ "embed",
283
+ "iframe",
284
+ "object",
285
+ "param",
286
+ "picture",
287
+ "portal",
288
+ "source",
289
+ "svg",
290
+ "math",
291
+ "canvas",
292
+ "noscript",
293
+ "script",
294
+ "del",
295
+ "ins",
296
+ "caption",
297
+ "col",
298
+ "colgroup",
299
+ "table",
300
+ "tbody",
301
+ "td",
302
+ "tfoot",
303
+ "th",
304
+ "thead",
305
+ "tr",
306
+ "button",
307
+ "datalist",
308
+ "fieldset",
309
+ "form",
310
+ "input",
311
+ "label",
312
+ "legend",
313
+ "meter",
314
+ "optgroup",
315
+ "option",
316
+ "output",
317
+ "progress",
318
+ "select",
319
+ "textarea",
320
+ "details",
321
+ "dialog",
322
+ "menu",
323
+ "summary",
324
+ "details",
325
+ "slot",
326
+ "template",
327
+ "acronym",
328
+ "applet",
329
+ "basefont",
330
+ "bgsound",
331
+ "big",
332
+ "blink",
333
+ "center",
334
+ "content",
335
+ "dir",
336
+ "font",
337
+ "frame",
338
+ "frameset",
339
+ "hgroup",
340
+ "image",
341
+ "keygen",
342
+ "marquee",
343
+ "menuitem",
344
+ "nobr",
345
+ "noembed",
346
+ "noframes",
347
+ "plaintext",
348
+ "rb",
349
+ "rtc",
350
+ "shadow",
351
+ "spacer",
352
+ "strike",
353
+ "tt",
354
+ "xmp",
355
+ "a",
356
+ "abbr",
357
+ "acronym",
358
+ "address",
359
+ "applet",
360
+ "area",
361
+ "article",
362
+ "aside",
363
+ "audio",
364
+ "b",
365
+ "base",
366
+ "basefont",
367
+ "bdi",
368
+ "bdo",
369
+ "bgsound",
370
+ "big",
371
+ "blink",
372
+ "blockquote",
373
+ "body",
374
+ "br",
375
+ "button",
376
+ "canvas",
377
+ "caption",
378
+ "center",
379
+ "cite",
380
+ "code",
381
+ "col",
382
+ "colgroup",
383
+ "content",
384
+ "data",
385
+ "datalist",
386
+ "dd",
387
+ "del",
388
+ "details",
389
+ "dfn",
390
+ "dialog",
391
+ "dir",
392
+ "div",
393
+ "dl",
394
+ "dt",
395
+ "em",
396
+ "embed",
397
+ "fieldset",
398
+ "figcaption",
399
+ "figure",
400
+ "font",
401
+ "footer",
402
+ "form",
403
+ "frame",
404
+ "frameset",
405
+ "head",
406
+ "header",
407
+ "hgroup",
408
+ "hr",
409
+ "html",
410
+ "i",
411
+ "iframe",
412
+ "image",
413
+ "img",
414
+ "input",
415
+ "ins",
416
+ "kbd",
417
+ "keygen",
418
+ "label",
419
+ "legend",
420
+ "li",
421
+ "link",
422
+ "main",
423
+ "map",
424
+ "mark",
425
+ "marquee",
426
+ "menu",
427
+ "menuitem",
428
+ "meta",
429
+ "meter",
430
+ "nav",
431
+ "nobr",
432
+ "noembed",
433
+ "noframes",
434
+ "noscript",
435
+ "object",
436
+ "ol",
437
+ "optgroup",
438
+ "option",
439
+ "output",
440
+ "p",
441
+ "param",
442
+ "picture",
443
+ "plaintext",
444
+ "portal",
445
+ "pre",
446
+ "progress",
447
+ "q",
448
+ "rb",
449
+ "rp",
450
+ "rt",
451
+ "rtc",
452
+ "ruby",
453
+ "s",
454
+ "samp",
455
+ "script",
456
+ "section",
457
+ "select",
458
+ "shadow",
459
+ "slot",
460
+ "small",
461
+ "source",
462
+ "spacer",
463
+ "span",
464
+ "strike",
465
+ "strong",
466
+ "style",
467
+ "sub",
468
+ "summary",
469
+ "sup",
470
+ "table",
471
+ "tbody",
472
+ "td",
473
+ "template",
474
+ "textarea",
475
+ "tfoot",
476
+ "th",
477
+ "thead",
478
+ "time",
479
+ "title",
480
+ "tr",
481
+ "track",
482
+ "tt",
483
+ "u",
484
+ "ul",
485
+ "var",
486
+ "video",
487
+ "wbr",
488
+ "xmp",
489
+ "input",
490
+ "h1",
491
+ "h2",
492
+ "h3",
493
+ "h4",
494
+ "h5",
495
+ "h6"
496
+ ]);
66
497
 
67
498
  const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
68
499
  const GLOBAL_IDENTIFIER = "_$HY.r";
@@ -680,22 +1111,27 @@ function ssrSpread(props, isSVG, skipChildren) {
680
1111
  ) {
681
1112
  continue;
682
1113
  } else {
683
- if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
684
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
1114
+ if (prop.slice(0, 5) === "bool:") {
1115
+ if (!value) continue;
1116
+ prop = prop.slice(5);
1117
+ result += `${escape(prop)}`;
1118
+ } else {
1119
+ if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
1120
+ result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
1121
+ }
685
1122
  }
686
1123
  if (i !== keys.length - 1) result += " ";
687
1124
  }
688
1125
  return result;
689
1126
  }
1127
+ function notSup() {
1128
+ throw new Error(
1129
+ "Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>."
1130
+ );
1131
+ }
690
1132
 
691
1133
  const isServer = true;
692
1134
  const isDev = false;
693
- function render() {}
694
- function hydrate() {}
695
- function insert() {}
696
- function spread() {}
697
- function addEventListener() {}
698
- function delegateEvents() {}
699
1135
  function Dynamic(props) {
700
1136
  const [p, others] = splitProps(props, ["component"]);
701
1137
  const comp = p.component,
@@ -712,32 +1148,51 @@ function Portal(props) {
712
1148
  }
713
1149
 
714
1150
  export {
1151
+ Aliases,
715
1152
  Assets,
1153
+ ChildProperties,
1154
+ DOMElements,
1155
+ DelegatedEvents,
716
1156
  Dynamic,
717
1157
  Hydration,
718
1158
  HydrationScript,
719
1159
  NoHydration,
720
1160
  Portal,
1161
+ Properties,
721
1162
  RequestContext,
722
- addEventListener,
723
- delegateEvents,
1163
+ SVGElements,
1164
+ SVGNamespace,
1165
+ notSup as addEventListener,
1166
+ notSup as assign,
1167
+ notSup as classList,
1168
+ notSup as className,
1169
+ notSup as delegateEvents,
1170
+ notSup as dynamicProperty,
724
1171
  escape,
725
1172
  generateHydrationScript,
726
1173
  getAssets,
727
1174
  getHydrationKey,
1175
+ notSup as getNextElement,
1176
+ notSup as getNextMarker,
1177
+ notSup as getNextMatch,
1178
+ getPropAlias,
728
1179
  getRequestEvent,
729
- hydrate,
730
- insert,
1180
+ notSup as hydrate,
1181
+ notSup as insert,
731
1182
  isDev,
732
1183
  isServer,
733
1184
  pipeToNodeWritable,
734
1185
  pipeToWritable,
735
- render,
1186
+ notSup as render,
736
1187
  renderToStream,
737
1188
  renderToString,
738
1189
  renderToStringAsync,
739
1190
  resolveSSRNode,
740
- spread,
1191
+ notSup as runHydrationEvents,
1192
+ notSup as setAttribute,
1193
+ notSup as setAttributeNS,
1194
+ notSup as setProperty,
1195
+ notSup as spread,
741
1196
  ssr,
742
1197
  ssrAttribute,
743
1198
  ssrClassList,
@@ -745,5 +1200,7 @@ export {
745
1200
  ssrHydrationKey,
746
1201
  ssrSpread,
747
1202
  ssrStyle,
1203
+ notSup as style,
1204
+ notSup as template,
748
1205
  useAssets
749
1206
  };
package/web/dist/web.cjs CHANGED
@@ -119,14 +119,14 @@ function render(code, element, init, options = {}) {
119
119
  element.textContent = "";
120
120
  };
121
121
  }
122
- function template(html, isCE, isSVG) {
122
+ function template(html, isImportNode, isSVG) {
123
123
  let node;
124
124
  const create = () => {
125
125
  const t = document.createElement("template");
126
126
  t.innerHTML = html;
127
127
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
128
128
  };
129
- const fn = isCE ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
129
+ const fn = isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
130
130
  fn.cloneNode = fn;
131
131
  return fn;
132
132
  }
@@ -158,6 +158,10 @@ function setAttributeNS(node, namespace, name, value) {
158
158
  if (isHydrating(node)) return;
159
159
  if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
160
160
  }
161
+ function setBoolAttribute(node, name, value) {
162
+ if (isHydrating(node)) return;
163
+ value ? node.setAttribute(name, "") : node.removeAttribute(name);
164
+ }
161
165
  function className(node, value) {
162
166
  if (isHydrating(node)) return;
163
167
  if (value == null) node.removeAttribute("class");else node.className = value;
@@ -171,7 +175,7 @@ function addEventListener(node, name, handler, delegate) {
171
175
  } else if (Array.isArray(handler)) {
172
176
  const handlerFn = handler[0];
173
177
  node.addEventListener(name, handler[0] = e => handlerFn.call(node, handler[1], e));
174
- } else node.addEventListener(name, handler);
178
+ } else node.addEventListener(name, handler, typeof handler !== "function" && handler);
175
179
  }
176
180
  function classList(node, value, prev = {}) {
177
181
  const classKeys = Object.keys(value || {}),
@@ -245,7 +249,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
245
249
  for (const prop in prevProps) {
246
250
  if (!(prop in props)) {
247
251
  if (prop === "children") continue;
248
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
252
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef, props);
249
253
  }
250
254
  }
251
255
  for (const prop in props) {
@@ -254,7 +258,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
254
258
  continue;
255
259
  }
256
260
  const value = props[prop];
257
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
261
+ prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
258
262
  }
259
263
  }
260
264
  function hydrate$1(code, element, options = {}) {
@@ -343,7 +347,7 @@ function toggleClassKey(node, key, value) {
343
347
  const classNames = key.trim().split(/\s+/);
344
348
  for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
345
349
  }
346
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
350
+ function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
347
351
  let isCE, isProp, isChildProp, propAlias, forceProp;
348
352
  if (prop === "style") return style(node, value, prev);
349
353
  if (prop === "classList") return classList(node, value, prev);
@@ -352,8 +356,8 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
352
356
  if (!skipRef) value(node);
353
357
  } else if (prop.slice(0, 3) === "on:") {
354
358
  const e = prop.slice(3);
355
- prev && node.removeEventListener(e, prev);
356
- value && node.addEventListener(e, value);
359
+ prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
360
+ value && node.addEventListener(e, value, typeof value !== "function" && value);
357
361
  } else if (prop.slice(0, 10) === "oncapture:") {
358
362
  const e = prop.slice(10);
359
363
  prev && node.removeEventListener(e, prev, true);
@@ -371,7 +375,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
371
375
  }
372
376
  } else if (prop.slice(0, 5) === "attr:") {
373
377
  setAttribute(node, prop.slice(5), value);
374
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
378
+ } else if (prop.slice(0, 5) === "bool:") {
379
+ setBoolAttribute(node, prop.slice(5), value);
380
+ } else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG && ((propAlias = getPropAlias(prop, node.tagName)) || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-") || 'is' in props)) {
375
381
  if (forceProp) {
376
382
  prop = prop.slice(5);
377
383
  isProp = true;
@@ -387,30 +393,52 @@ function eventHandler(e) {
387
393
  if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
388
394
  if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
389
395
  }
396
+ let node = e.target;
390
397
  const key = `$$${e.type}`;
391
- let node = e.composedPath && e.composedPath()[0] || e.target;
392
- if (e.target !== node) {
393
- Object.defineProperty(e, "target", {
394
- configurable: true,
395
- value: node
396
- });
397
- }
398
- Object.defineProperty(e, "currentTarget", {
398
+ const oriTarget = e.target;
399
+ const oriCurrentTarget = e.currentTarget;
400
+ const retarget = value => Object.defineProperty(e, "target", {
399
401
  configurable: true,
400
- get() {
401
- return node || document;
402
- }
402
+ value
403
403
  });
404
- if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) solidJs.sharedConfig.done = _$HY.done = true;
405
- while (node) {
404
+ const handleNode = () => {
406
405
  const handler = node[key];
407
406
  if (handler && !node.disabled) {
408
407
  const data = node[`${key}Data`];
409
408
  data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
410
409
  if (e.cancelBubble) return;
411
410
  }
412
- node = node._$host || node.parentNode || node.host;
411
+ node.host && node.contains(e.target) && !node.host._$host && retarget(node.host);
412
+ return true;
413
+ };
414
+ const walkUpTree = () => {
415
+ while (handleNode() && (node = node._$host || node.parentNode || node.host));
416
+ };
417
+ Object.defineProperty(e, "currentTarget", {
418
+ configurable: true,
419
+ get() {
420
+ return node || document;
421
+ }
422
+ });
423
+ if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) solidJs.sharedConfig.done = _$HY.done = true;
424
+ if (e.composedPath) {
425
+ const path = e.composedPath();
426
+ retarget(path[0]);
427
+ for (let i = 0; i < path.length - 2; i++) {
428
+ node = path[i];
429
+ if (!handleNode()) break;
430
+ if (node._$host) {
431
+ node = node._$host;
432
+ walkUpTree();
433
+ break;
434
+ }
435
+ if (node.parentNode === oriCurrentTarget) {
436
+ break;
437
+ }
438
+ }
413
439
  }
440
+ else walkUpTree();
441
+ retarget(oriTarget);
414
442
  }
415
443
  function insertExpression(parent, value, current, marker, unwrapArray) {
416
444
  const hydrating = isHydrating(parent);
@@ -749,6 +777,7 @@ exports.resolveSSRNode = resolveSSRNode;
749
777
  exports.runHydrationEvents = runHydrationEvents;
750
778
  exports.setAttribute = setAttribute;
751
779
  exports.setAttributeNS = setAttributeNS;
780
+ exports.setBoolAttribute = setBoolAttribute;
752
781
  exports.setProperty = setProperty;
753
782
  exports.spread = spread;
754
783
  exports.ssr = ssr;