vue 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.
@@ -277,13 +277,15 @@ function looseIndexOf(arr, val) {
277
277
  * @private
278
278
  */
279
279
  const toDisplayString = (val) => {
280
- return val == null
281
- ? ''
282
- : isArray(val) ||
283
- (isObject(val) &&
284
- (val.toString === objectToString || !isFunction(val.toString)))
285
- ? JSON.stringify(val, replacer, 2)
286
- : String(val);
280
+ return isString(val)
281
+ ? val
282
+ : val == null
283
+ ? ''
284
+ : isArray(val) ||
285
+ (isObject(val) &&
286
+ (val.toString === objectToString || !isFunction(val.toString)))
287
+ ? JSON.stringify(val, replacer, 2)
288
+ : String(val);
287
289
  };
288
290
  const replacer = (_key, val) => {
289
291
  // can't use isRef here since @vue/shared has no deps
@@ -357,6 +359,7 @@ const isReservedProp = /*#__PURE__*/ makeMap(
357
359
  'onVnodeBeforeMount,onVnodeMounted,' +
358
360
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
359
361
  'onVnodeBeforeUnmount,onVnodeUnmounted');
362
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
360
363
  const cacheStringFunction = (fn) => {
361
364
  const cache = Object.create(null);
362
365
  return ((str) => {
@@ -422,11 +425,19 @@ function warn(msg, ...args) {
422
425
  }
423
426
 
424
427
  let activeEffectScope;
425
- const effectScopeStack = [];
426
428
  class EffectScope {
427
429
  constructor(detached = false) {
430
+ /**
431
+ * @internal
432
+ */
428
433
  this.active = true;
434
+ /**
435
+ * @internal
436
+ */
429
437
  this.effects = [];
438
+ /**
439
+ * @internal
440
+ */
430
441
  this.cleanups = [];
431
442
  if (!detached && activeEffectScope) {
432
443
  this.parent = activeEffectScope;
@@ -436,36 +447,46 @@ class EffectScope {
436
447
  }
437
448
  run(fn) {
438
449
  if (this.active) {
450
+ const currentEffectScope = activeEffectScope;
439
451
  try {
440
- this.on();
452
+ activeEffectScope = this;
441
453
  return fn();
442
454
  }
443
455
  finally {
444
- this.off();
456
+ activeEffectScope = currentEffectScope;
445
457
  }
446
458
  }
447
459
  else {
448
460
  warn(`cannot run an inactive effect scope.`);
449
461
  }
450
462
  }
463
+ /**
464
+ * This should only be called on non-detached scopes
465
+ * @internal
466
+ */
451
467
  on() {
452
- if (this.active) {
453
- effectScopeStack.push(this);
454
- activeEffectScope = this;
455
- }
468
+ activeEffectScope = this;
456
469
  }
470
+ /**
471
+ * This should only be called on non-detached scopes
472
+ * @internal
473
+ */
457
474
  off() {
458
- if (this.active) {
459
- effectScopeStack.pop();
460
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
461
- }
475
+ activeEffectScope = this.parent;
462
476
  }
463
477
  stop(fromParent) {
464
478
  if (this.active) {
465
- this.effects.forEach(e => e.stop());
466
- this.cleanups.forEach(cleanup => cleanup());
479
+ let i, l;
480
+ for (i = 0, l = this.effects.length; i < l; i++) {
481
+ this.effects[i].stop();
482
+ }
483
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
484
+ this.cleanups[i]();
485
+ }
467
486
  if (this.scopes) {
468
- this.scopes.forEach(e => e.stop(true));
487
+ for (i = 0, l = this.scopes.length; i < l; i++) {
488
+ this.scopes[i].stop(true);
489
+ }
469
490
  }
470
491
  // nested scope, dereference from parent to avoid memory leaks
471
492
  if (this.parent && !fromParent) {
@@ -483,8 +504,7 @@ class EffectScope {
483
504
  function effectScope(detached) {
484
505
  return new EffectScope(detached);
485
506
  }
486
- function recordEffectScope(effect, scope) {
487
- scope = scope || activeEffectScope;
507
+ function recordEffectScope(effect, scope = activeEffectScope) {
488
508
  if (scope && scope.active) {
489
509
  scope.effects.push(effect);
490
510
  }
@@ -547,7 +567,6 @@ let trackOpBit = 1;
547
567
  * When recursion depth is greater, fall back to using a full cleanup.
548
568
  */
549
569
  const maxMarkerBits = 30;
550
- const effectStack = [];
551
570
  let activeEffect;
552
571
  const ITERATE_KEY = Symbol('iterate' );
553
572
  const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
@@ -557,35 +576,42 @@ class ReactiveEffect {
557
576
  this.scheduler = scheduler;
558
577
  this.active = true;
559
578
  this.deps = [];
579
+ this.parent = undefined;
560
580
  recordEffectScope(this, scope);
561
581
  }
562
582
  run() {
563
583
  if (!this.active) {
564
584
  return this.fn();
565
585
  }
566
- if (!effectStack.length || !effectStack.includes(this)) {
567
- try {
568
- effectStack.push((activeEffect = this));
569
- enableTracking();
570
- trackOpBit = 1 << ++effectTrackDepth;
571
- if (effectTrackDepth <= maxMarkerBits) {
572
- initDepMarkers(this);
573
- }
574
- else {
575
- cleanupEffect(this);
576
- }
577
- return this.fn();
586
+ let parent = activeEffect;
587
+ let lastShouldTrack = shouldTrack;
588
+ while (parent) {
589
+ if (parent === this) {
590
+ return;
578
591
  }
579
- finally {
580
- if (effectTrackDepth <= maxMarkerBits) {
581
- finalizeDepMarkers(this);
582
- }
583
- trackOpBit = 1 << --effectTrackDepth;
584
- resetTracking();
585
- effectStack.pop();
586
- const n = effectStack.length;
587
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
592
+ parent = parent.parent;
593
+ }
594
+ try {
595
+ this.parent = activeEffect;
596
+ activeEffect = this;
597
+ shouldTrack = true;
598
+ trackOpBit = 1 << ++effectTrackDepth;
599
+ if (effectTrackDepth <= maxMarkerBits) {
600
+ initDepMarkers(this);
601
+ }
602
+ else {
603
+ cleanupEffect(this);
604
+ }
605
+ return this.fn();
606
+ }
607
+ finally {
608
+ if (effectTrackDepth <= maxMarkerBits) {
609
+ finalizeDepMarkers(this);
588
610
  }
611
+ trackOpBit = 1 << --effectTrackDepth;
612
+ activeEffect = this.parent;
613
+ shouldTrack = lastShouldTrack;
614
+ this.parent = undefined;
589
615
  }
590
616
  }
591
617
  stop() {
@@ -633,32 +659,24 @@ function pauseTracking() {
633
659
  trackStack.push(shouldTrack);
634
660
  shouldTrack = false;
635
661
  }
636
- function enableTracking() {
637
- trackStack.push(shouldTrack);
638
- shouldTrack = true;
639
- }
640
662
  function resetTracking() {
641
663
  const last = trackStack.pop();
642
664
  shouldTrack = last === undefined ? true : last;
643
665
  }
644
666
  function track(target, type, key) {
645
- if (!isTracking()) {
646
- return;
647
- }
648
- let depsMap = targetMap.get(target);
649
- if (!depsMap) {
650
- targetMap.set(target, (depsMap = new Map()));
651
- }
652
- let dep = depsMap.get(key);
653
- if (!dep) {
654
- depsMap.set(key, (dep = createDep()));
667
+ if (shouldTrack && activeEffect) {
668
+ let depsMap = targetMap.get(target);
669
+ if (!depsMap) {
670
+ targetMap.set(target, (depsMap = new Map()));
671
+ }
672
+ let dep = depsMap.get(key);
673
+ if (!dep) {
674
+ depsMap.set(key, (dep = createDep()));
675
+ }
676
+ const eventInfo = { effect: activeEffect, target, type, key }
677
+ ;
678
+ trackEffects(dep, eventInfo);
655
679
  }
656
- const eventInfo = { effect: activeEffect, target, type, key }
657
- ;
658
- trackEffects(dep, eventInfo);
659
- }
660
- function isTracking() {
661
- return shouldTrack && activeEffect !== undefined;
662
680
  }
663
681
  function trackEffects(dep, debuggerEventExtraInfo) {
664
682
  let shouldTrack = false;
@@ -676,9 +694,7 @@ function trackEffects(dep, debuggerEventExtraInfo) {
676
694
  dep.add(activeEffect);
677
695
  activeEffect.deps.push(dep);
678
696
  if (activeEffect.onTrack) {
679
- activeEffect.onTrack(Object.assign({
680
- effect: activeEffect
681
- }, debuggerEventExtraInfo));
697
+ activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
682
698
  }
683
699
  }
684
700
  }
@@ -1343,13 +1359,10 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1343
1359
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1344
1360
 
1345
1361
  function trackRefValue(ref) {
1346
- if (isTracking()) {
1362
+ if (shouldTrack && activeEffect) {
1347
1363
  ref = toRaw(ref);
1348
- if (!ref.dep) {
1349
- ref.dep = createDep();
1350
- }
1351
1364
  {
1352
- trackEffects(ref.dep, {
1365
+ trackEffects(ref.dep || (ref.dep = createDep()), {
1353
1366
  target: ref,
1354
1367
  type: "get" /* GET */,
1355
1368
  key: 'value'
@@ -1371,7 +1384,7 @@ function triggerRefValue(ref, newVal) {
1371
1384
  }
1372
1385
  }
1373
1386
  function isRef(r) {
1374
- return Boolean(r && r.__v_isRef === true);
1387
+ return !!(r && r.__v_isRef === true);
1375
1388
  }
1376
1389
  function ref(value) {
1377
1390
  return createRef(value, false);
@@ -3166,12 +3179,10 @@ function watchEffect(effect, options) {
3166
3179
  return doWatch(effect, null, options);
3167
3180
  }
3168
3181
  function watchPostEffect(effect, options) {
3169
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3170
- ));
3182
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
3171
3183
  }
3172
3184
  function watchSyncEffect(effect, options) {
3173
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3174
- ));
3185
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
3175
3186
  }
3176
3187
  // initial value for watchers to trigger on undefined initial values
3177
3188
  const INITIAL_WATCHER_VALUE = {};
@@ -3468,7 +3479,9 @@ const BaseTransitionImpl = {
3468
3479
  const { mode } = rawProps;
3469
3480
  // check mode
3470
3481
  if (mode &&
3471
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3482
+ mode !== 'in-out' &&
3483
+ mode !== 'out-in' &&
3484
+ mode !== 'default') {
3472
3485
  warn$1(`invalid <transition> mode: ${mode}`);
3473
3486
  }
3474
3487
  // at this point children has a guaranteed length of 1.
@@ -3695,20 +3708,24 @@ function setTransitionHooks(vnode, hooks) {
3695
3708
  vnode.transition = hooks;
3696
3709
  }
3697
3710
  }
3698
- function getTransitionRawChildren(children, keepComment = false) {
3711
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3699
3712
  let ret = [];
3700
3713
  let keyedFragmentCount = 0;
3701
3714
  for (let i = 0; i < children.length; i++) {
3702
- const child = children[i];
3715
+ let child = children[i];
3716
+ // #5360 inherit parent key in case of <template v-for>
3717
+ const key = parentKey == null
3718
+ ? child.key
3719
+ : String(parentKey) + String(child.key != null ? child.key : i);
3703
3720
  // handle fragment children case, e.g. v-for
3704
3721
  if (child.type === Fragment) {
3705
3722
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3706
3723
  keyedFragmentCount++;
3707
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3724
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3708
3725
  }
3709
3726
  // comment placeholders should be skipped, e.g. v-if
3710
3727
  else if (keepComment || child.type !== Comment) {
3711
- ret.push(child);
3728
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3712
3729
  }
3713
3730
  }
3714
3731
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4674,6 +4691,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4674
4691
  const propsToUpdate = instance.vnode.dynamicProps;
4675
4692
  for (let i = 0; i < propsToUpdate.length; i++) {
4676
4693
  let key = propsToUpdate[i];
4694
+ // skip if the prop key is a declared emit event listener
4695
+ if (isEmitListener(instance.emitsOptions, key)) {
4696
+ continue;
4697
+ }
4677
4698
  // PROPS flag guarantees rawProps to be non-null
4678
4699
  const value = rawProps[key];
4679
4700
  if (options) {
@@ -5184,7 +5205,6 @@ return withDirectives(h(comp), [
5184
5205
  [bar, this.y]
5185
5206
  ])
5186
5207
  */
5187
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5188
5208
  function validateDirectiveName(name) {
5189
5209
  if (isBuiltInDirective(name)) {
5190
5210
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5199,7 +5219,8 @@ function withDirectives(vnode, directives) {
5199
5219
  warn$1(`withDirectives can only be used inside render functions.`);
5200
5220
  return vnode;
5201
5221
  }
5202
- const instance = internalInstance.proxy;
5222
+ const instance = getExposeProxy(internalInstance) ||
5223
+ internalInstance.proxy;
5203
5224
  const bindings = vnode.dirs || (vnode.dirs = []);
5204
5225
  for (let i = 0; i < directives.length; i++) {
5205
5226
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -5271,6 +5292,9 @@ function createAppContext() {
5271
5292
  let uid = 0;
5272
5293
  function createAppAPI(render, hydrate) {
5273
5294
  return function createApp(rootComponent, rootProps = null) {
5295
+ if (!isFunction(rootComponent)) {
5296
+ rootComponent = Object.assign({}, rootComponent);
5297
+ }
5274
5298
  if (rootProps != null && !isObject(rootProps)) {
5275
5299
  warn$1(`root props passed to app.mount() must be an object.`);
5276
5300
  rootProps = null;
@@ -5467,6 +5491,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5467
5491
  if (!isArray(existing)) {
5468
5492
  if (_isString) {
5469
5493
  refs[ref] = [refValue];
5494
+ if (hasOwn(setupState, ref)) {
5495
+ setupState[ref] = refs[ref];
5496
+ }
5470
5497
  }
5471
5498
  else {
5472
5499
  ref.value = [refValue];
@@ -5665,7 +5692,8 @@ function createHydrationFunctions(rendererInternals) {
5665
5692
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5666
5693
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5667
5694
  // skip props & children if this is hoisted static nodes
5668
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5695
+ // #5405 in dev, always hydrate children for HMR
5696
+ {
5669
5697
  if (dirs) {
5670
5698
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
5671
5699
  }
@@ -5838,7 +5866,7 @@ function startMeasure(instance, type) {
5838
5866
  perf.mark(`vue-${type}-${instance.uid}`);
5839
5867
  }
5840
5868
  {
5841
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5869
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
5842
5870
  }
5843
5871
  }
5844
5872
  function endMeasure(instance, type) {
@@ -5851,7 +5879,7 @@ function endMeasure(instance, type) {
5851
5879
  perf.clearMarks(endTag);
5852
5880
  }
5853
5881
  {
5854
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5882
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
5855
5883
  }
5856
5884
  }
5857
5885
  function isSupported() {
@@ -8199,9 +8227,11 @@ const PublicInstanceProxyHandlers = {
8199
8227
  const { data, setupState, ctx } = instance;
8200
8228
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8201
8229
  setupState[key] = value;
8230
+ return true;
8202
8231
  }
8203
8232
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8204
8233
  data[key] = value;
8234
+ return true;
8205
8235
  }
8206
8236
  else if (hasOwn(instance.props, key)) {
8207
8237
  warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
@@ -8235,6 +8265,16 @@ const PublicInstanceProxyHandlers = {
8235
8265
  hasOwn(ctx, key) ||
8236
8266
  hasOwn(publicPropertiesMap, key) ||
8237
8267
  hasOwn(appContext.config.globalProperties, key));
8268
+ },
8269
+ defineProperty(target, key, descriptor) {
8270
+ if (descriptor.get != null) {
8271
+ // invalidate key cache of a getter based property #5417
8272
+ target.$.accessCache[key] = 0;
8273
+ }
8274
+ else if (hasOwn(descriptor, 'value')) {
8275
+ this.set(target, key, descriptor.value, null);
8276
+ }
8277
+ return Reflect.defineProperty(target, key, descriptor);
8238
8278
  }
8239
8279
  };
8240
8280
  {
@@ -9110,7 +9150,7 @@ function isMemoSame(cached, memo) {
9110
9150
  }
9111
9151
 
9112
9152
  // Core API ------------------------------------------------------------------
9113
- const version = "3.2.29";
9153
+ const version = "3.2.32";
9114
9154
  /**
9115
9155
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9116
9156
  * @internal
@@ -11538,13 +11578,13 @@ const deprecationData = {
11538
11578
  message: `Platform-native elements with "is" prop will no longer be ` +
11539
11579
  `treated as components in Vue 3 unless the "is" value is explicitly ` +
11540
11580
  `prefixed with "vue:".`,
11541
- link: `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
11581
+ link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
11542
11582
  },
11543
11583
  ["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
11544
11584
  message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
11545
11585
  `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
11546
11586
  `\`v-model:${key}\`.`,
11547
- link: `https://v3.vuejs.org/guide/migration/v-model.html`
11587
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
11548
11588
  },
11549
11589
  ["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
11550
11590
  message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
@@ -11556,11 +11596,11 @@ const deprecationData = {
11556
11596
  `that appears before v-bind in the case of conflict. ` +
11557
11597
  `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
11558
11598
  `You can also suppress this warning if the usage is intended.`,
11559
- link: `https://v3.vuejs.org/guide/migration/v-bind.html`
11599
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
11560
11600
  },
11561
11601
  ["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
11562
11602
  message: `.native modifier for v-on has been removed as is no longer necessary.`,
11563
- link: `https://v3.vuejs.org/guide/migration/v-on-native-modifier-removed.html`
11603
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
11564
11604
  },
11565
11605
  ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
11566
11606
  message: `v-if / v-for precedence when used on the same element has changed ` +
@@ -11568,7 +11608,7 @@ const deprecationData = {
11568
11608
  `access to v-for scope variables. It is best to avoid the ambiguity ` +
11569
11609
  `with <template> tags or use a computed property that filters v-for ` +
11570
11610
  `data source.`,
11571
- link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
11611
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
11572
11612
  },
11573
11613
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
11574
11614
  message: `<template> with no special directives will render as a native template ` +
@@ -11576,13 +11616,13 @@ const deprecationData = {
11576
11616
  },
11577
11617
  ["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
11578
11618
  message: `"inline-template" has been removed in Vue 3.`,
11579
- link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
11619
+ link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
11580
11620
  },
11581
11621
  ["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
11582
11622
  message: `filters have been removed in Vue 3. ` +
11583
11623
  `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
11584
11624
  `Use method calls or computed properties instead.`,
11585
- link: `https://v3.vuejs.org/guide/migration/filters.html`
11625
+ link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
11586
11626
  }
11587
11627
  };
11588
11628
  function getCompatValue(key, context) {
@@ -14586,7 +14626,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
14586
14626
  }
14587
14627
  }
14588
14628
  }
14589
- else {
14629
+ else if (!isBuiltInDirective(name)) {
14590
14630
  // no built-in transform, this is a user custom directive.
14591
14631
  runtimeDirectives.push(prop);
14592
14632
  // custom dirs may use beforeUpdate so they need to force blocks