solid-js 1.7.0-beta.3 → 1.7.0-beta.4

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
@@ -116,7 +116,10 @@ function workLoop(hasTimeRemaining, initialTime) {
116
116
  return currentTask !== null;
117
117
  }
118
118
 
119
- const sharedConfig = {};
119
+ const sharedConfig = {
120
+ context: undefined,
121
+ registry: undefined
122
+ };
120
123
  function setHydrateContext(context) {
121
124
  sharedConfig.context = context;
122
125
  }
@@ -606,8 +609,8 @@ function enableExternalSource(factory) {
606
609
  }
607
610
  function readSignal() {
608
611
  const runningTransition = Transition && Transition.running;
609
- if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
610
- if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
612
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
613
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
611
614
  const updates = Updates;
612
615
  Updates = null;
613
616
  runUpdates(() => lookUpstream(this), false);
@@ -651,11 +654,11 @@ function writeSignal(node, value, isComp) {
651
654
  const o = node.observers[i];
652
655
  const TransitionRunning = Transition && Transition.running;
653
656
  if (TransitionRunning && Transition.disposed.has(o)) continue;
654
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
657
+ if (TransitionRunning ? !o.tState : !o.state) {
655
658
  if (o.pure) Updates.push(o);else Effects.push(o);
656
659
  if (o.observers) markDownstream(o);
657
660
  }
658
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
661
+ if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
659
662
  }
660
663
  if (Updates.length > 10e5) {
661
664
  Updates = [];
@@ -761,13 +764,13 @@ function createComputation(fn, init, pure, state = STALE, options) {
761
764
  }
762
765
  function runTop(node) {
763
766
  const runningTransition = Transition && Transition.running;
764
- if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
765
- if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookUpstream(node);
767
+ if ((runningTransition ? node.tState : node.state) === 0) return;
768
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
766
769
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
767
770
  const ancestors = [node];
768
771
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
769
772
  if (runningTransition && Transition.disposed.has(node)) return;
770
- if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
773
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
771
774
  }
772
775
  for (let i = ancestors.length - 1; i >= 0; i--) {
773
776
  node = ancestors[i];
@@ -778,9 +781,9 @@ function runTop(node) {
778
781
  if (Transition.disposed.has(top)) return;
779
782
  }
780
783
  }
781
- if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
784
+ if ((runningTransition ? node.tState : node.state) === STALE) {
782
785
  updateComputation(node);
783
- } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
786
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
784
787
  const updates = Updates;
785
788
  Updates = null;
786
789
  runUpdates(() => lookUpstream(node, ancestors[0]), false);
@@ -885,9 +888,10 @@ function lookUpstream(node, ignore) {
885
888
  for (let i = 0; i < node.sources.length; i += 1) {
886
889
  const source = node.sources[i];
887
890
  if (source.sources) {
888
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
891
+ const state = runningTransition ? source.tState : source.state;
892
+ if (state === STALE) {
889
893
  if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
890
- } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
894
+ } else if (state === PENDING) lookUpstream(source, ignore);
891
895
  }
892
896
  }
893
897
  }
@@ -895,7 +899,7 @@ function markDownstream(node) {
895
899
  const runningTransition = Transition && Transition.running;
896
900
  for (let i = 0; i < node.observers.length; i += 1) {
897
901
  const o = node.observers[i];
898
- if (!runningTransition && !o.state || runningTransition && !o.tState) {
902
+ if (runningTransition ? !o.tState : !o.state) {
899
903
  if (runningTransition) o.tState = PENDING;else o.state = PENDING;
900
904
  if (o.pure) Updates.push(o);else Effects.push(o);
901
905
  o.observers && markDownstream(o);
@@ -1423,10 +1427,7 @@ function Show(props) {
1423
1427
  if (c) {
1424
1428
  const child = props.children;
1425
1429
  const fn = typeof child === "function" && child.length > 0;
1426
- return fn ? untrack(() => child(keyed ? c : () => {
1427
- if (true && !untrack(condition)) console.warn("Accessing stale value from Show.");
1428
- return props.when;
1429
- })) : child;
1430
+ return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1430
1431
  }
1431
1432
  return props.fallback;
1432
1433
  }, undefined, {
@@ -1457,10 +1458,7 @@ function Switch(props) {
1457
1458
  if (index < 0) return props.fallback;
1458
1459
  const c = cond.children;
1459
1460
  const fn = typeof c === "function" && c.length > 0;
1460
- return fn ? untrack(() => c(keyed ? when : () => {
1461
- if (true && untrack(evalConditions)[0] !== index) console.warn("Accessing stale value from Match.");
1462
- return cond.when;
1463
- })) : c;
1461
+ return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1464
1462
  }, undefined, {
1465
1463
  name: "value"
1466
1464
  } );
package/dist/dev.js CHANGED
@@ -114,7 +114,10 @@ function workLoop(hasTimeRemaining, initialTime) {
114
114
  return currentTask !== null;
115
115
  }
116
116
 
117
- const sharedConfig = {};
117
+ const sharedConfig = {
118
+ context: undefined,
119
+ registry: undefined
120
+ };
118
121
  function setHydrateContext(context) {
119
122
  sharedConfig.context = context;
120
123
  }
@@ -604,8 +607,8 @@ function enableExternalSource(factory) {
604
607
  }
605
608
  function readSignal() {
606
609
  const runningTransition = Transition && Transition.running;
607
- if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
608
- if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
610
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
611
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
609
612
  const updates = Updates;
610
613
  Updates = null;
611
614
  runUpdates(() => lookUpstream(this), false);
@@ -649,11 +652,11 @@ function writeSignal(node, value, isComp) {
649
652
  const o = node.observers[i];
650
653
  const TransitionRunning = Transition && Transition.running;
651
654
  if (TransitionRunning && Transition.disposed.has(o)) continue;
652
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
655
+ if (TransitionRunning ? !o.tState : !o.state) {
653
656
  if (o.pure) Updates.push(o);else Effects.push(o);
654
657
  if (o.observers) markDownstream(o);
655
658
  }
656
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
659
+ if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
657
660
  }
658
661
  if (Updates.length > 10e5) {
659
662
  Updates = [];
@@ -759,13 +762,13 @@ function createComputation(fn, init, pure, state = STALE, options) {
759
762
  }
760
763
  function runTop(node) {
761
764
  const runningTransition = Transition && Transition.running;
762
- if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
763
- if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookUpstream(node);
765
+ if ((runningTransition ? node.tState : node.state) === 0) return;
766
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
764
767
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
765
768
  const ancestors = [node];
766
769
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
767
770
  if (runningTransition && Transition.disposed.has(node)) return;
768
- if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
771
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
769
772
  }
770
773
  for (let i = ancestors.length - 1; i >= 0; i--) {
771
774
  node = ancestors[i];
@@ -776,9 +779,9 @@ function runTop(node) {
776
779
  if (Transition.disposed.has(top)) return;
777
780
  }
778
781
  }
779
- if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
782
+ if ((runningTransition ? node.tState : node.state) === STALE) {
780
783
  updateComputation(node);
781
- } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
784
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
782
785
  const updates = Updates;
783
786
  Updates = null;
784
787
  runUpdates(() => lookUpstream(node, ancestors[0]), false);
@@ -883,9 +886,10 @@ function lookUpstream(node, ignore) {
883
886
  for (let i = 0; i < node.sources.length; i += 1) {
884
887
  const source = node.sources[i];
885
888
  if (source.sources) {
886
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
889
+ const state = runningTransition ? source.tState : source.state;
890
+ if (state === STALE) {
887
891
  if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
888
- } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
892
+ } else if (state === PENDING) lookUpstream(source, ignore);
889
893
  }
890
894
  }
891
895
  }
@@ -893,7 +897,7 @@ function markDownstream(node) {
893
897
  const runningTransition = Transition && Transition.running;
894
898
  for (let i = 0; i < node.observers.length; i += 1) {
895
899
  const o = node.observers[i];
896
- if (!runningTransition && !o.state || runningTransition && !o.tState) {
900
+ if (runningTransition ? !o.tState : !o.state) {
897
901
  if (runningTransition) o.tState = PENDING;else o.state = PENDING;
898
902
  if (o.pure) Updates.push(o);else Effects.push(o);
899
903
  o.observers && markDownstream(o);
@@ -1421,10 +1425,7 @@ function Show(props) {
1421
1425
  if (c) {
1422
1426
  const child = props.children;
1423
1427
  const fn = typeof child === "function" && child.length > 0;
1424
- return fn ? untrack(() => child(keyed ? c : () => {
1425
- if (true && !untrack(condition)) console.warn("Accessing stale value from Show.");
1426
- return props.when;
1427
- })) : child;
1428
+ return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1428
1429
  }
1429
1430
  return props.fallback;
1430
1431
  }, undefined, {
@@ -1455,10 +1456,7 @@ function Switch(props) {
1455
1456
  if (index < 0) return props.fallback;
1456
1457
  const c = cond.children;
1457
1458
  const fn = typeof c === "function" && c.length > 0;
1458
- return fn ? untrack(() => c(keyed ? when : () => {
1459
- if (true && untrack(evalConditions)[0] !== index) console.warn("Accessing stale value from Match.");
1460
- return cond.when;
1461
- })) : c;
1459
+ return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1462
1460
  }, undefined, {
1463
1461
  name: "value"
1464
1462
  } );
package/dist/solid.cjs CHANGED
@@ -116,7 +116,10 @@ function workLoop(hasTimeRemaining, initialTime) {
116
116
  return currentTask !== null;
117
117
  }
118
118
 
119
- const sharedConfig = {};
119
+ const sharedConfig = {
120
+ context: undefined,
121
+ registry: undefined
122
+ };
120
123
  function setHydrateContext(context) {
121
124
  sharedConfig.context = context;
122
125
  }
@@ -568,8 +571,8 @@ function enableExternalSource(factory) {
568
571
  }
569
572
  function readSignal() {
570
573
  const runningTransition = Transition && Transition.running;
571
- if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
572
- if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
574
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
575
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
573
576
  const updates = Updates;
574
577
  Updates = null;
575
578
  runUpdates(() => lookUpstream(this), false);
@@ -613,11 +616,11 @@ function writeSignal(node, value, isComp) {
613
616
  const o = node.observers[i];
614
617
  const TransitionRunning = Transition && Transition.running;
615
618
  if (TransitionRunning && Transition.disposed.has(o)) continue;
616
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
619
+ if (TransitionRunning ? !o.tState : !o.state) {
617
620
  if (o.pure) Updates.push(o);else Effects.push(o);
618
621
  if (o.observers) markDownstream(o);
619
622
  }
620
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
623
+ if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
621
624
  }
622
625
  if (Updates.length > 10e5) {
623
626
  Updates = [];
@@ -721,13 +724,13 @@ function createComputation(fn, init, pure, state = STALE, options) {
721
724
  }
722
725
  function runTop(node) {
723
726
  const runningTransition = Transition && Transition.running;
724
- if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
725
- if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookUpstream(node);
727
+ if ((runningTransition ? node.tState : node.state) === 0) return;
728
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
726
729
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
727
730
  const ancestors = [node];
728
731
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
729
732
  if (runningTransition && Transition.disposed.has(node)) return;
730
- if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
733
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
731
734
  }
732
735
  for (let i = ancestors.length - 1; i >= 0; i--) {
733
736
  node = ancestors[i];
@@ -738,9 +741,9 @@ function runTop(node) {
738
741
  if (Transition.disposed.has(top)) return;
739
742
  }
740
743
  }
741
- if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
744
+ if ((runningTransition ? node.tState : node.state) === STALE) {
742
745
  updateComputation(node);
743
- } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
746
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
744
747
  const updates = Updates;
745
748
  Updates = null;
746
749
  runUpdates(() => lookUpstream(node, ancestors[0]), false);
@@ -845,9 +848,10 @@ function lookUpstream(node, ignore) {
845
848
  for (let i = 0; i < node.sources.length; i += 1) {
846
849
  const source = node.sources[i];
847
850
  if (source.sources) {
848
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
851
+ const state = runningTransition ? source.tState : source.state;
852
+ if (state === STALE) {
849
853
  if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
850
- } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
854
+ } else if (state === PENDING) lookUpstream(source, ignore);
851
855
  }
852
856
  }
853
857
  }
@@ -855,7 +859,7 @@ function markDownstream(node) {
855
859
  const runningTransition = Transition && Transition.running;
856
860
  for (let i = 0; i < node.observers.length; i += 1) {
857
861
  const o = node.observers[i];
858
- if (!runningTransition && !o.state || runningTransition && !o.tState) {
862
+ if (runningTransition ? !o.tState : !o.state) {
859
863
  if (runningTransition) o.tState = PENDING;else o.state = PENDING;
860
864
  if (o.pure) Updates.push(o);else Effects.push(o);
861
865
  o.observers && markDownstream(o);
@@ -1371,10 +1375,7 @@ function Show(props) {
1371
1375
  if (c) {
1372
1376
  const child = props.children;
1373
1377
  const fn = typeof child === "function" && child.length > 0;
1374
- return fn ? untrack(() => child(keyed ? c : () => {
1375
- if (false && !untrack(condition)) ;
1376
- return props.when;
1377
- })) : child;
1378
+ return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1378
1379
  }
1379
1380
  return props.fallback;
1380
1381
  }, undefined, undefined);
@@ -1402,10 +1403,7 @@ function Switch(props) {
1402
1403
  if (index < 0) return props.fallback;
1403
1404
  const c = cond.children;
1404
1405
  const fn = typeof c === "function" && c.length > 0;
1405
- return fn ? untrack(() => c(keyed ? when : () => {
1406
- if (false && untrack(evalConditions)[0] !== index) ;
1407
- return cond.when;
1408
- })) : c;
1406
+ return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1409
1407
  }, undefined, undefined);
1410
1408
  }
1411
1409
  function Match(props) {
package/dist/solid.js CHANGED
@@ -114,7 +114,10 @@ function workLoop(hasTimeRemaining, initialTime) {
114
114
  return currentTask !== null;
115
115
  }
116
116
 
117
- const sharedConfig = {};
117
+ const sharedConfig = {
118
+ context: undefined,
119
+ registry: undefined
120
+ };
118
121
  function setHydrateContext(context) {
119
122
  sharedConfig.context = context;
120
123
  }
@@ -566,8 +569,8 @@ function enableExternalSource(factory) {
566
569
  }
567
570
  function readSignal() {
568
571
  const runningTransition = Transition && Transition.running;
569
- if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
570
- if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
572
+ if (this.sources && (runningTransition ? this.tState : this.state)) {
573
+ if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
571
574
  const updates = Updates;
572
575
  Updates = null;
573
576
  runUpdates(() => lookUpstream(this), false);
@@ -611,11 +614,11 @@ function writeSignal(node, value, isComp) {
611
614
  const o = node.observers[i];
612
615
  const TransitionRunning = Transition && Transition.running;
613
616
  if (TransitionRunning && Transition.disposed.has(o)) continue;
614
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
617
+ if (TransitionRunning ? !o.tState : !o.state) {
615
618
  if (o.pure) Updates.push(o);else Effects.push(o);
616
619
  if (o.observers) markDownstream(o);
617
620
  }
618
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
621
+ if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
619
622
  }
620
623
  if (Updates.length > 10e5) {
621
624
  Updates = [];
@@ -719,13 +722,13 @@ function createComputation(fn, init, pure, state = STALE, options) {
719
722
  }
720
723
  function runTop(node) {
721
724
  const runningTransition = Transition && Transition.running;
722
- if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return;
723
- if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) return lookUpstream(node);
725
+ if ((runningTransition ? node.tState : node.state) === 0) return;
726
+ if ((runningTransition ? node.tState : node.state) === PENDING) return lookUpstream(node);
724
727
  if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
725
728
  const ancestors = [node];
726
729
  while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
727
730
  if (runningTransition && Transition.disposed.has(node)) return;
728
- if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node);
731
+ if (runningTransition ? node.tState : node.state) ancestors.push(node);
729
732
  }
730
733
  for (let i = ancestors.length - 1; i >= 0; i--) {
731
734
  node = ancestors[i];
@@ -736,9 +739,9 @@ function runTop(node) {
736
739
  if (Transition.disposed.has(top)) return;
737
740
  }
738
741
  }
739
- if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) {
742
+ if ((runningTransition ? node.tState : node.state) === STALE) {
740
743
  updateComputation(node);
741
- } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
744
+ } else if ((runningTransition ? node.tState : node.state) === PENDING) {
742
745
  const updates = Updates;
743
746
  Updates = null;
744
747
  runUpdates(() => lookUpstream(node, ancestors[0]), false);
@@ -843,9 +846,10 @@ function lookUpstream(node, ignore) {
843
846
  for (let i = 0; i < node.sources.length; i += 1) {
844
847
  const source = node.sources[i];
845
848
  if (source.sources) {
846
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
849
+ const state = runningTransition ? source.tState : source.state;
850
+ if (state === STALE) {
847
851
  if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
848
- } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore);
852
+ } else if (state === PENDING) lookUpstream(source, ignore);
849
853
  }
850
854
  }
851
855
  }
@@ -853,7 +857,7 @@ function markDownstream(node) {
853
857
  const runningTransition = Transition && Transition.running;
854
858
  for (let i = 0; i < node.observers.length; i += 1) {
855
859
  const o = node.observers[i];
856
- if (!runningTransition && !o.state || runningTransition && !o.tState) {
860
+ if (runningTransition ? !o.tState : !o.state) {
857
861
  if (runningTransition) o.tState = PENDING;else o.state = PENDING;
858
862
  if (o.pure) Updates.push(o);else Effects.push(o);
859
863
  o.observers && markDownstream(o);
@@ -1369,10 +1373,7 @@ function Show(props) {
1369
1373
  if (c) {
1370
1374
  const child = props.children;
1371
1375
  const fn = typeof child === "function" && child.length > 0;
1372
- return fn ? untrack(() => child(keyed ? c : () => {
1373
- if (false && !untrack(condition)) ;
1374
- return props.when;
1375
- })) : child;
1376
+ return fn ? untrack(() => child(keyed ? c : createMemo(p => condition() ? props.when : p))) : child;
1376
1377
  }
1377
1378
  return props.fallback;
1378
1379
  }, undefined, undefined);
@@ -1400,10 +1401,7 @@ function Switch(props) {
1400
1401
  if (index < 0) return props.fallback;
1401
1402
  const c = cond.children;
1402
1403
  const fn = typeof c === "function" && c.length > 0;
1403
- return fn ? untrack(() => c(keyed ? when : () => {
1404
- if (false && untrack(evalConditions)[0] !== index) ;
1405
- return cond.when;
1406
- })) : c;
1404
+ return fn ? untrack(() => c(keyed ? when : createMemo(p => evalConditions()[0] === index ? cond.when : p))) : c;
1407
1405
  }, undefined, undefined);
1408
1406
  }
1409
1407
  function Match(props) {
@@ -763,6 +763,7 @@ export namespace JSX {
763
763
  src?: FunctionMaybe<string>;
764
764
  srcdoc?: FunctionMaybe<string>;
765
765
  width?: FunctionMaybe<number | string>;
766
+ loading?: FunctionMaybe<"eager" | "lazy">;
766
767
  referrerPolicy?: FunctionMaybe<HTMLReferrerPolicy>;
767
768
  }
768
769
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
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.3",
4
+ "version": "1.7.0-beta.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
package/types/jsx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as csstype from 'csstype';
1
+ import * as csstype from "csstype";
2
2
 
3
3
  /**
4
4
  * Based on JSX types for Surplus and Inferno and adapted for `dom-expressions`.
@@ -9,14 +9,7 @@ import * as csstype from 'csstype';
9
9
  type DOMElement = Element;
10
10
 
11
11
  export namespace JSX {
12
- type Element =
13
- | Node
14
- | ArrayElement
15
- | (string & {})
16
- | number
17
- | boolean
18
- | null
19
- | undefined;
12
+ type Element = Node | ArrayElement | (string & {}) | number | boolean | null | undefined;
20
13
  interface ArrayElement extends Array<Element> {}
21
14
  interface ElementClass {
22
15
  // empty, libs can define requirements downstream
@@ -46,6 +39,85 @@ export namespace JSX {
46
39
  1: any;
47
40
  }
48
41
  type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
42
+
43
+ interface InputEventHandler<T, E extends InputEvent> {
44
+ (
45
+ e: E & {
46
+ currentTarget: T;
47
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
48
+ ? T
49
+ : DOMElement;
50
+ }
51
+ ): void;
52
+ }
53
+ interface BoundInputEventHandler<T, E extends InputEvent> {
54
+ 0: (
55
+ data: any,
56
+ e: E & {
57
+ currentTarget: T;
58
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
59
+ ? T
60
+ : DOMElement;
61
+ }
62
+ ) => void;
63
+ 1: any;
64
+ }
65
+ type InputEventHandlerUnion<T, E extends InputEvent> =
66
+ | InputEventHandler<T, E>
67
+ | BoundInputEventHandler<T, E>;
68
+
69
+ interface ChangeEventHandler<T, E extends Event> {
70
+ (
71
+ e: E & {
72
+ currentTarget: T;
73
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
74
+ ? T
75
+ : DOMElement;
76
+ }
77
+ ): void;
78
+ }
79
+ interface BoundChangeEventHandler<T, E extends Event> {
80
+ 0: (
81
+ data: any,
82
+ e: E & {
83
+ currentTarget: T;
84
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
85
+ ? T
86
+ : DOMElement;
87
+ }
88
+ ) => void;
89
+ 1: any;
90
+ }
91
+ type ChangeEventHandlerUnion<T, E extends Event> =
92
+ | ChangeEventHandler<T, E>
93
+ | BoundChangeEventHandler<T, E>;
94
+
95
+ interface FocusEventHandler<T, E extends FocusEvent> {
96
+ (
97
+ e: E & {
98
+ currentTarget: T;
99
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
100
+ ? T
101
+ : DOMElement;
102
+ }
103
+ ): void;
104
+ }
105
+ interface BoundFocusEventHandler<T, E extends FocusEvent> {
106
+ 0: (
107
+ data: any,
108
+ e: E & {
109
+ currentTarget: T;
110
+ target: T extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
111
+ ? T
112
+ : DOMElement;
113
+ }
114
+ ) => void;
115
+ 1: any;
116
+ }
117
+ type FocusEventHandlerUnion<T, E extends FocusEvent> =
118
+ | FocusEventHandler<T, E>
119
+ | BoundFocusEventHandler<T, E>;
120
+
49
121
  interface IntrinsicAttributes {
50
122
  ref?: unknown | ((e: unknown) => void);
51
123
  }
@@ -56,7 +128,7 @@ export namespace JSX {
56
128
  };
57
129
  $ServerOnly?: boolean;
58
130
  }
59
- type Accessor<T> = () => T
131
+ type Accessor<T> = () => T;
60
132
  interface Directives {}
61
133
  interface DirectiveFunctions {
62
134
  [x: string]: (el: Element, accessor: Accessor<any>) => void;
@@ -69,7 +141,9 @@ export namespace JSX {
69
141
  [Key in keyof Directives as `use:${Key}`]?: Directives[Key];
70
142
  };
71
143
  type DirectiveFunctionAttributes<T> = {
72
- [K in keyof DirectiveFunctions as string extends K ? never : `use:${K}`]?: DirectiveFunctions[K] extends (
144
+ [K in keyof DirectiveFunctions as string extends K
145
+ ? never
146
+ : `use:${K}`]?: DirectiveFunctions[K] extends (
73
147
  el: infer E, // will be unknown if not provided
74
148
  ...rest: infer R // use rest so that we can check whether it's provided or not
75
149
  ) => void
@@ -90,13 +164,23 @@ export namespace JSX {
90
164
  };
91
165
  type OnAttributes<T> = {
92
166
  [Key in keyof CustomEvents as `on:${Key}`]?: EventHandler<T, CustomEvents[Key]>;
93
- }
167
+ };
94
168
  type OnCaptureAttributes<T> = {
95
- [Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<T, CustomCaptureEvents[Key]>;
96
- }
97
- interface DOMAttributes<T> extends CustomAttributes<T>, DirectiveAttributes, DirectiveFunctionAttributes<T>,
98
- PropAttributes, AttrAttributes, OnAttributes<T>, OnCaptureAttributes<T>,
99
- CustomEventHandlersCamelCase<T>, CustomEventHandlersLowerCase<T> {
169
+ [Key in keyof CustomCaptureEvents as `oncapture:${Key}`]?: EventHandler<
170
+ T,
171
+ CustomCaptureEvents[Key]
172
+ >;
173
+ };
174
+ interface DOMAttributes<T>
175
+ extends CustomAttributes<T>,
176
+ DirectiveAttributes,
177
+ DirectiveFunctionAttributes<T>,
178
+ PropAttributes,
179
+ AttrAttributes,
180
+ OnAttributes<T>,
181
+ OnCaptureAttributes<T>,
182
+ CustomEventHandlersCamelCase<T>,
183
+ CustomEventHandlersLowerCase<T> {
100
184
  children?: Element;
101
185
  innerHTML?: string;
102
186
  innerText?: string | number;
@@ -108,8 +192,8 @@ export namespace JSX {
108
192
  onCompositionEnd?: EventHandlerUnion<T, CompositionEvent>;
109
193
  onCompositionStart?: EventHandlerUnion<T, CompositionEvent>;
110
194
  onCompositionUpdate?: EventHandlerUnion<T, CompositionEvent>;
111
- onFocusOut?: EventHandlerUnion<T, FocusEvent>;
112
- onFocusIn?: EventHandlerUnion<T, FocusEvent>;
195
+ onFocusOut?: FocusEventHandlerUnion<T, FocusEvent>;
196
+ onFocusIn?: FocusEventHandlerUnion<T, FocusEvent>;
113
197
  onEncrypted?: EventHandlerUnion<T, Event>;
114
198
  onDragExit?: EventHandlerUnion<T, DragEvent>;
115
199
  // lower case events
@@ -119,8 +203,8 @@ export namespace JSX {
119
203
  oncompositionend?: EventHandlerUnion<T, CompositionEvent>;
120
204
  oncompositionstart?: EventHandlerUnion<T, CompositionEvent>;
121
205
  oncompositionupdate?: EventHandlerUnion<T, CompositionEvent>;
122
- onfocusout?: EventHandlerUnion<T, FocusEvent>;
123
- onfocusin?: EventHandlerUnion<T, FocusEvent>;
206
+ onfocusout?: FocusEventHandlerUnion<T, FocusEvent>;
207
+ onfocusin?: FocusEventHandlerUnion<T, FocusEvent>;
124
208
  onencrypted?: EventHandlerUnion<T, Event>;
125
209
  ondragexit?: EventHandlerUnion<T, DragEvent>;
126
210
  }
@@ -130,11 +214,11 @@ export namespace JSX {
130
214
  onAnimationIteration?: EventHandlerUnion<T, AnimationEvent>;
131
215
  onAnimationStart?: EventHandlerUnion<T, AnimationEvent>;
132
216
  onAuxClick?: EventHandlerUnion<T, MouseEvent>;
133
- onBeforeInput?: EventHandlerUnion<T, InputEvent>;
134
- onBlur?: EventHandlerUnion<T, FocusEvent>;
217
+ onBeforeInput?: InputEventHandlerUnion<T, InputEvent>;
218
+ onBlur?: FocusEventHandlerUnion<T, FocusEvent>;
135
219
  onCanPlay?: EventHandlerUnion<T, Event>;
136
220
  onCanPlayThrough?: EventHandlerUnion<T, Event>;
137
- onChange?: EventHandlerUnion<T, Event>;
221
+ onChange?: ChangeEventHandlerUnion<T, Event>;
138
222
  onClick?: EventHandlerUnion<T, MouseEvent>;
139
223
  onContextMenu?: EventHandlerUnion<T, MouseEvent>;
140
224
  onDblClick?: EventHandlerUnion<T, MouseEvent>;
@@ -149,9 +233,9 @@ export namespace JSX {
149
233
  onEmptied?: EventHandlerUnion<T, Event>;
150
234
  onEnded?: EventHandlerUnion<T, Event>;
151
235
  onError?: EventHandlerUnion<T, Event>;
152
- onFocus?: EventHandlerUnion<T, FocusEvent>;
236
+ onFocus?: FocusEventHandlerUnion<T, FocusEvent>;
153
237
  onGotPointerCapture?: EventHandlerUnion<T, PointerEvent>;
154
- onInput?: EventHandlerUnion<T, InputEvent>;
238
+ onInput?: InputEventHandlerUnion<T, InputEvent>;
155
239
  onInvalid?: EventHandlerUnion<T, Event>;
156
240
  onKeyDown?: EventHandlerUnion<T, KeyboardEvent>;
157
241
  onKeyPress?: EventHandlerUnion<T, KeyboardEvent>;
@@ -213,11 +297,11 @@ export namespace JSX {
213
297
  onanimationiteration?: EventHandlerUnion<T, AnimationEvent>;
214
298
  onanimationstart?: EventHandlerUnion<T, AnimationEvent>;
215
299
  onauxclick?: EventHandlerUnion<T, MouseEvent>;
216
- onbeforeinput?: EventHandlerUnion<T, InputEvent>;
217
- onblur?: EventHandlerUnion<T, FocusEvent>;
300
+ onbeforeinput?: InputEventHandlerUnion<T, InputEvent>;
301
+ onblur?: FocusEventHandlerUnion<T, FocusEvent>;
218
302
  oncanplay?: EventHandlerUnion<T, Event>;
219
303
  oncanplaythrough?: EventHandlerUnion<T, Event>;
220
- onchange?: EventHandlerUnion<T, Event>;
304
+ onchange?: ChangeEventHandlerUnion<T, Event>;
221
305
  onclick?: EventHandlerUnion<T, MouseEvent>;
222
306
  oncontextmenu?: EventHandlerUnion<T, MouseEvent>;
223
307
  ondblclick?: EventHandlerUnion<T, MouseEvent>;
@@ -232,9 +316,9 @@ export namespace JSX {
232
316
  onemptied?: EventHandlerUnion<T, Event>;
233
317
  onended?: EventHandlerUnion<T, Event>;
234
318
  onerror?: EventHandlerUnion<T, Event>;
235
- onfocus?: EventHandlerUnion<T, FocusEvent>;
319
+ onfocus?: FocusEventHandlerUnion<T, FocusEvent>;
236
320
  ongotpointercapture?: EventHandlerUnion<T, PointerEvent>;
237
- oninput?: EventHandlerUnion<T, InputEvent>;
321
+ oninput?: InputEventHandlerUnion<T, InputEvent>;
238
322
  oninvalid?: EventHandlerUnion<T, Event>;
239
323
  onkeydown?: EventHandlerUnion<T, KeyboardEvent>;
240
324
  onkeypress?: EventHandlerUnion<T, KeyboardEvent>;
@@ -290,7 +374,7 @@ export namespace JSX {
290
374
 
291
375
  interface CSSProperties extends csstype.PropertiesHyphen {
292
376
  // Override
293
- [key: `-${string}`]: string | number | undefined
377
+ [key: `-${string}`]: string | number | undefined;
294
378
  }
295
379
 
296
380
  type HTMLAutocapitalize = "off" | "none" | "on" | "sentences" | "words" | "characters";
@@ -769,6 +853,7 @@ export namespace JSX {
769
853
  src?: string;
770
854
  srcdoc?: string;
771
855
  width?: number | string;
856
+ loading?: "eager" | "lazy";
772
857
  referrerPolicy?: HTMLReferrerPolicy;
773
858
  }
774
859
  interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
@@ -799,7 +884,7 @@ export namespace JSX {
799
884
  checked?: boolean;
800
885
  crossorigin?: HTMLCrossorigin;
801
886
  disabled?: boolean;
802
- enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
887
+ enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
803
888
  form?: string;
804
889
  formaction?: string;
805
890
  formenctype?: HTMLFormEncType;
@@ -1023,7 +1108,7 @@ export namespace JSX {
1023
1108
  rowspan?: number | string;
1024
1109
  colSpan?: number | string;
1025
1110
  rowSpan?: number | string;
1026
- scope?: 'col' | 'row' | 'rowgroup' | 'colgroup';
1111
+ scope?: "col" | "row" | "rowgroup" | "colgroup";
1027
1112
  }
1028
1113
  interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
1029
1114
  datetime?: string;
@@ -1299,7 +1384,7 @@ export namespace JSX {
1299
1384
  gradientUnits?: SVGUnits;
1300
1385
  gradientTransform?: string;
1301
1386
  spreadMethod?: "pad" | "reflect" | "repeat";
1302
- href?: string
1387
+ href?: string;
1303
1388
  }
1304
1389
  interface GraphicsElementSVGAttributes<T>
1305
1390
  extends CoreSVGAttributes<T>,
@@ -23,6 +23,7 @@ export interface Renderer<NodeType> {
23
23
  spread<T>(node: any, accessor: (() => T) | T, skipChildren?: Boolean): void;
24
24
  setProp<T>(node: NodeType, name: string, value: T, prev?: T): T;
25
25
  mergeProps(...sources: unknown[]): unknown;
26
+ use<A, T>(fn: (element: NodeType, arg: A) => T, element: NodeType, arg: A): T;
26
27
  }
27
28
 
28
29
  export function createRenderer<NodeType>(options: RendererOptions<NodeType>): Renderer<NodeType>;
package/web/dist/dev.cjs CHANGED
@@ -126,7 +126,9 @@ function template(html, isCE, isSVG) {
126
126
  t.innerHTML = html;
127
127
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
128
128
  };
129
- return isCE ? () => (node || (node = create())).cloneNode(true) : () => solidJs.untrack(() => document.importNode(node || (node = create()), true));
129
+ const fn = isCE ? () => (node || (node = create())).cloneNode(true) : () => solidJs.untrack(() => document.importNode(node || (node = create()), true));
130
+ fn.cloneNode = fn;
131
+ return fn;
130
132
  }
131
133
  function delegateEvents(eventNames, document = window.document) {
132
134
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
package/web/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, untrack, createRenderEffect, sharedConfig, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, 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"];
@@ -125,7 +125,9 @@ function template(html, isCE, isSVG) {
125
125
  t.innerHTML = html;
126
126
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
127
127
  };
128
- return isCE ? () => (node || (node = create())).cloneNode(true) : () => untrack(() => document.importNode(node || (node = create()), true));
128
+ const fn = isCE ? () => (node || (node = create())).cloneNode(true) : () => untrack(() => document.importNode(node || (node = create()), true));
129
+ fn.cloneNode = fn;
130
+ return fn;
129
131
  }
130
132
  function delegateEvents(eventNames, document = window.document) {
131
133
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
package/web/dist/web.cjs CHANGED
@@ -126,7 +126,9 @@ function template(html, isCE, isSVG) {
126
126
  t.innerHTML = html;
127
127
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
128
128
  };
129
- return isCE ? () => (node || (node = create())).cloneNode(true) : () => solidJs.untrack(() => document.importNode(node || (node = create()), true));
129
+ const fn = isCE ? () => (node || (node = create())).cloneNode(true) : () => solidJs.untrack(() => document.importNode(node || (node = create()), true));
130
+ fn.cloneNode = fn;
131
+ return fn;
130
132
  }
131
133
  function delegateEvents(eventNames, document = window.document) {
132
134
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
package/web/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRoot, untrack, createRenderEffect, sharedConfig, enableHydration, createMemo, createSignal, onMount, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
1
+ import { createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createMemo, createSignal, onMount, 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"];
@@ -125,7 +125,9 @@ function template(html, isCE, isSVG) {
125
125
  t.innerHTML = html;
126
126
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
127
127
  };
128
- return isCE ? () => (node || (node = create())).cloneNode(true) : () => untrack(() => document.importNode(node || (node = create()), true));
128
+ const fn = isCE ? () => (node || (node = create())).cloneNode(true) : () => untrack(() => document.importNode(node || (node = create()), true));
129
+ fn.cloneNode = fn;
130
+ return fn;
129
131
  }
130
132
  function delegateEvents(eventNames, document = window.document) {
131
133
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());