@solidjs/signals 0.8.5 → 0.8.7

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 +31 -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,8 @@ function recompute(el, create = false) {
412
413
  insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
413
414
  }
414
415
  }
416
+ if ((!create || el._statusFlags & STATUS_PENDING) && !el._optimistic && !el._transition)
417
+ globalQueue._pendingNodes.push(el);
415
418
  if (el._transition && honoraryOptimistic) runInTransition(el, recompute);
416
419
  }
417
420
  function updateIfNecessary(el) {
@@ -444,7 +447,7 @@ function unlinkSubs(link) {
444
447
  dep._subs = nextSub;
445
448
  if (nextSub === null) {
446
449
  dep._unobserved?.();
447
- dep._fn && unobserved(dep);
450
+ dep._fn && !dep._preventAutoDisposal && unobserved(dep);
448
451
  }
449
452
  }
450
453
  return nextDep;
@@ -456,7 +459,7 @@ function unobserved(el) {
456
459
  dep = unlinkSubs(dep);
457
460
  }
458
461
  el._deps = null;
459
- runDisposal(el);
462
+ disposeChildren(el, true);
460
463
  }
461
464
  function link(dep, sub) {
462
465
  const prevDep = sub._depsTail;
@@ -712,6 +715,7 @@ function read(el) {
712
715
  let c = context;
713
716
  if (c?._root) c = c._parentComputed;
714
717
  if (c && tracking && !pendingCheck && !pendingValueCheck) {
718
+ if (el._fn && el._flags & REACTIVE_DISPOSED) recompute(el);
715
719
  link(el, c);
716
720
  const owner = el._firewall || el;
717
721
  if (owner._fn) {
@@ -1947,6 +1951,7 @@ function boundaryComputed(fn, propagationMask) {
1947
1951
  }
1948
1952
  });
1949
1953
  node._propagationMask = propagationMask;
1954
+ node._preventAutoDisposal = true;
1950
1955
  return node;
1951
1956
  }
1952
1957
  function createBoundChildren(owner, fn, queue, mask) {