@solidjs/web 2.0.0-beta.4 → 2.0.0-beta.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/dist/web.js CHANGED
@@ -1,9 +1,40 @@
1
1
  import { createRenderEffect, createMemo as createMemo$1, sharedConfig, untrack, runWithOwner, flatten, createRoot, omit, enableHydration } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
  import { createMemo } from '@solidjs/signals';
4
4
 
5
- const Properties = /*#__PURE__*/new Set([
6
- "value", "checked", "selected", "muted"]);
5
+ const DOMWithState = {
6
+ INPUT: {
7
+ value: 1,
8
+ defaultValue: 1,
9
+ checked: 1,
10
+ defaultChecked: 1
11
+ },
12
+ SELECT: {
13
+ value: 1
14
+ },
15
+ OPTION: {
16
+ value: 1,
17
+ selected: 1,
18
+ defaultSelected: 1
19
+ },
20
+ TEXTAREA: {
21
+ value: 1,
22
+ defaultValue: 1
23
+ },
24
+ VIDEO: {
25
+ muted: 1,
26
+ defaultMuted: 1
27
+ },
28
+ AUDIO: {
29
+ muted: 1,
30
+ defaultMuted: 1
31
+ }
32
+ };
33
+ for (const tagName in DOMWithState) {
34
+ for (const propName in DOMWithState[tagName]) {
35
+ DOMWithState[tagName]["prop:" + propName] = 1;
36
+ }
37
+ }
7
38
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
8
39
  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"]);
9
40
  const SVGElements = /*#__PURE__*/new Set([
@@ -11,7 +42,10 @@ const SVGElements = /*#__PURE__*/new Set([
11
42
  "set", "stop",
12
43
  "svg", "switch", "symbol", "text", "textPath",
13
44
  "tref", "tspan", "use", "view", "vkern"]);
14
- const SVGNamespace = {
45
+ const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
46
+ const Namespaces = {
47
+ svg: "http://www.w3.org/2000/svg",
48
+ mathml: "http://www.w3.org/1998/Math/MathML",
15
49
  xlink: "http://www.w3.org/1999/xlink",
16
50
  xml: "http://www.w3.org/XML/1998/namespace"
17
51
  };
@@ -97,14 +131,14 @@ function render$1(code, element, init, options = {}) {
97
131
  element.textContent = "";
98
132
  };
99
133
  }
100
- function template(html, isImportNode, isSVG, isMathML) {
134
+ function create(html, bypassGuard, flag) {
135
+ const t = document.createElement("template");
136
+ t.innerHTML = html;
137
+ return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
138
+ }
139
+ function template(html, flag) {
101
140
  let node;
102
- const create = bypassGuard => {
103
- const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
104
- t.innerHTML = html;
105
- return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
106
- };
107
- const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
141
+ const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
108
142
  return fn;
109
143
  }
110
144
  function delegateEvents(eventNames, document = window.document) {
@@ -133,16 +167,16 @@ function setAttribute(node, name, value) {
133
167
  }
134
168
  function setAttributeNS(node, namespace, name, value) {
135
169
  if (isHydrating(node)) return;
136
- if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
170
+ if (value == null || value === false) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
137
171
  }
138
- function className(node, value, isSVG, prev) {
172
+ function className(node, value, prev) {
139
173
  if (isHydrating(node)) return;
140
174
  if (value == null || value === false) {
141
175
  prev && node.removeAttribute("class");
142
176
  return;
143
177
  }
144
178
  if (typeof value === "string") {
145
- value !== prev && (isSVG ? node.setAttribute("class", value) : node.className = value);
179
+ value !== prev && node.setAttribute("class", value);
146
180
  return;
147
181
  }
148
182
  if (typeof prev === "string") {
@@ -197,7 +231,7 @@ function style(node, value, prev) {
197
231
  function setStyleProperty(node, name, value) {
198
232
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
199
233
  }
200
- function spread(node, props = {}, isSVG, skipChildren) {
234
+ function spread(node, props = {}, skipChildren) {
201
235
  const prevProps = {};
202
236
  if (!skipChildren) insert(node, () => props.children);
203
237
  effect(() => {
@@ -211,7 +245,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
211
245
  newProps[prop] = props[prop];
212
246
  }
213
247
  return newProps;
214
- }, props => assign(node, props, isSVG, true, prevProps, true));
248
+ }, props => assign(node, props, true, prevProps, true));
215
249
  return prevProps;
216
250
  }
217
251
  function dynamicProperty(props, key) {
@@ -256,21 +290,21 @@ function insert(parent, accessor, marker, initial) {
256
290
  }
257
291
  effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
258
292
  }
259
- function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
293
+ function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
294
+ const nodeName = node.nodeName;
260
295
  props || (props = {});
261
296
  for (const prop in prevProps) {
262
297
  if (!(prop in props)) {
263
298
  if (prop === "children") continue;
264
- prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
299
+ prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
265
300
  }
266
301
  }
267
302
  for (const prop in props) {
268
303
  if (prop === "children") {
269
- if (!skipChildren) insertExpression(node, props.children);
304
+ if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
270
305
  continue;
271
306
  }
272
- const value = props[prop];
273
- prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
307
+ prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
274
308
  }
275
309
  }
276
310
  function hydrate$1(code, element, options = {}) {
@@ -397,18 +431,20 @@ function flattenClassList(list, result) {
397
431
  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;
398
432
  }
399
433
  }
400
- function assignProp(node, prop, value, prev, isSVG, skipRef) {
401
- let forceProp;
434
+ function assignProp(node, prop, value, prev, skipRef, nodeName) {
402
435
  if (prop === "style") return style(node, value, prev), value;
403
- if (prop === "class") return className(node, value, isSVG, prev), value;
404
- if (value === prev) return prev;
436
+ if (prop === "class") return className(node, value, prev), value;
437
+ if (value === prev && !DOMWithState[nodeName]?.[prop]) return prev;
405
438
  if (prop === "ref") {
406
439
  if (!skipRef && value) ref(() => value, node);
407
- } else if (prop.slice(0, 3) === "on:") {
440
+ return value;
441
+ }
442
+ const hasNamespace = prop.indexOf(":") > -1;
443
+ if (hasNamespace && prop.slice(0, 3) === "on:") {
408
444
  const e = prop.slice(3);
409
445
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
410
446
  value && node.addEventListener(e, value, typeof value !== "function" && value);
411
- } else if (prop.slice(0, 2) === "on") {
447
+ } else if (!hasNamespace && prop.slice(0, 2) === "on") {
412
448
  const name = prop.slice(2).toLowerCase();
413
449
  const delegate = DelegatedEvents.has(name);
414
450
  if (!delegate && prev) {
@@ -419,11 +455,11 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
419
455
  addEventListener(node, name, value, delegate);
420
456
  delegate && delegateEvents([name]);
421
457
  }
422
- } else if ((forceProp = prop.slice(0, 5) === "prop:") || ChildProperties.has(prop) || !isSVG && Properties.has(prop)) {
423
- if (forceProp) prop = prop.slice(5);else if (isHydrating(node)) return value;
424
- if (prop === "value" && node.nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
458
+ } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
459
+ if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
460
+ if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
425
461
  } else {
426
- const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
462
+ const ns = hasNamespace && Namespaces[prop.split(":")[0]];
427
463
  if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
428
464
  }
429
465
  return value;
@@ -505,7 +541,6 @@ function insertExpression(parent, value, current, marker) {
505
541
  appendNodes(parent, value, marker);
506
542
  } else reconcileArrays(parent, current, value);
507
543
  } else {
508
- if (current && current.nodeType) clearHydrationRegistry(current);
509
544
  current && cleanChildren(parent);
510
545
  appendNodes(parent, value);
511
546
  }
@@ -531,18 +566,6 @@ function normalize(value, current, multi, doNotUnwrap) {
531
566
  function appendNodes(parent, array, marker = null) {
532
567
  for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
533
568
  }
534
- function clearHydrationRegistry(node) {
535
- if (!sharedConfig.registry || !node || node.nodeType !== 1) return;
536
- const key = node.getAttribute("_hk");
537
- if (key) sharedConfig.registry.delete(key);
538
- const descendants = node.querySelectorAll?.(`*[_hk]`);
539
- if (descendants) {
540
- for (let i = 0; i < descendants.length; i++) {
541
- const descendantKey = descendants[i].getAttribute("_hk");
542
- if (descendantKey) sharedConfig.registry.delete(descendantKey);
543
- }
544
- }
545
- }
546
569
  function cleanChildren(parent, current, marker, replacement) {
547
570
  if (marker === undefined) return parent.textContent = "";
548
571
  if (current.length) {
@@ -551,10 +574,7 @@ function cleanChildren(parent, current, marker, replacement) {
551
574
  const el = current[i];
552
575
  if (replacement !== el) {
553
576
  const isParent = el.parentNode === parent;
554
- if (replacement && !inserted && !i) isParent ? (clearHydrationRegistry(el), parent.replaceChild(replacement, el)) : parent.insertBefore(replacement, marker);else if (isParent) {
555
- clearHydrationRegistry(el);
556
- el.remove();
557
- }
577
+ if (replacement && !inserted && !i) isParent ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else isParent && el.remove();
558
578
  } else inserted = true;
559
579
  }
560
580
  } else if (replacement) parent.insertBefore(replacement, marker);
@@ -668,4 +688,4 @@ function Dynamic(props) {
668
688
  return createDynamic(() => props.component, others);
669
689
  }
670
690
 
671
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };
691
+ export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RequestContext, SVGElements, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, 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-beta.4",
4
+ "version": "2.0.0-beta.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -75,11 +75,12 @@
75
75
  "seroval-plugins": "^1.1.0"
76
76
  },
77
77
  "peerDependencies": {
78
- "solid-js": "^2.0.0-beta.4",
79
- "@solidjs/signals": "^0.13.6"
78
+ "@solidjs/signals": "^0.13.11",
79
+ "solid-js": "^2.0.0-beta.6"
80
80
  },
81
81
  "devDependencies": {
82
- "solid-js": "2.0.0-beta.4"
82
+ "@solidjs/signals": "^0.13.11",
83
+ "solid-js": "2.0.0-beta.6"
83
84
  },
84
85
  "scripts": {
85
86
  "build": "npm-run-all -nl build:*",
@@ -2,7 +2,7 @@ import { hydrate as hydrateCore, render as renderCore } from "./client.js";
2
2
  import { JSX, ComponentProps, ValidComponent } from "solid-js";
3
3
  export * from "./client.js";
4
4
  export declare function render(...args: Parameters<typeof renderCore>): ReturnType<typeof renderCore>;
5
- export { For, Show, Switch, Match, Errored, Loading, NoHydration, Hydration, merge as mergeProps } from "solid-js";
5
+ export { For, Show, Switch, Match, Errored, Loading, Reveal, NoHydration, Hydration, merge as mergeProps } from "solid-js";
6
6
  export * from "./server-mock.js";
7
7
  export declare const isServer: boolean;
8
8
  export declare const isDev: boolean;
package/types/client.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { JSX } from "./jsx.js";
2
- export const Properties: Set<string>;
2
+ export const DOMWithState: Record<string, Record<string, number>>;
3
3
  export const ChildProperties: Set<string>;
4
4
  export const DelegatedEvents: Set<string>;
5
5
  export const DOMElements: Set<string>;
6
6
  export const SVGElements: Set<string>;
7
- export const SVGNamespace: Record<string, string>;
7
+ export const MathMLElements: Set<string>;
8
+ export const Namespaces: Record<string, string>;
8
9
 
9
10
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
10
11
  export function render(
@@ -13,7 +14,7 @@ export function render(
13
14
  init?: JSX.Element,
14
15
  options?: { owner?: unknown }
15
16
  ): () => void;
16
- export function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Element;
17
+ export function template(html: string, flag?: number): () => Element;
17
18
  export function effect<T>(fn: (prev?: T) => T, effect: (value: T, prev?: T) => void, init?: T): void;
18
19
  export function memo<T>(fn: () => T, equal: boolean): () => T;
19
20
  export function untrack<T>(fn: () => T): T;
@@ -29,13 +30,11 @@ export function clearDelegatedEvents(d?: Document): void;
29
30
  export function spread<T>(
30
31
  node: Element,
31
32
  accessor: T,
32
- isSVG?: Boolean,
33
33
  skipChildren?: Boolean
34
34
  ): void;
35
35
  export function assign(
36
36
  node: Element,
37
37
  props: any,
38
- isSVG?: Boolean,
39
38
  skipChildren?: Boolean,
40
39
  prevProps?: any,
41
40
  skipRef?: Boolean
@@ -45,7 +44,7 @@ export function setAttributeNS(node: Element, namespace: string, name: string, v
45
44
  type ClassList =
46
45
  | Record<string, boolean>
47
46
  | Array<string | number | boolean | null | undefined | Record<string, boolean>>;
48
- export function className(node: Element, value: string | ClassList, isSvg?: boolean, prev?: string | ClassList): void;
47
+ export function className(node: Element, value: string | ClassList, prev?: string | ClassList): void;
49
48
  export function setProperty(node: Element, name: string, value: any): void;
50
49
  export function setStyleProperty(node: Element, name: string, value: any): void;
51
50
  export function addEventListener(
package/types/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { hydrate as hydrateCore, render as renderCore } from "./client.js";
2
2
  import { JSX, ComponentProps, ValidComponent } from "solid-js";
3
3
  export * from "./client.js";
4
4
  export declare function render(...args: Parameters<typeof renderCore>): ReturnType<typeof renderCore>;
5
- export { For, Show, Switch, Match, Errored, Loading, NoHydration, Hydration, merge as mergeProps } from "solid-js";
5
+ export { For, Show, Switch, Match, Errored, Loading, Reveal, NoHydration, Hydration, merge as mergeProps } from "solid-js";
6
6
  export * from "./server-mock.js";
7
7
  export declare const isServer: boolean;
8
8
  export declare const isDev: boolean;
package/types/server.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { JSX } from "./jsx.js";
2
- export const Properties: Set<string>;
3
2
  export const ChildProperties: Set<string>;
4
3
  export const DelegatedEvents: Set<string>;
5
4
  export const DOMElements: Set<string>;
6
5
  export const SVGElements: Set<string>;
7
- export const SVGNamespace: Record<string, string>;
6
+ export const MathMLElements: Set<string>;
7
+ export const Namespaces: Record<string, string>;
8
8
 
9
9
  type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
10
10
 
@@ -107,7 +107,6 @@ export function insert<T>(
107
107
  export function spread<T>(
108
108
  node: Element,
109
109
  accessor: T,
110
- isSVG?: Boolean,
111
110
  skipChildren?: Boolean
112
111
  ): void;
113
112
 
@@ -131,13 +130,13 @@ export function addEventListener(
131
130
  /** @deprecated not supported on the server side */
132
131
  export function render(code: () => JSX.Element, element: MountableElement): () => void;
133
132
  /** @deprecated not supported on the server side */
134
- export function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Element;
133
+ export function template(html: string, flag?: number): () => Element;
135
134
  /** @deprecated not supported on the server side */
136
135
  export function setProperty(node: Element, name: string, value: any): void;
137
136
  /** @deprecated not supported on the server side */
138
137
  export function className(node: Element, value: string): void;
139
138
  /** @deprecated not supported on the server side */
140
- export function assign(node: Element, props: any, isSVG?: Boolean, skipChildren?: Boolean): void;
139
+ export function assign(node: Element, props: any, skipChildren?: Boolean): void;
141
140
 
142
141
  /** @deprecated not supported on the server side */
143
142
  export function hydrate(