solid-js 2.0.0-beta.11 → 2.0.0-beta.13

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/CHEATSHEET.md CHANGED
@@ -216,9 +216,12 @@ const rest = omit(props, "class", "style"); // replaces splitProps
216
216
  const user = createMemo(() => fetchUser(id()));
217
217
  // Reading user() suspends until ready; wrap in <Loading>.
218
218
 
219
- // "Refreshing…" indicator (false during initial Loading)
219
+ // "Refreshing…" indicator (false on the Loading path)
220
220
  isPending(() => user());
221
221
 
222
+ // Render guard: pending read follows the Loading path
223
+ isPending(() => user(), true);
224
+
222
225
  // Peek at the in-flight value during a transition
223
226
  latest(id);
224
227
 
@@ -255,12 +258,12 @@ Optimistic writes revert when the transition completes.
255
258
  ```tsx
256
259
  // List, keyed by identity (default)
257
260
  <For each={items()}>
258
- {(item, i) => <Row item={item()} index={i()} />}
261
+ {(item, i) => <Row item={item} index={i()} />}
259
262
  </For>
260
263
 
261
264
  // List, non-keyed (replaces <Index>)
262
265
  <For each={items()} keyed={false}>
263
- {(item, i) => <Row item={item()} index={i()} />}
266
+ {(item, i) => <Row item={item()} index={i} />}
264
267
  </For>
265
268
 
266
269
  // List with custom key
@@ -290,7 +293,7 @@ Optimistic writes revert when the transition completes.
290
293
  </Loading>
291
294
 
292
295
  // Error boundary (replaces <ErrorBoundary>)
293
- <Errored fallback={(err, reset) => <button onClick={reset}>retry</button>}>
296
+ <Errored fallback={(err, reset) => <button onClick={reset}>retry {String(err())}</button>}>
294
297
  <Page />
295
298
  </Errored>
296
299
 
@@ -316,7 +319,8 @@ import { Dynamic } from "@solidjs/web";
316
319
  <Dynamic component={isEditing() ? Editor : Viewer} value={value()} />
317
320
  ```
318
321
 
319
- `<For>` non-keyed: `item` and `i` are **accessors** call them: `item()`, `i()`.
322
+ `<For>` non-keyed: `item` is an **accessor** and `i` is a plain number.
323
+ `<For>` default/keyed-by-identity: `item` is a **plain value** and `i` is an accessor.
320
324
  `<Repeat>`: `i` is a **plain number**.
321
325
 
322
326
  ---
@@ -434,7 +438,15 @@ function titleDirective(source) {
434
438
  <some-element enabled="true" /> // when platform requires the string
435
439
  ```
436
440
 
437
- Lowercase HTML attribute names. No `attr:` / `bool:` / `oncapture:` namespaces. Event handlers stay camelCase (`onClick`).
441
+ Lowercase HTML attribute names. No `attr:` / `bool:` / `on:` / `oncapture:` namespaces. Event handlers stay camelCase (`onClick`).
442
+
443
+ For native listener options, use a ref callback:
444
+
445
+ ```jsx
446
+ const on = (type, handler, options) => el => el.addEventListener(type, handler, options);
447
+
448
+ <button ref={on("click", handleClick, { capture: true })} />;
449
+ ```
438
450
 
439
451
  ### Conditional classes — always use the array/object form
440
452
 
@@ -607,7 +619,7 @@ If your training data is 1.x, these are the corrections. **Read this before gene
607
619
  | `indexArray` | `mapArray` (handles non-keyed too) |
608
620
  | `use:foo={x}` directives | `ref={foo(x)}` (or array `ref={[a, b(x)]}`) |
609
621
  | `attr:` / `bool:` namespaces | Standard attribute behavior |
610
- | `oncapture:` | `addEventListener(..., { capture: true })` |
622
+ | `on:` / `oncapture:` | `onClick` for Solid events; ref callbacks for native listener opts |
611
623
  | `resetErrorBoundaries` | Boundaries heal automatically |
612
624
 
613
625
  ### Behavior changes
@@ -618,12 +630,12 @@ If your training data is 1.x, these are the corrections. **Read this before gene
618
630
  - **No top-level reactive reads in component body** — reading signals/props directly at the top of a component warns. Read inside JSX, a memo, or `untrack`.
619
631
  - **Props are values, not accessors** — at the call site call accessors (`<X v={count()} />`, not `<X v={count} />`). The single most common AI-generated bug.
620
632
  - **Don't destructure props** — `function Comp({ name })` warns; use `props.name` to keep reactivity. (Same root cause as above; see the Props section.)
621
- - **`<For>` non-keyed children are accessors** — `(item, i) => ...` where `item` and `i` are functions. Call them: `item()`, `i()`.
622
- - **`<Show>` / `<Match>` function children receive narrowed accessors** — also call them.
633
+ - **`<For>` callback shape follows keying** — default/keyed-by-identity receives a raw item and index accessor; `keyed={false}` receives an item accessor and stable numeric index; custom keys receive accessors.
634
+ - **`<Show>` / `<Match>` function children narrow values** — non-keyed children receive accessors; keyed children receive raw values.
623
635
  - **Stores: setters take a draft callback** — mutate the draft in place by default. Returning a new value is shallow (array index-replace, object top-level diff); reach for it for filter/remove. Keyed reconcile is a _projection-fn_ feature, not a setter feature.
624
636
  - **`undefined` is a real value in `merge`** — it overrides rather than "skip this key".
625
- - **Async lives in computations** — return a Promise/AsyncIterable from `createMemo`/`createStore(fn)`/`createProjection`. Reads suspend; wrap in `<Loading>`.
626
- - **`Loading` is initial-only by default** — once content has rendered, revalidation keeps it visible. Use `isPending(() => x())` for "refreshing…" indicators. Use `<Loading on={key}>` to re-show fallback on key changes.
637
+ - **Async lives in computations** — return a Promise/AsyncIterable from `createMemo`/`createStore(fn)`/`createProjection`. Pending reads participate in `<Loading>`.
638
+ - **`Loading` covers unresolved branches** — once content has rendered, revalidation keeps it visible. Use `isPending(() => x())` for "refreshing…" indicators, or `isPending(() => x(), true)` when a render guard should follow the Loading path. Use `<Loading on={key}>` to re-show fallback on key changes.
627
639
  - **No `Suspense.Provider` or single error path** — async errors flow to `<Errored>` (or effect `error`); no inline `resource.error` branching.
628
640
  - **`createRoot` is owned by parent by default** — disposed when parent disposes. To detach: `runWithOwner(null, fn)`.
629
641
  - **Refs are functions** — `ref={el => ...}`. No `useRef`-style ref objects. Compose with arrays: `ref={[a, b]}`.
package/dist/dev.cjs CHANGED
@@ -809,7 +809,7 @@ function Show(props) {
809
809
  if (c) {
810
810
  const child = props.children;
811
811
  const fn = typeof child === "function" && child.length > 0;
812
- return fn ? signals.untrack(() => child(() => {
812
+ return fn ? keyed ? signals.untrack(() => child(c), "<Show>") : signals.untrack(() => child(() => {
813
813
  if (!signals.untrack(condition)) throw narrowedError("Show");
814
814
  return conditionValue();
815
815
  }), "<Show>") : child;
@@ -837,7 +837,12 @@ function Switch(props) {
837
837
  name: "condition",
838
838
  sync: true
839
839
  } );
840
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
840
+ func = () => {
841
+ const prev = prevFunc();
842
+ if (prev) return prev;
843
+ const c = condition();
844
+ return c ? [index, c, conditionValue, mp] : undefined;
845
+ };
841
846
  }
842
847
  return func;
843
848
  }, {
@@ -846,10 +851,10 @@ function Switch(props) {
846
851
  return signals.createMemo(() => {
847
852
  const sel = switchFunc()();
848
853
  if (!sel) return props.fallback;
849
- const [index, conditionValue, mp] = sel;
854
+ const [index, value, conditionValue, mp] = sel;
850
855
  const child = mp.children;
851
856
  const fn = typeof child === "function" && child.length > 0;
852
- return fn ? signals.untrack(() => child(() => {
857
+ return fn ? mp.keyed ? signals.untrack(() => child(value), "<Match>") : signals.untrack(() => child(() => {
853
858
  if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
854
859
  return conditionValue();
855
860
  }), "<Match>") : child;
@@ -864,7 +869,7 @@ function Match(props) {
864
869
  function Errored(props) {
865
870
  return createErrorBoundary(() => props.children, (err, reset) => {
866
871
  const f = props.fallback;
867
- if ((typeof f !== "function" || f.length == 0)) console.error(err);
872
+ if ((typeof f !== "function" || f.length == 0)) console.error(err());
868
873
  return typeof f === "function" && f.length ? f(err, reset) : f;
869
874
  });
870
875
  }
package/dist/dev.js CHANGED
@@ -808,7 +808,7 @@ function Show(props) {
808
808
  if (c) {
809
809
  const child = props.children;
810
810
  const fn = typeof child === "function" && child.length > 0;
811
- return fn ? untrack(() => child(() => {
811
+ return fn ? keyed ? untrack(() => child(c), "<Show>") : untrack(() => child(() => {
812
812
  if (!untrack(condition)) throw narrowedError("Show");
813
813
  return conditionValue();
814
814
  }), "<Show>") : child;
@@ -836,7 +836,12 @@ function Switch(props) {
836
836
  name: "condition",
837
837
  sync: true
838
838
  } );
839
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
839
+ func = () => {
840
+ const prev = prevFunc();
841
+ if (prev) return prev;
842
+ const c = condition();
843
+ return c ? [index, c, conditionValue, mp] : undefined;
844
+ };
840
845
  }
841
846
  return func;
842
847
  }, {
@@ -845,10 +850,10 @@ function Switch(props) {
845
850
  return createMemo$1(() => {
846
851
  const sel = switchFunc()();
847
852
  if (!sel) return props.fallback;
848
- const [index, conditionValue, mp] = sel;
853
+ const [index, value, conditionValue, mp] = sel;
849
854
  const child = mp.children;
850
855
  const fn = typeof child === "function" && child.length > 0;
851
- return fn ? untrack(() => child(() => {
856
+ return fn ? mp.keyed ? untrack(() => child(value), "<Match>") : untrack(() => child(() => {
852
857
  if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
853
858
  return conditionValue();
854
859
  }), "<Match>") : child;
@@ -863,7 +868,7 @@ function Match(props) {
863
868
  function Errored(props) {
864
869
  return createErrorBoundary(() => props.children, (err, reset) => {
865
870
  const f = props.fallback;
866
- if ((typeof f !== "function" || f.length == 0)) console.error(err);
871
+ if ((typeof f !== "function" || f.length == 0)) console.error(err());
867
872
  return typeof f === "function" && f.length ? f(err, reset) : f;
868
873
  });
869
874
  }
package/dist/server.cjs CHANGED
@@ -32,6 +32,9 @@ function nextChildIdFor(owner, consume) {
32
32
  }
33
33
  throw new Error("Cannot get child id from owner without an id");
34
34
  }
35
+ function consumeClientComputedSlot(owner) {
36
+ if (owner?.id != null) nextChildIdFor(owner);
37
+ }
35
38
  function getNextChildId(owner) {
36
39
  return nextChildIdFor(owner);
37
40
  }
@@ -116,6 +119,7 @@ function disposeOwner(owner, self = true) {
116
119
  if (self) {
117
120
  node._disposed = true;
118
121
  if (ownerPool.length < OWNER_POOL_MAX) {
122
+ node.id = undefined;
119
123
  node._parent = null;
120
124
  node._nextSibling = null;
121
125
  ownerPool.push(node);
@@ -142,6 +146,7 @@ function disposeOwner(owner, self = true) {
142
146
  node._disposal = null;
143
147
  }
144
148
  if (self && ownerPool.length < OWNER_POOL_MAX) {
149
+ node.id = undefined;
145
150
  node._parent = null;
146
151
  node._nextSibling = null;
147
152
  ownerPool.push(node);
@@ -744,8 +749,43 @@ function reconcile(value) {
744
749
  function deep(store) {
745
750
  return store;
746
751
  }
752
+ function proxySource(read) {
753
+ return new Proxy({}, {
754
+ get(_, property, receiver) {
755
+ if (property === signals.$PROXY) return receiver;
756
+ const source = read() || {};
757
+ return source[property];
758
+ },
759
+ has(_, property) {
760
+ if (property === signals.$PROXY) return true;
761
+ return property in (read() || {});
762
+ },
763
+ ownKeys() {
764
+ return Object.keys(read() || {});
765
+ },
766
+ getOwnPropertyDescriptor(_, property) {
767
+ return {
768
+ configurable: true,
769
+ enumerable: true,
770
+ get() {
771
+ return (read() || {})[property];
772
+ }
773
+ };
774
+ }
775
+ });
776
+ }
777
+ function merge(...sources) {
778
+ for (let i = 0; i < sources.length; i++) {
779
+ if (typeof sources[i] === "function") {
780
+ sources[i] = proxySource(createMemo(sources[i]));
781
+ }
782
+ }
783
+ return signals.merge(...sources);
784
+ }
747
785
  function mapArray(list, mapFn, options = {}) {
748
- return createMemo(() => {
786
+ const indexes = mapFn.length > 1;
787
+ const parent = currentOwner;
788
+ const read = createMemo(() => {
749
789
  const items = list();
750
790
  const s = [];
751
791
  if (items && items.length) {
@@ -758,7 +798,7 @@ function mapArray(list, mapFn, options = {}) {
758
798
  parent.id = formatChildId(origId, origChildCount + i);
759
799
  }
760
800
  parent._childCount = 0;
761
- s.push(mapFn(() => items[i], () => i));
801
+ s.push(options.keyed === false ? indexes ? mapFn(() => items[i], i) : mapFn(() => items[i]) : typeof options.keyed === "function" ? indexes ? mapFn(() => items[i], () => i) : mapFn(() => items[i]) : indexes ? mapFn(items[i], () => i) : mapFn(items[i]));
762
802
  }
763
803
  } finally {
764
804
  parent.id = origId;
@@ -772,9 +812,12 @@ function mapArray(list, mapFn, options = {}) {
772
812
  }, {
773
813
  sync: true
774
814
  });
815
+ consumeClientComputedSlot(parent);
816
+ return read;
775
817
  }
776
818
  function repeat(count, mapFn, options = {}) {
777
- return createMemo(() => {
819
+ const parent = currentOwner;
820
+ const read = createMemo(() => {
778
821
  const len = count();
779
822
  const offset = options.from?.() || 0;
780
823
  if (!len) {
@@ -802,6 +845,8 @@ function repeat(count, mapFn, options = {}) {
802
845
  }, {
803
846
  sync: true
804
847
  });
848
+ consumeClientComputedSlot(parent);
849
+ return read;
805
850
  }
806
851
  const ErrorContext = {
807
852
  id: Symbol("ErrorContext"),
@@ -838,8 +883,8 @@ function createErrorBoundary(fn, fallback) {
838
883
  };
839
884
  const renderFallback = err => ctx ? runWithOwner(parent, () => {
840
885
  const fallbackOwner = createOwner();
841
- return runWithOwner(fallbackOwner, () => fallback(err, () => {}));
842
- }) : fallback(err, () => {});
886
+ return runWithOwner(fallbackOwner, () => fallback(() => err, () => {}));
887
+ }) : fallback(() => err, () => {});
843
888
  const serializeError = err => {
844
889
  if (ctx && owner.id && !runWithOwner(owner, () => getContext(NoHydrateContext))) {
845
890
  ctx.serialize(owner.id, err);
@@ -889,15 +934,13 @@ function flush() {}
889
934
  function resolve(fn) {
890
935
  throw new Error("resolve is not implemented on the server");
891
936
  }
892
- function isPending(fn, fallback) {
937
+ function isPending(fn, loading) {
893
938
  try {
894
939
  fn();
895
940
  return false;
896
941
  } catch (err) {
897
- if (err instanceof signals.NotReadyError && arguments.length > 1) {
898
- return fallback;
899
- }
900
- throw err;
942
+ if (!(err instanceof signals.NotReadyError) || loading) throw err;
943
+ return false;
901
944
  }
902
945
  }
903
946
  function latest(fn) {
@@ -1185,7 +1228,7 @@ function Show(props) {
1185
1228
  if (when) {
1186
1229
  const child = props.children;
1187
1230
  if (typeof child === "function" && child.length > 0) {
1188
- return child(() => when);
1231
+ return props.keyed ? child(when) : child(() => when);
1189
1232
  }
1190
1233
  return child;
1191
1234
  }
@@ -1205,7 +1248,7 @@ function Switch(props) {
1205
1248
  const w = conds[i].when;
1206
1249
  if (w) {
1207
1250
  const c = conds[i].children;
1208
- return typeof c === "function" && c.length > 0 ? c(() => w) : c;
1251
+ return typeof c === "function" && c.length > 0 ? conds[i].keyed ? c(w) : c(() => w) : c;
1209
1252
  }
1210
1253
  }
1211
1254
  return props.fallback;
@@ -1436,10 +1479,6 @@ Object.defineProperty(exports, "isWrappable", {
1436
1479
  enumerable: true,
1437
1480
  get: function () { return signals.isWrappable; }
1438
1481
  });
1439
- Object.defineProperty(exports, "merge", {
1440
- enumerable: true,
1441
- get: function () { return signals.merge; }
1442
- });
1443
1482
  Object.defineProperty(exports, "omit", {
1444
1483
  enumerable: true,
1445
1484
  get: function () { return signals.omit; }
@@ -1498,6 +1537,7 @@ exports.isRefreshing = isRefreshing;
1498
1537
  exports.latest = latest;
1499
1538
  exports.lazy = lazy;
1500
1539
  exports.mapArray = mapArray;
1540
+ exports.merge = merge;
1501
1541
  exports.onCleanup = onCleanup;
1502
1542
  exports.onSettled = onSettled;
1503
1543
  exports.reconcile = reconcile;
package/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
- import { NotReadyError, $REFRESH, isWrappable, NoOwnerError, ContextNotFoundError, flatten } from '@solidjs/signals';
2
- export { $PROXY, $REFRESH, $TRACK, NotReadyError, enableExternalSource, enforceLoadingBoundary, flatten, isEqual, isWrappable, merge, omit, snapshot, storePath } from '@solidjs/signals';
1
+ import { NotReadyError, $REFRESH, merge as merge$1, isWrappable, NoOwnerError, ContextNotFoundError, $PROXY, flatten } from '@solidjs/signals';
2
+ export { $PROXY, $REFRESH, $TRACK, NotReadyError, enableExternalSource, enforceLoadingBoundary, flatten, isEqual, isWrappable, omit, snapshot, storePath } from '@solidjs/signals';
3
3
 
4
4
  const NoHydrateContext = {
5
5
  id: Symbol("NoHydrateContext"),
@@ -31,6 +31,9 @@ function nextChildIdFor(owner, consume) {
31
31
  }
32
32
  throw new Error("Cannot get child id from owner without an id");
33
33
  }
34
+ function consumeClientComputedSlot(owner) {
35
+ if (owner?.id != null) nextChildIdFor(owner);
36
+ }
34
37
  function getNextChildId(owner) {
35
38
  return nextChildIdFor(owner);
36
39
  }
@@ -115,6 +118,7 @@ function disposeOwner(owner, self = true) {
115
118
  if (self) {
116
119
  node._disposed = true;
117
120
  if (ownerPool.length < OWNER_POOL_MAX) {
121
+ node.id = undefined;
118
122
  node._parent = null;
119
123
  node._nextSibling = null;
120
124
  ownerPool.push(node);
@@ -141,6 +145,7 @@ function disposeOwner(owner, self = true) {
141
145
  node._disposal = null;
142
146
  }
143
147
  if (self && ownerPool.length < OWNER_POOL_MAX) {
148
+ node.id = undefined;
144
149
  node._parent = null;
145
150
  node._nextSibling = null;
146
151
  ownerPool.push(node);
@@ -743,8 +748,43 @@ function reconcile(value) {
743
748
  function deep(store) {
744
749
  return store;
745
750
  }
751
+ function proxySource(read) {
752
+ return new Proxy({}, {
753
+ get(_, property, receiver) {
754
+ if (property === $PROXY) return receiver;
755
+ const source = read() || {};
756
+ return source[property];
757
+ },
758
+ has(_, property) {
759
+ if (property === $PROXY) return true;
760
+ return property in (read() || {});
761
+ },
762
+ ownKeys() {
763
+ return Object.keys(read() || {});
764
+ },
765
+ getOwnPropertyDescriptor(_, property) {
766
+ return {
767
+ configurable: true,
768
+ enumerable: true,
769
+ get() {
770
+ return (read() || {})[property];
771
+ }
772
+ };
773
+ }
774
+ });
775
+ }
776
+ function merge(...sources) {
777
+ for (let i = 0; i < sources.length; i++) {
778
+ if (typeof sources[i] === "function") {
779
+ sources[i] = proxySource(createMemo(sources[i]));
780
+ }
781
+ }
782
+ return merge$1(...sources);
783
+ }
746
784
  function mapArray(list, mapFn, options = {}) {
747
- return createMemo(() => {
785
+ const indexes = mapFn.length > 1;
786
+ const parent = currentOwner;
787
+ const read = createMemo(() => {
748
788
  const items = list();
749
789
  const s = [];
750
790
  if (items && items.length) {
@@ -757,7 +797,7 @@ function mapArray(list, mapFn, options = {}) {
757
797
  parent.id = formatChildId(origId, origChildCount + i);
758
798
  }
759
799
  parent._childCount = 0;
760
- s.push(mapFn(() => items[i], () => i));
800
+ s.push(options.keyed === false ? indexes ? mapFn(() => items[i], i) : mapFn(() => items[i]) : typeof options.keyed === "function" ? indexes ? mapFn(() => items[i], () => i) : mapFn(() => items[i]) : indexes ? mapFn(items[i], () => i) : mapFn(items[i]));
761
801
  }
762
802
  } finally {
763
803
  parent.id = origId;
@@ -771,9 +811,12 @@ function mapArray(list, mapFn, options = {}) {
771
811
  }, {
772
812
  sync: true
773
813
  });
814
+ consumeClientComputedSlot(parent);
815
+ return read;
774
816
  }
775
817
  function repeat(count, mapFn, options = {}) {
776
- return createMemo(() => {
818
+ const parent = currentOwner;
819
+ const read = createMemo(() => {
777
820
  const len = count();
778
821
  const offset = options.from?.() || 0;
779
822
  if (!len) {
@@ -801,6 +844,8 @@ function repeat(count, mapFn, options = {}) {
801
844
  }, {
802
845
  sync: true
803
846
  });
847
+ consumeClientComputedSlot(parent);
848
+ return read;
804
849
  }
805
850
  const ErrorContext = {
806
851
  id: Symbol("ErrorContext"),
@@ -837,8 +882,8 @@ function createErrorBoundary(fn, fallback) {
837
882
  };
838
883
  const renderFallback = err => ctx ? runWithOwner(parent, () => {
839
884
  const fallbackOwner = createOwner();
840
- return runWithOwner(fallbackOwner, () => fallback(err, () => {}));
841
- }) : fallback(err, () => {});
885
+ return runWithOwner(fallbackOwner, () => fallback(() => err, () => {}));
886
+ }) : fallback(() => err, () => {});
842
887
  const serializeError = err => {
843
888
  if (ctx && owner.id && !runWithOwner(owner, () => getContext(NoHydrateContext))) {
844
889
  ctx.serialize(owner.id, err);
@@ -888,15 +933,13 @@ function flush() {}
888
933
  function resolve(fn) {
889
934
  throw new Error("resolve is not implemented on the server");
890
935
  }
891
- function isPending(fn, fallback) {
936
+ function isPending(fn, loading) {
892
937
  try {
893
938
  fn();
894
939
  return false;
895
940
  } catch (err) {
896
- if (err instanceof NotReadyError && arguments.length > 1) {
897
- return fallback;
898
- }
899
- throw err;
941
+ if (!(err instanceof NotReadyError) || loading) throw err;
942
+ return false;
900
943
  }
901
944
  }
902
945
  function latest(fn) {
@@ -1184,7 +1227,7 @@ function Show(props) {
1184
1227
  if (when) {
1185
1228
  const child = props.children;
1186
1229
  if (typeof child === "function" && child.length > 0) {
1187
- return child(() => when);
1230
+ return props.keyed ? child(when) : child(() => when);
1188
1231
  }
1189
1232
  return child;
1190
1233
  }
@@ -1204,7 +1247,7 @@ function Switch(props) {
1204
1247
  const w = conds[i].when;
1205
1248
  if (w) {
1206
1249
  const c = conds[i].children;
1207
- return typeof c === "function" && c.length > 0 ? c(() => w) : c;
1250
+ return typeof c === "function" && c.length > 0 ? conds[i].keyed ? c(w) : c(() => w) : c;
1208
1251
  }
1209
1252
  }
1210
1253
  return props.fallback;
@@ -1399,4 +1442,4 @@ function Reveal(props) {
1399
1442
 
1400
1443
  const DEV = undefined;
1401
1444
 
1402
- export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getNextChildId, getObserver, getOwner, isDisposed, isPending, isRefreshing, latest, lazy, mapArray, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, sharedConfig, ssrHandleError, untrack, useContext };
1445
+ export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getNextChildId, getObserver, getOwner, isDisposed, isPending, isRefreshing, latest, lazy, mapArray, merge, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, sharedConfig, ssrHandleError, untrack, useContext };
package/dist/solid.cjs CHANGED
@@ -784,7 +784,7 @@ function Show(props) {
784
784
  if (c) {
785
785
  const child = props.children;
786
786
  const fn = typeof child === "function" && child.length > 0;
787
- return fn ? signals.untrack(() => child(() => {
787
+ return fn ? keyed ? signals.untrack(() => child(c), IS_DEV) : signals.untrack(() => child(() => {
788
788
  if (!signals.untrack(condition)) throw narrowedError("Show");
789
789
  return conditionValue();
790
790
  }), IS_DEV) : child;
@@ -808,7 +808,12 @@ function Switch(props) {
808
808
  equals: (a, b) => !a === !b,
809
809
  sync: true
810
810
  });
811
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
811
+ func = () => {
812
+ const prev = prevFunc();
813
+ if (prev) return prev;
814
+ const c = condition();
815
+ return c ? [index, c, conditionValue, mp] : undefined;
816
+ };
812
817
  }
813
818
  return func;
814
819
  }, {
@@ -817,10 +822,10 @@ function Switch(props) {
817
822
  return signals.createMemo(() => {
818
823
  const sel = switchFunc()();
819
824
  if (!sel) return props.fallback;
820
- const [index, conditionValue, mp] = sel;
825
+ const [index, value, conditionValue, mp] = sel;
821
826
  const child = mp.children;
822
827
  const fn = typeof child === "function" && child.length > 0;
823
- return fn ? signals.untrack(() => child(() => {
828
+ return fn ? mp.keyed ? signals.untrack(() => child(value), IS_DEV) : signals.untrack(() => child(() => {
824
829
  if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
825
830
  return conditionValue();
826
831
  }), IS_DEV) : child;
package/dist/solid.js CHANGED
@@ -783,7 +783,7 @@ function Show(props) {
783
783
  if (c) {
784
784
  const child = props.children;
785
785
  const fn = typeof child === "function" && child.length > 0;
786
- return fn ? untrack(() => child(() => {
786
+ return fn ? keyed ? untrack(() => child(c), IS_DEV) : untrack(() => child(() => {
787
787
  if (!untrack(condition)) throw narrowedError("Show");
788
788
  return conditionValue();
789
789
  }), IS_DEV) : child;
@@ -807,7 +807,12 @@ function Switch(props) {
807
807
  equals: (a, b) => !a === !b,
808
808
  sync: true
809
809
  });
810
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
810
+ func = () => {
811
+ const prev = prevFunc();
812
+ if (prev) return prev;
813
+ const c = condition();
814
+ return c ? [index, c, conditionValue, mp] : undefined;
815
+ };
811
816
  }
812
817
  return func;
813
818
  }, {
@@ -816,10 +821,10 @@ function Switch(props) {
816
821
  return createMemo$1(() => {
817
822
  const sel = switchFunc()();
818
823
  if (!sel) return props.fallback;
819
- const [index, conditionValue, mp] = sel;
824
+ const [index, value, conditionValue, mp] = sel;
820
825
  const child = mp.children;
821
826
  const fn = typeof child === "function" && child.length > 0;
822
- return fn ? untrack(() => child(() => {
827
+ return fn ? mp.keyed ? untrack(() => child(value), IS_DEV) : untrack(() => child(() => {
823
828
  if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
824
829
  return conditionValue();
825
830
  }), IS_DEV) : child;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "Reactive JavaScript library for building user interfaces. Compiles JSX to real DOM with fine-grained signal-based updates — no virtual DOM.",
4
- "version": "2.0.0-beta.11",
4
+ "version": "2.0.0-beta.13",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -107,7 +107,7 @@
107
107
  "performance"
108
108
  ],
109
109
  "dependencies": {
110
- "@solidjs/signals": "^2.0.0-beta.11",
110
+ "@solidjs/signals": "^2.0.0-beta.13",
111
111
  "csstype": "^3.1.0",
112
112
  "seroval": "~1.5.0",
113
113
  "seroval-plugins": "~1.5.0"