@vue/runtime-dom 3.5.6 → 3.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.6
2
+ * @vue/runtime-dom v3.5.8
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -600,7 +600,7 @@ var VueRuntimeDOM = (function (exports) {
600
600
  link.dep.activeLink = link;
601
601
  }
602
602
  }
603
- function cleanupDeps(sub) {
603
+ function cleanupDeps(sub, fromComputed = false) {
604
604
  let head;
605
605
  let tail = sub.depsTail;
606
606
  let link = tail;
@@ -608,7 +608,7 @@ var VueRuntimeDOM = (function (exports) {
608
608
  const prev = link.prevDep;
609
609
  if (link.version === -1) {
610
610
  if (link === tail) tail = prev;
611
- removeSub(link);
611
+ removeSub(link, fromComputed);
612
612
  removeDep(link);
613
613
  } else {
614
614
  head = link;
@@ -663,11 +663,11 @@ var VueRuntimeDOM = (function (exports) {
663
663
  } finally {
664
664
  activeSub = prevSub;
665
665
  shouldTrack = prevShouldTrack;
666
- cleanupDeps(computed);
666
+ cleanupDeps(computed, true);
667
667
  computed.flags &= ~2;
668
668
  }
669
669
  }
670
- function removeSub(link) {
670
+ function removeSub(link, fromComputed = false) {
671
671
  const { dep, prevSub, nextSub } = link;
672
672
  if (prevSub) {
673
673
  prevSub.nextSub = nextSub;
@@ -680,10 +680,18 @@ var VueRuntimeDOM = (function (exports) {
680
680
  if (dep.subs === link) {
681
681
  dep.subs = prevSub;
682
682
  }
683
- if (!dep.subs && dep.computed) {
684
- dep.computed.flags &= ~4;
685
- for (let l = dep.computed.deps; l; l = l.nextDep) {
686
- removeSub(l);
683
+ if (dep.subsHead === link) {
684
+ dep.subsHead = nextSub;
685
+ }
686
+ if (!dep.subs) {
687
+ if (dep.computed) {
688
+ dep.computed.flags &= ~4;
689
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
690
+ removeSub(l, true);
691
+ }
692
+ } else if (dep.map && !fromComputed) {
693
+ dep.map.delete(dep.key);
694
+ if (!dep.map.size) targetMap.delete(dep.target);
687
695
  }
688
696
  }
689
697
  }
@@ -764,6 +772,12 @@ var VueRuntimeDOM = (function (exports) {
764
772
  * Doubly linked list representing the subscribing effects (tail)
765
773
  */
766
774
  this.subs = void 0;
775
+ /**
776
+ * For object property deps cleanup
777
+ */
778
+ this.target = void 0;
779
+ this.map = void 0;
780
+ this.key = void 0;
767
781
  {
768
782
  this.subsHead = void 0;
769
783
  }
@@ -884,6 +898,9 @@ var VueRuntimeDOM = (function (exports) {
884
898
  let dep = depsMap.get(key);
885
899
  if (!dep) {
886
900
  depsMap.set(key, dep = new Dep());
901
+ dep.target = target;
902
+ dep.map = depsMap;
903
+ dep.key = key;
887
904
  }
888
905
  {
889
906
  dep.track({
@@ -1760,13 +1777,15 @@ var VueRuntimeDOM = (function (exports) {
1760
1777
  }
1761
1778
  }
1762
1779
  function triggerRef(ref2) {
1763
- {
1764
- ref2.dep.trigger({
1765
- target: ref2,
1766
- type: "set",
1767
- key: "value",
1768
- newValue: ref2._value
1769
- });
1780
+ if (ref2.dep) {
1781
+ {
1782
+ ref2.dep.trigger({
1783
+ target: ref2,
1784
+ type: "set",
1785
+ key: "value",
1786
+ newValue: ref2._value
1787
+ });
1788
+ }
1770
1789
  }
1771
1790
  }
1772
1791
  function unref(ref2) {
@@ -2514,7 +2533,9 @@ var VueRuntimeDOM = (function (exports) {
2514
2533
  cb.flags &= ~1;
2515
2534
  }
2516
2535
  cb();
2517
- cb.flags &= ~1;
2536
+ if (!(cb.flags & 4)) {
2537
+ cb.flags &= ~1;
2538
+ }
2518
2539
  }
2519
2540
  }
2520
2541
  }
@@ -2570,7 +2591,9 @@ var VueRuntimeDOM = (function (exports) {
2570
2591
  job.i,
2571
2592
  job.i ? 15 : 14
2572
2593
  );
2573
- job.flags &= ~1;
2594
+ if (!(job.flags & 4)) {
2595
+ job.flags &= ~1;
2596
+ }
2574
2597
  }
2575
2598
  }
2576
2599
  } finally {
@@ -4369,6 +4392,11 @@ Server rendered element contains fewer child nodes than client vdom.`
4369
4392
  const id = requestIdleCallback(hydrate, { timeout });
4370
4393
  return () => cancelIdleCallback(id);
4371
4394
  };
4395
+ function elementIsVisibleInViewport(el) {
4396
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4397
+ const { innerHeight, innerWidth } = window;
4398
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4399
+ }
4372
4400
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4373
4401
  const ob = new IntersectionObserver((entries) => {
4374
4402
  for (const e of entries) {
@@ -4378,7 +4406,15 @@ Server rendered element contains fewer child nodes than client vdom.`
4378
4406
  break;
4379
4407
  }
4380
4408
  }, opts);
4381
- forEach((el) => ob.observe(el));
4409
+ forEach((el) => {
4410
+ if (!(el instanceof Element)) return;
4411
+ if (elementIsVisibleInViewport(el)) {
4412
+ hydrate();
4413
+ ob.disconnect();
4414
+ return false;
4415
+ }
4416
+ ob.observe(el);
4417
+ });
4382
4418
  return () => ob.disconnect();
4383
4419
  };
4384
4420
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -4423,7 +4459,10 @@ Server rendered element contains fewer child nodes than client vdom.`
4423
4459
  let next = node.nextSibling;
4424
4460
  while (next) {
4425
4461
  if (next.nodeType === 1) {
4426
- cb(next);
4462
+ const result = cb(next);
4463
+ if (result === false) {
4464
+ break;
4465
+ }
4427
4466
  } else if (isComment(next)) {
4428
4467
  if (next.data === "]") {
4429
4468
  if (--depth === 0) break;
@@ -10354,7 +10393,7 @@ Component that was made reactive: `,
10354
10393
  return true;
10355
10394
  }
10356
10395
 
10357
- const version = "3.5.6";
10396
+ const version = "3.5.8";
10358
10397
  const warn = warn$1 ;
10359
10398
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10360
10399
  const devtools = devtools$1 ;
@@ -10641,7 +10680,7 @@ Component that was made reactive: `,
10641
10680
  resolve();
10642
10681
  }
10643
10682
  };
10644
- if (explicitTimeout) {
10683
+ if (explicitTimeout != null) {
10645
10684
  return setTimeout(resolveIfNotStale, explicitTimeout);
10646
10685
  }
10647
10686
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);