@vue/runtime-dom 3.5.5 → 3.5.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.5
2
+ * @vue/runtime-dom v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -287,7 +287,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
287
287
  resolve();
288
288
  }
289
289
  };
290
- if (explicitTimeout) {
290
+ if (explicitTimeout != null) {
291
291
  return setTimeout(resolveIfNotStale, explicitTimeout);
292
292
  }
293
293
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.5
2
+ * @vue/runtime-dom v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -283,7 +283,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
283
283
  resolve();
284
284
  }
285
285
  };
286
- if (explicitTimeout) {
286
+ if (explicitTimeout != null) {
287
287
  return setTimeout(resolveIfNotStale, explicitTimeout);
288
288
  }
289
289
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.5.5
2
+ * @vue/runtime-dom v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -465,7 +465,7 @@ class ReactiveEffect {
465
465
  /**
466
466
  * @internal
467
467
  */
468
- this.nextEffect = void 0;
468
+ this.next = void 0;
469
469
  /**
470
470
  * @internal
471
471
  */
@@ -495,9 +495,7 @@ class ReactiveEffect {
495
495
  return;
496
496
  }
497
497
  if (!(this.flags & 8)) {
498
- this.flags |= 8;
499
- this.nextEffect = batchedEffect;
500
- batchedEffect = this;
498
+ batch(this);
501
499
  }
502
500
  }
503
501
  run() {
@@ -558,7 +556,12 @@ class ReactiveEffect {
558
556
  }
559
557
  }
560
558
  let batchDepth = 0;
561
- let batchedEffect;
559
+ let batchedSub;
560
+ function batch(sub) {
561
+ sub.flags |= 8;
562
+ sub.next = batchedSub;
563
+ batchedSub = sub;
564
+ }
562
565
  function startBatch() {
563
566
  batchDepth++;
564
567
  }
@@ -567,15 +570,16 @@ function endBatch() {
567
570
  return;
568
571
  }
569
572
  let error;
570
- while (batchedEffect) {
571
- let e = batchedEffect;
572
- batchedEffect = void 0;
573
+ while (batchedSub) {
574
+ let e = batchedSub;
575
+ batchedSub = void 0;
573
576
  while (e) {
574
- const next = e.nextEffect;
575
- e.nextEffect = void 0;
577
+ const next = e.next;
578
+ e.next = void 0;
576
579
  e.flags &= ~8;
577
580
  if (e.flags & 1) {
578
581
  try {
582
+ ;
579
583
  e.trigger();
580
584
  } catch (err) {
581
585
  if (!error) error = err;
@@ -615,7 +619,7 @@ function cleanupDeps(sub) {
615
619
  }
616
620
  function isDirty(sub) {
617
621
  for (let link = sub.deps; link; link = link.nextDep) {
618
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
622
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
619
623
  return true;
620
624
  }
621
625
  }
@@ -635,7 +639,7 @@ function refreshComputed(computed) {
635
639
  computed.globalVersion = globalVersion;
636
640
  const dep = computed.dep;
637
641
  computed.flags |= 2;
638
- if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
642
+ if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
639
643
  computed.flags &= ~2;
640
644
  return;
641
645
  }
@@ -660,7 +664,7 @@ function refreshComputed(computed) {
660
664
  computed.flags &= ~2;
661
665
  }
662
666
  }
663
- function removeSub(link) {
667
+ function removeSub(link, fromComputed = false) {
664
668
  const { dep, prevSub, nextSub } = link;
665
669
  if (prevSub) {
666
670
  prevSub.nextSub = nextSub;
@@ -673,10 +677,18 @@ function removeSub(link) {
673
677
  if (dep.subs === link) {
674
678
  dep.subs = prevSub;
675
679
  }
676
- if (!dep.subs && dep.computed) {
677
- dep.computed.flags &= ~4;
678
- for (let l = dep.computed.deps; l; l = l.nextDep) {
679
- removeSub(l);
680
+ if (dep.subsHead === link) {
681
+ dep.subsHead = nextSub;
682
+ }
683
+ if (!dep.subs) {
684
+ if (dep.computed) {
685
+ dep.computed.flags &= ~4;
686
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
687
+ removeSub(l, true);
688
+ }
689
+ } else if (dep.map && !fromComputed) {
690
+ dep.map.delete(dep.key);
691
+ if (!dep.map.size) targetMap.delete(dep.target);
680
692
  }
681
693
  }
682
694
  }
@@ -757,6 +769,12 @@ class Dep {
757
769
  * Doubly linked list representing the subscribing effects (tail)
758
770
  */
759
771
  this.subs = void 0;
772
+ /**
773
+ * For object property deps cleanup
774
+ */
775
+ this.target = void 0;
776
+ this.map = void 0;
777
+ this.key = void 0;
760
778
  {
761
779
  this.subsHead = void 0;
762
780
  }
@@ -830,7 +848,10 @@ class Dep {
830
848
  }
831
849
  }
832
850
  for (let link = this.subs; link; link = link.prevSub) {
833
- link.sub.notify();
851
+ if (link.sub.notify()) {
852
+ ;
853
+ link.sub.dep.notify();
854
+ }
834
855
  }
835
856
  } finally {
836
857
  endBatch();
@@ -874,6 +895,9 @@ function track(target, type, key) {
874
895
  let dep = depsMap.get(key);
875
896
  if (!dep) {
876
897
  depsMap.set(key, dep = new Dep());
898
+ dep.target = target;
899
+ dep.map = depsMap;
900
+ dep.key = key;
877
901
  }
878
902
  {
879
903
  dep.track({
@@ -1750,13 +1774,15 @@ class RefImpl {
1750
1774
  }
1751
1775
  }
1752
1776
  function triggerRef(ref2) {
1753
- {
1754
- ref2.dep.trigger({
1755
- target: ref2,
1756
- type: "set",
1757
- key: "value",
1758
- newValue: ref2._value
1759
- });
1777
+ if (ref2.dep) {
1778
+ {
1779
+ ref2.dep.trigger({
1780
+ target: ref2,
1781
+ type: "set",
1782
+ key: "value",
1783
+ newValue: ref2._value
1784
+ });
1785
+ }
1760
1786
  }
1761
1787
  }
1762
1788
  function unref(ref2) {
@@ -1899,8 +1925,10 @@ class ComputedRefImpl {
1899
1925
  */
1900
1926
  notify() {
1901
1927
  this.flags |= 16;
1902
- if (activeSub !== this) {
1903
- this.dep.notify();
1928
+ if (!(this.flags & 8) && // avoid infinite self recursion
1929
+ activeSub !== this) {
1930
+ batch(this);
1931
+ return true;
1904
1932
  }
1905
1933
  }
1906
1934
  get value() {
@@ -2048,20 +2076,12 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2048
2076
  remove(scope.effects, effect);
2049
2077
  }
2050
2078
  };
2051
- if (once) {
2052
- if (cb) {
2053
- const _cb = cb;
2054
- cb = (...args) => {
2055
- _cb(...args);
2056
- watchHandle();
2057
- };
2058
- } else {
2059
- const _getter = getter;
2060
- getter = () => {
2061
- _getter();
2062
- watchHandle();
2063
- };
2064
- }
2079
+ if (once && cb) {
2080
+ const _cb = cb;
2081
+ cb = (...args) => {
2082
+ _cb(...args);
2083
+ watchHandle();
2084
+ };
2065
2085
  }
2066
2086
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2067
2087
  const job = (immediateFirstRun) => {
@@ -2510,7 +2530,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
2510
2530
  cb.flags &= ~1;
2511
2531
  }
2512
2532
  cb();
2513
- cb.flags &= ~1;
2533
+ if (!(cb.flags & 4)) {
2534
+ cb.flags &= ~1;
2535
+ }
2514
2536
  }
2515
2537
  }
2516
2538
  }
@@ -2566,7 +2588,9 @@ function flushJobs(seen) {
2566
2588
  job.i,
2567
2589
  job.i ? 15 : 14
2568
2590
  );
2569
- job.flags &= ~1;
2591
+ if (!(job.flags & 4)) {
2592
+ job.flags &= ~1;
2593
+ }
2570
2594
  }
2571
2595
  }
2572
2596
  } finally {
@@ -4365,6 +4389,11 @@ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4365
4389
  const id = requestIdleCallback(hydrate, { timeout });
4366
4390
  return () => cancelIdleCallback(id);
4367
4391
  };
4392
+ function elementIsVisibleInViewport(el) {
4393
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4394
+ const { innerHeight, innerWidth } = window;
4395
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4396
+ }
4368
4397
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4369
4398
  const ob = new IntersectionObserver((entries) => {
4370
4399
  for (const e of entries) {
@@ -4374,7 +4403,15 @@ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4374
4403
  break;
4375
4404
  }
4376
4405
  }, opts);
4377
- forEach((el) => ob.observe(el));
4406
+ forEach((el) => {
4407
+ if (!(el instanceof Element)) return;
4408
+ if (elementIsVisibleInViewport(el)) {
4409
+ hydrate();
4410
+ ob.disconnect();
4411
+ return false;
4412
+ }
4413
+ ob.observe(el);
4414
+ });
4378
4415
  return () => ob.disconnect();
4379
4416
  };
4380
4417
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -4419,7 +4456,10 @@ function forEachElement(node, cb) {
4419
4456
  let next = node.nextSibling;
4420
4457
  while (next) {
4421
4458
  if (next.nodeType === 1) {
4422
- cb(next);
4459
+ const result = cb(next);
4460
+ if (result === false) {
4461
+ break;
4462
+ }
4423
4463
  } else if (isComment(next)) {
4424
4464
  if (next.data === "]") {
4425
4465
  if (--depth === 0) break;
@@ -8206,11 +8246,12 @@ function doWatch(source, cb, options = EMPTY_OBJ) {
8206
8246
  } else if (!cb || immediate) {
8207
8247
  baseWatchOptions.once = true;
8208
8248
  } else {
8209
- return {
8210
- stop: NOOP,
8211
- resume: NOOP,
8212
- pause: NOOP
8249
+ const watchStopHandle = () => {
8213
8250
  };
8251
+ watchStopHandle.stop = NOOP;
8252
+ watchStopHandle.resume = NOOP;
8253
+ watchStopHandle.pause = NOOP;
8254
+ return watchStopHandle;
8214
8255
  }
8215
8256
  }
8216
8257
  const instance = currentInstance;
@@ -10395,7 +10436,7 @@ function isMemoSame(cached, memo) {
10395
10436
  return true;
10396
10437
  }
10397
10438
 
10398
- const version = "3.5.5";
10439
+ const version = "3.5.7";
10399
10440
  const warn = warn$1 ;
10400
10441
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10401
10442
  const devtools = devtools$1 ;
@@ -10694,7 +10735,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
10694
10735
  resolve();
10695
10736
  }
10696
10737
  };
10697
- if (explicitTimeout) {
10738
+ if (explicitTimeout != null) {
10698
10739
  return setTimeout(resolveIfNotStale, explicitTimeout);
10699
10740
  }
10700
10741
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);