solid-js 1.7.0-beta.4 → 1.7.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.
package/dist/dev.cjs CHANGED
@@ -1400,6 +1400,7 @@ function createUniqueId() {
1400
1400
  return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1401
1401
  }
1402
1402
 
1403
+ const narrowedError = name => `Attempting to access a stale value from <${name}> that could possibly be undefined. This may occur because you are reading the accessor returned from the component at a time where it has already been unmounted. We recommend cleaning up any stale timers or async, or reading from the initial condition.` ;
1403
1404
  function For(props) {
1404
1405
  const fallback = "fallback" in props && {
1405
1406
  fallback: () => props.fallback
@@ -1427,7 +1428,10 @@ function Show(props) {
1427
1428
  if (c) {
1428
1429
  const child = props.children;
1429
1430
  const fn = typeof child === "function" && child.length > 0;
1430
- return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1431
+ return fn ? untrack(() => child(keyed ? c : () => {
1432
+ if (!untrack(condition)) throw narrowedError("Show");
1433
+ return props.when;
1434
+ })) : child;
1431
1435
  }
1432
1436
  return props.fallback;
1433
1437
  }, undefined, {
@@ -1458,7 +1462,10 @@ function Switch(props) {
1458
1462
  if (index < 0) return props.fallback;
1459
1463
  const c = cond.children;
1460
1464
  const fn = typeof c === "function" && c.length > 0;
1461
- return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1465
+ return fn ? untrack(() => c(keyed ? when : () => {
1466
+ if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1467
+ return cond.when;
1468
+ })) : c;
1462
1469
  }, undefined, {
1463
1470
  name: "value"
1464
1471
  } );
package/dist/dev.js CHANGED
@@ -1398,6 +1398,7 @@ function createUniqueId() {
1398
1398
  return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1399
1399
  }
1400
1400
 
1401
+ const narrowedError = name => `Attempting to access a stale value from <${name}> that could possibly be undefined. This may occur because you are reading the accessor returned from the component at a time where it has already been unmounted. We recommend cleaning up any stale timers or async, or reading from the initial condition.` ;
1401
1402
  function For(props) {
1402
1403
  const fallback = "fallback" in props && {
1403
1404
  fallback: () => props.fallback
@@ -1425,7 +1426,10 @@ function Show(props) {
1425
1426
  if (c) {
1426
1427
  const child = props.children;
1427
1428
  const fn = typeof child === "function" && child.length > 0;
1428
- return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1429
+ return fn ? untrack(() => child(keyed ? c : () => {
1430
+ if (!untrack(condition)) throw narrowedError("Show");
1431
+ return props.when;
1432
+ })) : child;
1429
1433
  }
1430
1434
  return props.fallback;
1431
1435
  }, undefined, {
@@ -1456,7 +1460,10 @@ function Switch(props) {
1456
1460
  if (index < 0) return props.fallback;
1457
1461
  const c = cond.children;
1458
1462
  const fn = typeof c === "function" && c.length > 0;
1459
- return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1463
+ return fn ? untrack(() => c(keyed ? when : () => {
1464
+ if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1465
+ return cond.when;
1466
+ })) : c;
1460
1467
  }, undefined, {
1461
1468
  name: "value"
1462
1469
  } );
package/dist/server.cjs CHANGED
@@ -601,9 +601,9 @@ function Suspense(props) {
601
601
  });
602
602
  function suspenseError(err) {
603
603
  if (!done || !done(undefined, err)) {
604
- if (o) runWithOwner(o.owner, () => {
604
+ runWithOwner(o.owner, () => {
605
605
  throw err;
606
- });else throw err;
606
+ });
607
607
  }
608
608
  }
609
609
  function runSuspense() {
@@ -611,7 +611,7 @@ function Suspense(props) {
611
611
  ...ctx,
612
612
  count: 0
613
613
  });
614
- o && cleanNode(o);
614
+ cleanNode(o);
615
615
  return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
616
616
  value,
617
617
  get children() {
package/dist/server.js CHANGED
@@ -599,9 +599,9 @@ function Suspense(props) {
599
599
  });
600
600
  function suspenseError(err) {
601
601
  if (!done || !done(undefined, err)) {
602
- if (o) runWithOwner(o.owner, () => {
602
+ runWithOwner(o.owner, () => {
603
603
  throw err;
604
- });else throw err;
604
+ });
605
605
  }
606
606
  }
607
607
  function runSuspense() {
@@ -609,7 +609,7 @@ function Suspense(props) {
609
609
  ...ctx,
610
610
  count: 0
611
611
  });
612
- o && cleanNode(o);
612
+ cleanNode(o);
613
613
  return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
614
614
  value,
615
615
  get children() {
package/dist/solid.cjs CHANGED
@@ -1353,6 +1353,7 @@ function createUniqueId() {
1353
1353
  return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1354
1354
  }
1355
1355
 
1356
+ const narrowedError = name => `Stale read from <${name}>.`;
1356
1357
  function For(props) {
1357
1358
  const fallback = "fallback" in props && {
1358
1359
  fallback: () => props.fallback
@@ -1375,7 +1376,10 @@ function Show(props) {
1375
1376
  if (c) {
1376
1377
  const child = props.children;
1377
1378
  const fn = typeof child === "function" && child.length > 0;
1378
- return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1379
+ return fn ? untrack(() => child(keyed ? c : () => {
1380
+ if (!untrack(condition)) throw narrowedError("Show");
1381
+ return props.when;
1382
+ })) : child;
1379
1383
  }
1380
1384
  return props.fallback;
1381
1385
  }, undefined, undefined);
@@ -1403,7 +1407,10 @@ function Switch(props) {
1403
1407
  if (index < 0) return props.fallback;
1404
1408
  const c = cond.children;
1405
1409
  const fn = typeof c === "function" && c.length > 0;
1406
- return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1410
+ return fn ? untrack(() => c(keyed ? when : () => {
1411
+ if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1412
+ return cond.when;
1413
+ })) : c;
1407
1414
  }, undefined, undefined);
1408
1415
  }
1409
1416
  function Match(props) {
package/dist/solid.js CHANGED
@@ -1351,6 +1351,7 @@ function createUniqueId() {
1351
1351
  return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
1352
1352
  }
1353
1353
 
1354
+ const narrowedError = name => `Stale read from <${name}>.`;
1354
1355
  function For(props) {
1355
1356
  const fallback = "fallback" in props && {
1356
1357
  fallback: () => props.fallback
@@ -1373,7 +1374,10 @@ function Show(props) {
1373
1374
  if (c) {
1374
1375
  const child = props.children;
1375
1376
  const fn = typeof child === "function" && child.length > 0;
1376
- return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1377
+ return fn ? untrack(() => child(keyed ? c : () => {
1378
+ if (!untrack(condition)) throw narrowedError("Show");
1379
+ return props.when;
1380
+ })) : child;
1377
1381
  }
1378
1382
  return props.fallback;
1379
1383
  }, undefined, undefined);
@@ -1401,7 +1405,10 @@ function Switch(props) {
1401
1405
  if (index < 0) return props.fallback;
1402
1406
  const c = cond.children;
1403
1407
  const fn = typeof c === "function" && c.length > 0;
1404
- return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1408
+ return fn ? untrack(() => c(keyed ? when : () => {
1409
+ if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
1410
+ return cond.when;
1411
+ })) : c;
1405
1412
  }, undefined, undefined);
1406
1413
  }
1407
1414
  function Match(props) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.7.0-beta.4",
4
+ "version": "1.7.0",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -279,8 +279,8 @@
279
279
  "types:universal": "tsc --project ./universal/tsconfig.json && ncp ../../node_modules/dom-expressions/src/universal.d.ts ./universal/types/universal.d.ts",
280
280
  "bench": "node --allow-natives-syntax bench/bench.cjs",
281
281
  "link": "symlink-dir . node_modules/solid-js",
282
- "test": "jest",
283
- "coverage": "jest --coverage",
282
+ "test": "vitest run",
283
+ "coverage": "vitest run --coverage",
284
284
  "test-types": "tsc --project tsconfig.test.json"
285
285
  }
286
286
  }
package/types/jsx.d.ts CHANGED
@@ -847,13 +847,13 @@ export namespace JSX {
847
847
  allow?: string;
848
848
  allowfullscreen?: boolean;
849
849
  height?: number | string;
850
+ loading?: "eager" | "lazy";
850
851
  name?: string;
851
852
  referrerpolicy?: HTMLReferrerPolicy;
852
853
  sandbox?: HTMLIframeSandbox | string;
853
854
  src?: string;
854
855
  srcdoc?: string;
855
856
  width?: number | string;
856
- loading?: "eager" | "lazy";
857
857
  referrerPolicy?: HTMLReferrerPolicy;
858
858
  }
859
859
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -879,6 +879,7 @@ export namespace JSX {
879
879
  accept?: string;
880
880
  alt?: string;
881
881
  autocomplete?: string;
882
+ autocorrect?: "on" | "off";
882
883
  autofocus?: boolean;
883
884
  capture?: boolean | string;
884
885
  checked?: boolean;
@@ -892,6 +893,7 @@ export namespace JSX {
892
893
  formnovalidate?: boolean;
893
894
  formtarget?: string;
894
895
  height?: number | string;
896
+ incremental?: boolean;
895
897
  list?: string;
896
898
  max?: number | string;
897
899
  maxlength?: number | string;
@@ -902,6 +904,7 @@ export namespace JSX {
902
904
  pattern?: string;
903
905
  placeholder?: string;
904
906
  readonly?: boolean;
907
+ results?: number;
905
908
  required?: boolean;
906
909
  size?: number | string;
907
910
  src?: string;
package/web/dist/dev.cjs CHANGED
@@ -581,15 +581,13 @@ function Portal(props) {
581
581
  return () => s() && props.children;
582
582
  } else return () => props.children;
583
583
  }
584
- solidJs.createRenderEffect(() => {
584
+ solidJs.createEffect(() => {
585
585
  const el = mount();
586
586
  if (el instanceof HTMLHeadElement) {
587
587
  const [clean, setClean] = solidJs.createSignal(false);
588
588
  const cleanup = () => setClean(true);
589
589
  solidJs.createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
590
- solidJs.onCleanup(() => {
591
- if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
592
- });
590
+ solidJs.onCleanup(cleanup);
593
591
  } else {
594
592
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
595
593
  renderRoot = useShadow && container.attachShadow ? container.attachShadow({
package/web/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, createEffect, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, mergeProps, untrack } 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"];
@@ -580,15 +580,13 @@ function Portal(props) {
580
580
  return () => s() && props.children;
581
581
  } else return () => props.children;
582
582
  }
583
- createRenderEffect(() => {
583
+ createEffect(() => {
584
584
  const el = mount();
585
585
  if (el instanceof HTMLHeadElement) {
586
586
  const [clean, setClean] = createSignal(false);
587
587
  const cleanup = () => setClean(true);
588
588
  createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
589
- onCleanup(() => {
590
- if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
591
- });
589
+ onCleanup(cleanup);
592
590
  } else {
593
591
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
594
592
  renderRoot = useShadow && container.attachShadow ? container.attachShadow({
package/web/dist/web.cjs CHANGED
@@ -581,15 +581,13 @@ function Portal(props) {
581
581
  return () => s() && props.children;
582
582
  } else return () => props.children;
583
583
  }
584
- solidJs.createRenderEffect(() => {
584
+ solidJs.createEffect(() => {
585
585
  const el = mount();
586
586
  if (el instanceof HTMLHeadElement) {
587
587
  const [clean, setClean] = solidJs.createSignal(false);
588
588
  const cleanup = () => setClean(true);
589
589
  solidJs.createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
590
- solidJs.onCleanup(() => {
591
- if (solidJs.sharedConfig.context) queueMicrotask(cleanup);else cleanup();
592
- });
590
+ solidJs.onCleanup(cleanup);
593
591
  } else {
594
592
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
595
593
  renderRoot = useShadow && container.attachShadow ? container.attachShadow({
package/web/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, createEffect, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
2
2
  export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, mergeProps, untrack } 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"];
@@ -580,15 +580,13 @@ function Portal(props) {
580
580
  return () => s() && props.children;
581
581
  } else return () => props.children;
582
582
  }
583
- createRenderEffect(() => {
583
+ createEffect(() => {
584
584
  const el = mount();
585
585
  if (el instanceof HTMLHeadElement) {
586
586
  const [clean, setClean] = createSignal(false);
587
587
  const cleanup = () => setClean(true);
588
588
  createRoot(dispose => insert(el, () => !clean() ? content() : dispose(), null));
589
- onCleanup(() => {
590
- if (sharedConfig.context) queueMicrotask(cleanup);else cleanup();
591
- });
589
+ onCleanup(cleanup);
592
590
  } else {
593
591
  const container = createElement(props.isSVG ? "g" : "div", props.isSVG),
594
592
  renderRoot = useShadow && container.attachShadow ? container.attachShadow({