@vue/compat 3.2.29 → 3.2.30

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.
@@ -341,13 +341,15 @@ function looseIndexOf(arr, val) {
341
341
  * @private
342
342
  */
343
343
  const toDisplayString = (val) => {
344
- return val == null
345
- ? ''
346
- : isArray(val) ||
347
- (isObject(val) &&
348
- (val.toString === objectToString || !isFunction(val.toString)))
349
- ? JSON.stringify(val, replacer, 2)
350
- : String(val);
344
+ return isString(val)
345
+ ? val
346
+ : val == null
347
+ ? ''
348
+ : isArray(val) ||
349
+ (isObject(val) &&
350
+ (val.toString === objectToString || !isFunction(val.toString)))
351
+ ? JSON.stringify(val, replacer, 2)
352
+ : String(val);
351
353
  };
352
354
  const replacer = (_key, val) => {
353
355
  // can't use isRef here since @vue/shared has no deps
@@ -420,6 +422,7 @@ const isReservedProp = /*#__PURE__*/ makeMap(
420
422
  'onVnodeBeforeMount,onVnodeMounted,' +
421
423
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
422
424
  'onVnodeBeforeUnmount,onVnodeUnmounted');
425
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
423
426
  const cacheStringFunction = (fn) => {
424
427
  const cache = Object.create(null);
425
428
  return ((str) => {
@@ -481,7 +484,6 @@ const getGlobalThis = () => {
481
484
  };
482
485
 
483
486
  let activeEffectScope;
484
- const effectScopeStack = [];
485
487
  class EffectScope {
486
488
  constructor(detached = false) {
487
489
  this.active = true;
@@ -496,32 +498,33 @@ class EffectScope {
496
498
  run(fn) {
497
499
  if (this.active) {
498
500
  try {
499
- this.on();
501
+ activeEffectScope = this;
500
502
  return fn();
501
503
  }
502
504
  finally {
503
- this.off();
505
+ activeEffectScope = this.parent;
504
506
  }
505
507
  }
506
508
  }
507
509
  on() {
508
- if (this.active) {
509
- effectScopeStack.push(this);
510
- activeEffectScope = this;
511
- }
510
+ activeEffectScope = this;
512
511
  }
513
512
  off() {
514
- if (this.active) {
515
- effectScopeStack.pop();
516
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
517
- }
513
+ activeEffectScope = this.parent;
518
514
  }
519
515
  stop(fromParent) {
520
516
  if (this.active) {
521
- this.effects.forEach(e => e.stop());
522
- this.cleanups.forEach(cleanup => cleanup());
517
+ let i, l;
518
+ for (i = 0, l = this.effects.length; i < l; i++) {
519
+ this.effects[i].stop();
520
+ }
521
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
522
+ this.cleanups[i]();
523
+ }
523
524
  if (this.scopes) {
524
- this.scopes.forEach(e => e.stop(true));
525
+ for (i = 0, l = this.scopes.length; i < l; i++) {
526
+ this.scopes[i].stop(true);
527
+ }
525
528
  }
526
529
  // nested scope, dereference from parent to avoid memory leaks
527
530
  if (this.parent && !fromParent) {
@@ -539,8 +542,7 @@ class EffectScope {
539
542
  function effectScope(detached) {
540
543
  return new EffectScope(detached);
541
544
  }
542
- function recordEffectScope(effect, scope) {
543
- scope = scope || activeEffectScope;
545
+ function recordEffectScope(effect, scope = activeEffectScope) {
544
546
  if (scope && scope.active) {
545
547
  scope.effects.push(effect);
546
548
  }
@@ -599,7 +601,6 @@ let trackOpBit = 1;
599
601
  * When recursion depth is greater, fall back to using a full cleanup.
600
602
  */
601
603
  const maxMarkerBits = 30;
602
- const effectStack = [];
603
604
  let activeEffect;
604
605
  const ITERATE_KEY = Symbol('');
605
606
  const MAP_KEY_ITERATE_KEY = Symbol('');
@@ -609,35 +610,42 @@ class ReactiveEffect {
609
610
  this.scheduler = scheduler;
610
611
  this.active = true;
611
612
  this.deps = [];
613
+ this.parent = undefined;
612
614
  recordEffectScope(this, scope);
613
615
  }
614
616
  run() {
615
617
  if (!this.active) {
616
618
  return this.fn();
617
619
  }
618
- if (!effectStack.length || !effectStack.includes(this)) {
619
- try {
620
- effectStack.push((activeEffect = this));
621
- enableTracking();
622
- trackOpBit = 1 << ++effectTrackDepth;
623
- if (effectTrackDepth <= maxMarkerBits) {
624
- initDepMarkers(this);
625
- }
626
- else {
627
- cleanupEffect(this);
628
- }
629
- return this.fn();
620
+ let parent = activeEffect;
621
+ let lastShouldTrack = shouldTrack;
622
+ while (parent) {
623
+ if (parent === this) {
624
+ return;
630
625
  }
631
- finally {
632
- if (effectTrackDepth <= maxMarkerBits) {
633
- finalizeDepMarkers(this);
634
- }
635
- trackOpBit = 1 << --effectTrackDepth;
636
- resetTracking();
637
- effectStack.pop();
638
- const n = effectStack.length;
639
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
626
+ parent = parent.parent;
627
+ }
628
+ try {
629
+ this.parent = activeEffect;
630
+ activeEffect = this;
631
+ shouldTrack = true;
632
+ trackOpBit = 1 << ++effectTrackDepth;
633
+ if (effectTrackDepth <= maxMarkerBits) {
634
+ initDepMarkers(this);
635
+ }
636
+ else {
637
+ cleanupEffect(this);
640
638
  }
639
+ return this.fn();
640
+ }
641
+ finally {
642
+ if (effectTrackDepth <= maxMarkerBits) {
643
+ finalizeDepMarkers(this);
644
+ }
645
+ trackOpBit = 1 << --effectTrackDepth;
646
+ activeEffect = this.parent;
647
+ shouldTrack = lastShouldTrack;
648
+ this.parent = undefined;
641
649
  }
642
650
  }
643
651
  stop() {
@@ -685,30 +693,22 @@ function pauseTracking() {
685
693
  trackStack.push(shouldTrack);
686
694
  shouldTrack = false;
687
695
  }
688
- function enableTracking() {
689
- trackStack.push(shouldTrack);
690
- shouldTrack = true;
691
- }
692
696
  function resetTracking() {
693
697
  const last = trackStack.pop();
694
698
  shouldTrack = last === undefined ? true : last;
695
699
  }
696
700
  function track(target, type, key) {
697
- if (!isTracking()) {
698
- return;
699
- }
700
- let depsMap = targetMap.get(target);
701
- if (!depsMap) {
702
- targetMap.set(target, (depsMap = new Map()));
703
- }
704
- let dep = depsMap.get(key);
705
- if (!dep) {
706
- depsMap.set(key, (dep = createDep()));
701
+ if (shouldTrack && activeEffect) {
702
+ let depsMap = targetMap.get(target);
703
+ if (!depsMap) {
704
+ targetMap.set(target, (depsMap = new Map()));
705
+ }
706
+ let dep = depsMap.get(key);
707
+ if (!dep) {
708
+ depsMap.set(key, (dep = createDep()));
709
+ }
710
+ trackEffects(dep);
707
711
  }
708
- trackEffects(dep);
709
- }
710
- function isTracking() {
711
- return shouldTrack && activeEffect !== undefined;
712
712
  }
713
713
  function trackEffects(dep, debuggerEventExtraInfo) {
714
714
  let shouldTrack = false;
@@ -1349,13 +1349,10 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1349
1349
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1350
1350
 
1351
1351
  function trackRefValue(ref) {
1352
- if (isTracking()) {
1352
+ if (shouldTrack && activeEffect) {
1353
1353
  ref = toRaw(ref);
1354
- if (!ref.dep) {
1355
- ref.dep = createDep();
1356
- }
1357
1354
  {
1358
- trackEffects(ref.dep);
1355
+ trackEffects(ref.dep || (ref.dep = createDep()));
1359
1356
  }
1360
1357
  }
1361
1358
  }
@@ -1368,7 +1365,7 @@ function triggerRefValue(ref, newVal) {
1368
1365
  }
1369
1366
  }
1370
1367
  function isRef(r) {
1371
- return Boolean(r && r.__v_isRef === true);
1368
+ return !!(r && r.__v_isRef === true);
1372
1369
  }
1373
1370
  function ref(value) {
1374
1371
  return createRef(value, false);
@@ -4895,7 +4892,7 @@ function createCompatVue(createApp, createSingletonApp) {
4895
4892
  return vm;
4896
4893
  }
4897
4894
  }
4898
- Vue.version = `2.6.14-compat:${"3.2.29"}`;
4895
+ Vue.version = `2.6.14-compat:${"3.2.30"}`;
4899
4896
  Vue.config = singletonApp.config;
4900
4897
  Vue.use = (p, ...options) => {
4901
4898
  if (p && isFunction(p.install)) {
@@ -9000,7 +8997,7 @@ function isMemoSame(cached, memo) {
9000
8997
  }
9001
8998
 
9002
8999
  // Core API ------------------------------------------------------------------
9003
- const version = "3.2.29";
9000
+ const version = "3.2.30";
9004
9001
  const _ssrUtils = {
9005
9002
  createComponentInstance,
9006
9003
  setupComponent,
@@ -15244,7 +15241,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
15244
15241
  }
15245
15242
  }
15246
15243
  }
15247
- else {
15244
+ else if (!isBuiltInDirective(name)) {
15248
15245
  // no built-in transform, this is a user custom directive.
15249
15246
  runtimeDirectives.push(prop);
15250
15247
  // custom dirs may use beforeUpdate so they need to force blocks