@solidjs/signals 0.8.5 → 0.8.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.
Files changed (4) hide show
  1. package/dist/dev.js +36 -26
  2. package/dist/node.cjs +245 -241
  3. package/dist/prod.js +245 -241
  4. package/package.json +1 -1
package/dist/dev.js CHANGED
@@ -337,16 +337,19 @@ function notifySubs(node) {
337
337
  }
338
338
  }
339
339
  function recompute(el, create = false) {
340
- deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
341
- if (el._pendingValue !== NOT_PENDING || el._pendingFirstChild || el._pendingDisposal)
342
- disposeChildren(el);
343
- else {
344
- markDisposal(el);
345
- globalQueue._pendingNodes.push(el);
346
- el._pendingDisposal = el._disposal;
347
- el._pendingFirstChild = el._firstChild;
348
- el._disposal = null;
349
- el._firstChild = null;
340
+ const honoraryOptimistic = el._type && el._transition != activeTransition;
341
+ if (!create) {
342
+ if (el._transition && activeTransition !== el._transition && !honoraryOptimistic)
343
+ globalQueue.initTransition(el);
344
+ deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
345
+ if (el._transition) disposeChildren(el);
346
+ else {
347
+ markDisposal(el);
348
+ el._pendingDisposal = el._disposal;
349
+ el._pendingFirstChild = el._firstChild;
350
+ el._disposal = null;
351
+ el._firstChild = null;
352
+ }
350
353
  }
351
354
  const oldcontext = context;
352
355
  context = el;
@@ -373,16 +376,17 @@ function recompute(el, create = false) {
373
376
  }
374
377
  el._flags = REACTIVE_NONE;
375
378
  context = oldcontext;
376
- const depsTail = el._depsTail;
377
- let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
378
- if (toRemove !== null) {
379
- do {
380
- toRemove = unlinkSubs(toRemove);
381
- } while (toRemove !== null);
382
- if (depsTail !== null) depsTail._nextDep = null;
383
- else el._deps = null;
379
+ if (!(el._statusFlags & STATUS_PENDING)) {
380
+ const depsTail = el._depsTail;
381
+ let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
382
+ if (toRemove !== null) {
383
+ do {
384
+ toRemove = unlinkSubs(toRemove);
385
+ } while (toRemove !== null);
386
+ if (depsTail !== null) depsTail._nextDep = null;
387
+ else el._deps = null;
388
+ }
384
389
  }
385
- const honoraryOptimistic = el._type && el._transition != activeTransition;
386
390
  const valueChanged =
387
391
  !el._equals ||
388
392
  !el._equals(
@@ -396,11 +400,8 @@ function recompute(el, create = false) {
396
400
  if (valueChanged || statusFlagsChanged) {
397
401
  if (valueChanged) {
398
402
  if (create || el._optimistic || honoraryOptimistic) el._value = value;
399
- else {
400
- if (el._pendingValue === NOT_PENDING) globalQueue._pendingNodes.push(el);
401
- el._pendingValue = value;
402
- }
403
- if (el._pendingSignal) el._pendingSignal._set(value);
403
+ else el._pendingValue = value;
404
+ if (el._pendingSignal) el._pendingSignal._pendingValue = value;
404
405
  }
405
406
  for (let s = el._subs; s !== null; s = s._nextSub) {
406
407
  const queue = s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
@@ -412,6 +413,13 @@ function recompute(el, create = false) {
412
413
  insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
413
414
  }
414
415
  }
416
+ if (
417
+ (!create || el._statusFlags & STATUS_PENDING) &&
418
+ !el._optimistic &&
419
+ !honoraryOptimistic &&
420
+ !el._transition
421
+ )
422
+ globalQueue._pendingNodes.push(el);
415
423
  if (el._transition && honoraryOptimistic) runInTransition(el, recompute);
416
424
  }
417
425
  function updateIfNecessary(el) {
@@ -444,7 +452,7 @@ function unlinkSubs(link) {
444
452
  dep._subs = nextSub;
445
453
  if (nextSub === null) {
446
454
  dep._unobserved?.();
447
- dep._fn && unobserved(dep);
455
+ dep._fn && !dep._preventAutoDisposal && unobserved(dep);
448
456
  }
449
457
  }
450
458
  return nextDep;
@@ -456,7 +464,7 @@ function unobserved(el) {
456
464
  dep = unlinkSubs(dep);
457
465
  }
458
466
  el._deps = null;
459
- runDisposal(el);
467
+ disposeChildren(el, true);
460
468
  }
461
469
  function link(dep, sub) {
462
470
  const prevDep = sub._depsTail;
@@ -712,6 +720,7 @@ function read(el) {
712
720
  let c = context;
713
721
  if (c?._root) c = c._parentComputed;
714
722
  if (c && tracking && !pendingCheck && !pendingValueCheck) {
723
+ if (el._fn && el._flags & REACTIVE_DISPOSED) recompute(el);
715
724
  link(el, c);
716
725
  const owner = el._firewall || el;
717
726
  if (owner._fn) {
@@ -1947,6 +1956,7 @@ function boundaryComputed(fn, propagationMask) {
1947
1956
  }
1948
1957
  });
1949
1958
  node._propagationMask = propagationMask;
1959
+ node._preventAutoDisposal = true;
1950
1960
  return node;
1951
1961
  }
1952
1962
  function createBoundChildren(owner, fn, queue, mask) {