vue 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.5
2
+ * vue v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.5
2
+ * vue v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.5.5
2
+ * vue v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -532,7 +532,7 @@ class ReactiveEffect {
532
532
  /**
533
533
  * @internal
534
534
  */
535
- this.nextEffect = void 0;
535
+ this.next = void 0;
536
536
  /**
537
537
  * @internal
538
538
  */
@@ -562,9 +562,7 @@ class ReactiveEffect {
562
562
  return;
563
563
  }
564
564
  if (!(this.flags & 8)) {
565
- this.flags |= 8;
566
- this.nextEffect = batchedEffect;
567
- batchedEffect = this;
565
+ batch(this);
568
566
  }
569
567
  }
570
568
  run() {
@@ -625,7 +623,12 @@ class ReactiveEffect {
625
623
  }
626
624
  }
627
625
  let batchDepth = 0;
628
- let batchedEffect;
626
+ let batchedSub;
627
+ function batch(sub) {
628
+ sub.flags |= 8;
629
+ sub.next = batchedSub;
630
+ batchedSub = sub;
631
+ }
629
632
  function startBatch() {
630
633
  batchDepth++;
631
634
  }
@@ -634,15 +637,16 @@ function endBatch() {
634
637
  return;
635
638
  }
636
639
  let error;
637
- while (batchedEffect) {
638
- let e = batchedEffect;
639
- batchedEffect = void 0;
640
+ while (batchedSub) {
641
+ let e = batchedSub;
642
+ batchedSub = void 0;
640
643
  while (e) {
641
- const next = e.nextEffect;
642
- e.nextEffect = void 0;
644
+ const next = e.next;
645
+ e.next = void 0;
643
646
  e.flags &= ~8;
644
647
  if (e.flags & 1) {
645
648
  try {
649
+ ;
646
650
  e.trigger();
647
651
  } catch (err) {
648
652
  if (!error) error = err;
@@ -682,7 +686,7 @@ function cleanupDeps(sub) {
682
686
  }
683
687
  function isDirty(sub) {
684
688
  for (let link = sub.deps; link; link = link.nextDep) {
685
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
689
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
686
690
  return true;
687
691
  }
688
692
  }
@@ -702,7 +706,7 @@ function refreshComputed(computed) {
702
706
  computed.globalVersion = globalVersion;
703
707
  const dep = computed.dep;
704
708
  computed.flags |= 2;
705
- if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
709
+ if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
706
710
  computed.flags &= ~2;
707
711
  return;
708
712
  }
@@ -727,7 +731,7 @@ function refreshComputed(computed) {
727
731
  computed.flags &= ~2;
728
732
  }
729
733
  }
730
- function removeSub(link) {
734
+ function removeSub(link, fromComputed = false) {
731
735
  const { dep, prevSub, nextSub } = link;
732
736
  if (prevSub) {
733
737
  prevSub.nextSub = nextSub;
@@ -740,10 +744,18 @@ function removeSub(link) {
740
744
  if (dep.subs === link) {
741
745
  dep.subs = prevSub;
742
746
  }
743
- if (!dep.subs && dep.computed) {
744
- dep.computed.flags &= ~4;
745
- for (let l = dep.computed.deps; l; l = l.nextDep) {
746
- removeSub(l);
747
+ if (dep.subsHead === link) {
748
+ dep.subsHead = nextSub;
749
+ }
750
+ if (!dep.subs) {
751
+ if (dep.computed) {
752
+ dep.computed.flags &= ~4;
753
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
754
+ removeSub(l, true);
755
+ }
756
+ } else if (dep.map && !fromComputed) {
757
+ dep.map.delete(dep.key);
758
+ if (!dep.map.size) targetMap.delete(dep.target);
747
759
  }
748
760
  }
749
761
  }
@@ -824,6 +836,12 @@ class Dep {
824
836
  * Doubly linked list representing the subscribing effects (tail)
825
837
  */
826
838
  this.subs = void 0;
839
+ /**
840
+ * For object property deps cleanup
841
+ */
842
+ this.target = void 0;
843
+ this.map = void 0;
844
+ this.key = void 0;
827
845
  {
828
846
  this.subsHead = void 0;
829
847
  }
@@ -897,7 +915,10 @@ class Dep {
897
915
  }
898
916
  }
899
917
  for (let link = this.subs; link; link = link.prevSub) {
900
- link.sub.notify();
918
+ if (link.sub.notify()) {
919
+ ;
920
+ link.sub.dep.notify();
921
+ }
901
922
  }
902
923
  } finally {
903
924
  endBatch();
@@ -941,6 +962,9 @@ function track(target, type, key) {
941
962
  let dep = depsMap.get(key);
942
963
  if (!dep) {
943
964
  depsMap.set(key, dep = new Dep());
965
+ dep.target = target;
966
+ dep.map = depsMap;
967
+ dep.key = key;
944
968
  }
945
969
  {
946
970
  dep.track({
@@ -1817,13 +1841,15 @@ class RefImpl {
1817
1841
  }
1818
1842
  }
1819
1843
  function triggerRef(ref2) {
1820
- {
1821
- ref2.dep.trigger({
1822
- target: ref2,
1823
- type: "set",
1824
- key: "value",
1825
- newValue: ref2._value
1826
- });
1844
+ if (ref2.dep) {
1845
+ {
1846
+ ref2.dep.trigger({
1847
+ target: ref2,
1848
+ type: "set",
1849
+ key: "value",
1850
+ newValue: ref2._value
1851
+ });
1852
+ }
1827
1853
  }
1828
1854
  }
1829
1855
  function unref(ref2) {
@@ -1966,8 +1992,10 @@ class ComputedRefImpl {
1966
1992
  */
1967
1993
  notify() {
1968
1994
  this.flags |= 16;
1969
- if (activeSub !== this) {
1970
- this.dep.notify();
1995
+ if (!(this.flags & 8) && // avoid infinite self recursion
1996
+ activeSub !== this) {
1997
+ batch(this);
1998
+ return true;
1971
1999
  }
1972
2000
  }
1973
2001
  get value() {
@@ -2115,20 +2143,12 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2115
2143
  remove(scope.effects, effect);
2116
2144
  }
2117
2145
  };
2118
- if (once) {
2119
- if (cb) {
2120
- const _cb = cb;
2121
- cb = (...args) => {
2122
- _cb(...args);
2123
- watchHandle();
2124
- };
2125
- } else {
2126
- const _getter = getter;
2127
- getter = () => {
2128
- _getter();
2129
- watchHandle();
2130
- };
2131
- }
2146
+ if (once && cb) {
2147
+ const _cb = cb;
2148
+ cb = (...args) => {
2149
+ _cb(...args);
2150
+ watchHandle();
2151
+ };
2132
2152
  }
2133
2153
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2134
2154
  const job = (immediateFirstRun) => {
@@ -2577,7 +2597,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
2577
2597
  cb.flags &= ~1;
2578
2598
  }
2579
2599
  cb();
2580
- cb.flags &= ~1;
2600
+ if (!(cb.flags & 4)) {
2601
+ cb.flags &= ~1;
2602
+ }
2581
2603
  }
2582
2604
  }
2583
2605
  }
@@ -2633,7 +2655,9 @@ function flushJobs(seen) {
2633
2655
  job.i,
2634
2656
  job.i ? 15 : 14
2635
2657
  );
2636
- job.flags &= ~1;
2658
+ if (!(job.flags & 4)) {
2659
+ job.flags &= ~1;
2660
+ }
2637
2661
  }
2638
2662
  }
2639
2663
  } finally {
@@ -4432,6 +4456,11 @@ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4432
4456
  const id = requestIdleCallback(hydrate, { timeout });
4433
4457
  return () => cancelIdleCallback(id);
4434
4458
  };
4459
+ function elementIsVisibleInViewport(el) {
4460
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4461
+ const { innerHeight, innerWidth } = window;
4462
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4463
+ }
4435
4464
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4436
4465
  const ob = new IntersectionObserver((entries) => {
4437
4466
  for (const e of entries) {
@@ -4441,7 +4470,15 @@ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4441
4470
  break;
4442
4471
  }
4443
4472
  }, opts);
4444
- forEach((el) => ob.observe(el));
4473
+ forEach((el) => {
4474
+ if (!(el instanceof Element)) return;
4475
+ if (elementIsVisibleInViewport(el)) {
4476
+ hydrate();
4477
+ ob.disconnect();
4478
+ return false;
4479
+ }
4480
+ ob.observe(el);
4481
+ });
4445
4482
  return () => ob.disconnect();
4446
4483
  };
4447
4484
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -4486,7 +4523,10 @@ function forEachElement(node, cb) {
4486
4523
  let next = node.nextSibling;
4487
4524
  while (next) {
4488
4525
  if (next.nodeType === 1) {
4489
- cb(next);
4526
+ const result = cb(next);
4527
+ if (result === false) {
4528
+ break;
4529
+ }
4490
4530
  } else if (isComment(next)) {
4491
4531
  if (next.data === "]") {
4492
4532
  if (--depth === 0) break;
@@ -8273,11 +8313,12 @@ function doWatch(source, cb, options = EMPTY_OBJ) {
8273
8313
  } else if (!cb || immediate) {
8274
8314
  baseWatchOptions.once = true;
8275
8315
  } else {
8276
- return {
8277
- stop: NOOP,
8278
- resume: NOOP,
8279
- pause: NOOP
8316
+ const watchStopHandle = () => {
8280
8317
  };
8318
+ watchStopHandle.stop = NOOP;
8319
+ watchStopHandle.resume = NOOP;
8320
+ watchStopHandle.pause = NOOP;
8321
+ return watchStopHandle;
8281
8322
  }
8282
8323
  }
8283
8324
  const instance = currentInstance;
@@ -10462,7 +10503,7 @@ function isMemoSame(cached, memo) {
10462
10503
  return true;
10463
10504
  }
10464
10505
 
10465
- const version = "3.5.5";
10506
+ const version = "3.5.7";
10466
10507
  const warn = warn$1 ;
10467
10508
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10468
10509
  const devtools = devtools$1 ;
@@ -10761,7 +10802,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
10761
10802
  resolve();
10762
10803
  }
10763
10804
  };
10764
- if (explicitTimeout) {
10805
+ if (explicitTimeout != null) {
10765
10806
  return setTimeout(resolveIfNotStale, explicitTimeout);
10766
10807
  }
10767
10808
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
@@ -17288,7 +17329,7 @@ const transformModel$1 = (dir, node, context) => {
17288
17329
  );
17289
17330
  return createTransformProps();
17290
17331
  }
17291
- const rawExp = exp.loc.source;
17332
+ const rawExp = exp.loc.source.trim();
17292
17333
  const expString = exp.type === 4 ? exp.content : rawExp;
17293
17334
  const bindingType = context.bindingMetadata[rawExp];
17294
17335
  if (bindingType === "props" || bindingType === "props-aliased") {