@solidjs/signals 0.4.6 → 0.4.8

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.js CHANGED
@@ -292,6 +292,8 @@ function cloneGraph(node) {
292
292
  _sources: node._sources ? [...node._sources] : null,
293
293
  _cloned: node
294
294
  });
295
+ if (clone._compute)
296
+ clone._stateFlags |= UNINITIALIZED_BIT;
295
297
  ActiveTransition._sources.set(node, clone);
296
298
  node._transition = ActiveTransition;
297
299
  if (node._sources) {
@@ -384,10 +386,12 @@ function finishTransition(transition2) {
384
386
  continue;
385
387
  if (clone._sources)
386
388
  replaceSourceObservers(clone, transition2);
387
- source.dispose(false);
388
- source.emptyDisposal();
389
- Object.assign(source, clone);
390
- delete source._cloned;
389
+ if (!(clone._stateFlags === UNINITIALIZED_BIT)) {
390
+ source.dispose(false);
391
+ source.emptyDisposal();
392
+ Object.assign(source, clone);
393
+ delete source._cloned;
394
+ }
391
395
  delete source._transition;
392
396
  }
393
397
  globalQueue._queues[0].push.apply(globalQueue._queues[0], transition2._queues[0]);
@@ -1918,7 +1922,7 @@ function createOptimistic(initial, compute2, key) {
1918
1922
  if (!ActiveTransition)
1919
1923
  throw new Error("createOptimistic can only be updated inside a transition");
1920
1924
  ActiveTransition.addOptimistic(reset2);
1921
- queueMicrotask(() => node.write(v));
1925
+ queueMicrotask(() => reset2._transition && node.write(v));
1922
1926
  };
1923
1927
  var write = write2;
1924
1928
  const node = new Computation(initial, null);
@@ -1949,7 +1953,7 @@ function createOptimistic(initial, compute2, key) {
1949
1953
  throw new Error("createOptimistic can only be updated inside a transition");
1950
1954
  ActiveTransition.addOptimistic(reset);
1951
1955
  queueMicrotask(
1952
- () => setStore((s) => {
1956
+ () => reset._transition && setStore((s) => {
1953
1957
  lastChange = typeof v === "function" ? v(lastChange) : v;
1954
1958
  compute2(s.value, lastChange);
1955
1959
  })