@vue/compat 3.2.29 → 3.2.32

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,11 +484,19 @@ const getGlobalThis = () => {
481
484
  };
482
485
 
483
486
  let activeEffectScope;
484
- const effectScopeStack = [];
485
487
  class EffectScope {
486
488
  constructor(detached = false) {
489
+ /**
490
+ * @internal
491
+ */
487
492
  this.active = true;
493
+ /**
494
+ * @internal
495
+ */
488
496
  this.effects = [];
497
+ /**
498
+ * @internal
499
+ */
489
500
  this.cleanups = [];
490
501
  if (!detached && activeEffectScope) {
491
502
  this.parent = activeEffectScope;
@@ -495,33 +506,43 @@ class EffectScope {
495
506
  }
496
507
  run(fn) {
497
508
  if (this.active) {
509
+ const currentEffectScope = activeEffectScope;
498
510
  try {
499
- this.on();
511
+ activeEffectScope = this;
500
512
  return fn();
501
513
  }
502
514
  finally {
503
- this.off();
515
+ activeEffectScope = currentEffectScope;
504
516
  }
505
517
  }
506
518
  }
519
+ /**
520
+ * This should only be called on non-detached scopes
521
+ * @internal
522
+ */
507
523
  on() {
508
- if (this.active) {
509
- effectScopeStack.push(this);
510
- activeEffectScope = this;
511
- }
524
+ activeEffectScope = this;
512
525
  }
526
+ /**
527
+ * This should only be called on non-detached scopes
528
+ * @internal
529
+ */
513
530
  off() {
514
- if (this.active) {
515
- effectScopeStack.pop();
516
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
517
- }
531
+ activeEffectScope = this.parent;
518
532
  }
519
533
  stop(fromParent) {
520
534
  if (this.active) {
521
- this.effects.forEach(e => e.stop());
522
- this.cleanups.forEach(cleanup => cleanup());
535
+ let i, l;
536
+ for (i = 0, l = this.effects.length; i < l; i++) {
537
+ this.effects[i].stop();
538
+ }
539
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
540
+ this.cleanups[i]();
541
+ }
523
542
  if (this.scopes) {
524
- this.scopes.forEach(e => e.stop(true));
543
+ for (i = 0, l = this.scopes.length; i < l; i++) {
544
+ this.scopes[i].stop(true);
545
+ }
525
546
  }
526
547
  // nested scope, dereference from parent to avoid memory leaks
527
548
  if (this.parent && !fromParent) {
@@ -539,8 +560,7 @@ class EffectScope {
539
560
  function effectScope(detached) {
540
561
  return new EffectScope(detached);
541
562
  }
542
- function recordEffectScope(effect, scope) {
543
- scope = scope || activeEffectScope;
563
+ function recordEffectScope(effect, scope = activeEffectScope) {
544
564
  if (scope && scope.active) {
545
565
  scope.effects.push(effect);
546
566
  }
@@ -599,7 +619,6 @@ let trackOpBit = 1;
599
619
  * When recursion depth is greater, fall back to using a full cleanup.
600
620
  */
601
621
  const maxMarkerBits = 30;
602
- const effectStack = [];
603
622
  let activeEffect;
604
623
  const ITERATE_KEY = Symbol('');
605
624
  const MAP_KEY_ITERATE_KEY = Symbol('');
@@ -609,35 +628,42 @@ class ReactiveEffect {
609
628
  this.scheduler = scheduler;
610
629
  this.active = true;
611
630
  this.deps = [];
631
+ this.parent = undefined;
612
632
  recordEffectScope(this, scope);
613
633
  }
614
634
  run() {
615
635
  if (!this.active) {
616
636
  return this.fn();
617
637
  }
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();
638
+ let parent = activeEffect;
639
+ let lastShouldTrack = shouldTrack;
640
+ while (parent) {
641
+ if (parent === this) {
642
+ return;
630
643
  }
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;
644
+ parent = parent.parent;
645
+ }
646
+ try {
647
+ this.parent = activeEffect;
648
+ activeEffect = this;
649
+ shouldTrack = true;
650
+ trackOpBit = 1 << ++effectTrackDepth;
651
+ if (effectTrackDepth <= maxMarkerBits) {
652
+ initDepMarkers(this);
640
653
  }
654
+ else {
655
+ cleanupEffect(this);
656
+ }
657
+ return this.fn();
658
+ }
659
+ finally {
660
+ if (effectTrackDepth <= maxMarkerBits) {
661
+ finalizeDepMarkers(this);
662
+ }
663
+ trackOpBit = 1 << --effectTrackDepth;
664
+ activeEffect = this.parent;
665
+ shouldTrack = lastShouldTrack;
666
+ this.parent = undefined;
641
667
  }
642
668
  }
643
669
  stop() {
@@ -685,30 +711,22 @@ function pauseTracking() {
685
711
  trackStack.push(shouldTrack);
686
712
  shouldTrack = false;
687
713
  }
688
- function enableTracking() {
689
- trackStack.push(shouldTrack);
690
- shouldTrack = true;
691
- }
692
714
  function resetTracking() {
693
715
  const last = trackStack.pop();
694
716
  shouldTrack = last === undefined ? true : last;
695
717
  }
696
718
  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()));
719
+ if (shouldTrack && activeEffect) {
720
+ let depsMap = targetMap.get(target);
721
+ if (!depsMap) {
722
+ targetMap.set(target, (depsMap = new Map()));
723
+ }
724
+ let dep = depsMap.get(key);
725
+ if (!dep) {
726
+ depsMap.set(key, (dep = createDep()));
727
+ }
728
+ trackEffects(dep);
707
729
  }
708
- trackEffects(dep);
709
- }
710
- function isTracking() {
711
- return shouldTrack && activeEffect !== undefined;
712
730
  }
713
731
  function trackEffects(dep, debuggerEventExtraInfo) {
714
732
  let shouldTrack = false;
@@ -1349,13 +1367,10 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1349
1367
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1350
1368
 
1351
1369
  function trackRefValue(ref) {
1352
- if (isTracking()) {
1370
+ if (shouldTrack && activeEffect) {
1353
1371
  ref = toRaw(ref);
1354
- if (!ref.dep) {
1355
- ref.dep = createDep();
1356
- }
1357
1372
  {
1358
- trackEffects(ref.dep);
1373
+ trackEffects(ref.dep || (ref.dep = createDep()));
1359
1374
  }
1360
1375
  }
1361
1376
  }
@@ -1368,7 +1383,7 @@ function triggerRefValue(ref, newVal) {
1368
1383
  }
1369
1384
  }
1370
1385
  function isRef(r) {
1371
- return Boolean(r && r.__v_isRef === true);
1386
+ return !!(r && r.__v_isRef === true);
1372
1387
  }
1373
1388
  function ref(value) {
1374
1389
  return createRef(value, false);
@@ -3436,20 +3451,24 @@ function setTransitionHooks(vnode, hooks) {
3436
3451
  vnode.transition = hooks;
3437
3452
  }
3438
3453
  }
3439
- function getTransitionRawChildren(children, keepComment = false) {
3454
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3440
3455
  let ret = [];
3441
3456
  let keyedFragmentCount = 0;
3442
3457
  for (let i = 0; i < children.length; i++) {
3443
- const child = children[i];
3458
+ let child = children[i];
3459
+ // #5360 inherit parent key in case of <template v-for>
3460
+ const key = parentKey == null
3461
+ ? child.key
3462
+ : String(parentKey) + String(child.key != null ? child.key : i);
3444
3463
  // handle fragment children case, e.g. v-for
3445
3464
  if (child.type === Fragment) {
3446
3465
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3447
3466
  keyedFragmentCount++;
3448
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3467
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3449
3468
  }
3450
3469
  // comment placeholders should be skipped, e.g. v-if
3451
3470
  else if (keepComment || child.type !== Comment) {
3452
- ret.push(child);
3471
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3453
3472
  }
3454
3473
  }
3455
3474
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4383,6 +4402,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4383
4402
  const propsToUpdate = instance.vnode.dynamicProps;
4384
4403
  for (let i = 0; i < propsToUpdate.length; i++) {
4385
4404
  let key = propsToUpdate[i];
4405
+ // skip if the prop key is a declared emit event listener
4406
+ if (isEmitListener(instance.emitsOptions, key)) {
4407
+ continue;
4408
+ }
4386
4409
  // PROPS flag guarantees rawProps to be non-null
4387
4410
  const value = rawProps[key];
4388
4411
  if (options) {
@@ -4801,7 +4824,8 @@ function withDirectives(vnode, directives) {
4801
4824
  if (internalInstance === null) {
4802
4825
  return vnode;
4803
4826
  }
4804
- const instance = internalInstance.proxy;
4827
+ const instance = getExposeProxy(internalInstance) ||
4828
+ internalInstance.proxy;
4805
4829
  const bindings = vnode.dirs || (vnode.dirs = []);
4806
4830
  for (let i = 0; i < directives.length; i++) {
4807
4831
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4895,7 +4919,7 @@ function createCompatVue(createApp, createSingletonApp) {
4895
4919
  return vm;
4896
4920
  }
4897
4921
  }
4898
- Vue.version = `2.6.14-compat:${"3.2.29"}`;
4922
+ Vue.version = `2.6.14-compat:${"3.2.32"}`;
4899
4923
  Vue.config = singletonApp.config;
4900
4924
  Vue.use = (p, ...options) => {
4901
4925
  if (p && isFunction(p.install)) {
@@ -5282,6 +5306,9 @@ function createAppContext() {
5282
5306
  let uid = 0;
5283
5307
  function createAppAPI(render, hydrate) {
5284
5308
  return function createApp(rootComponent, rootProps = null) {
5309
+ if (!isFunction(rootComponent)) {
5310
+ rootComponent = Object.assign({}, rootComponent);
5311
+ }
5285
5312
  if (rootProps != null && !isObject(rootProps)) {
5286
5313
  rootProps = null;
5287
5314
  }
@@ -5424,6 +5451,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5424
5451
  if (!isArray(existing)) {
5425
5452
  if (_isString) {
5426
5453
  refs[ref] = [refValue];
5454
+ if (hasOwn(setupState, ref)) {
5455
+ setupState[ref] = refs[ref];
5456
+ }
5427
5457
  }
5428
5458
  else {
5429
5459
  ref.value = [refValue];
@@ -5610,6 +5640,7 @@ function createHydrationFunctions(rendererInternals) {
5610
5640
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5611
5641
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5612
5642
  // skip props & children if this is hoisted static nodes
5643
+ // #5405 in dev, always hydrate children for HMR
5613
5644
  if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5614
5645
  if (dirs) {
5615
5646
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
@@ -8442,9 +8473,11 @@ const PublicInstanceProxyHandlers = {
8442
8473
  const { data, setupState, ctx } = instance;
8443
8474
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8444
8475
  setupState[key] = value;
8476
+ return true;
8445
8477
  }
8446
8478
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8447
8479
  data[key] = value;
8480
+ return true;
8448
8481
  }
8449
8482
  else if (hasOwn(instance.props, key)) {
8450
8483
  return false;
@@ -8468,6 +8501,16 @@ const PublicInstanceProxyHandlers = {
8468
8501
  hasOwn(ctx, key) ||
8469
8502
  hasOwn(publicPropertiesMap, key) ||
8470
8503
  hasOwn(appContext.config.globalProperties, key));
8504
+ },
8505
+ defineProperty(target, key, descriptor) {
8506
+ if (descriptor.get != null) {
8507
+ // invalidate key cache of a getter based property #5417
8508
+ target.$.accessCache[key] = 0;
8509
+ }
8510
+ else if (hasOwn(descriptor, 'value')) {
8511
+ this.set(target, key, descriptor.value, null);
8512
+ }
8513
+ return Reflect.defineProperty(target, key, descriptor);
8471
8514
  }
8472
8515
  };
8473
8516
  const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
@@ -9000,7 +9043,7 @@ function isMemoSame(cached, memo) {
9000
9043
  }
9001
9044
 
9002
9045
  // Core API ------------------------------------------------------------------
9003
- const version = "3.2.29";
9046
+ const version = "3.2.32";
9004
9047
  const _ssrUtils = {
9005
9048
  createComponentInstance,
9006
9049
  setupComponent,
@@ -15244,7 +15287,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
15244
15287
  }
15245
15288
  }
15246
15289
  }
15247
- else {
15290
+ else if (!isBuiltInDirective(name)) {
15248
15291
  // no built-in transform, this is a user custom directive.
15249
15292
  runtimeDirectives.push(prop);
15250
15293
  // custom dirs may use beforeUpdate so they need to force blocks