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.
@@ -280,13 +280,15 @@ var Vue = (function (exports) {
280
280
  * @private
281
281
  */
282
282
  const toDisplayString = (val) => {
283
- return val == null
284
- ? ''
285
- : isArray(val) ||
286
- (isObject(val) &&
287
- (val.toString === objectToString || !isFunction(val.toString)))
288
- ? JSON.stringify(val, replacer, 2)
289
- : String(val);
283
+ return isString(val)
284
+ ? val
285
+ : val == null
286
+ ? ''
287
+ : isArray(val) ||
288
+ (isObject(val) &&
289
+ (val.toString === objectToString || !isFunction(val.toString)))
290
+ ? JSON.stringify(val, replacer, 2)
291
+ : String(val);
290
292
  };
291
293
  const replacer = (_key, val) => {
292
294
  // can't use isRef here since @vue/shared has no deps
@@ -360,6 +362,7 @@ var Vue = (function (exports) {
360
362
  'onVnodeBeforeMount,onVnodeMounted,' +
361
363
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
362
364
  'onVnodeBeforeUnmount,onVnodeUnmounted');
365
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
363
366
  const cacheStringFunction = (fn) => {
364
367
  const cache = Object.create(null);
365
368
  return ((str) => {
@@ -425,11 +428,19 @@ var Vue = (function (exports) {
425
428
  }
426
429
 
427
430
  let activeEffectScope;
428
- const effectScopeStack = [];
429
431
  class EffectScope {
430
432
  constructor(detached = false) {
433
+ /**
434
+ * @internal
435
+ */
431
436
  this.active = true;
437
+ /**
438
+ * @internal
439
+ */
432
440
  this.effects = [];
441
+ /**
442
+ * @internal
443
+ */
433
444
  this.cleanups = [];
434
445
  if (!detached && activeEffectScope) {
435
446
  this.parent = activeEffectScope;
@@ -439,36 +450,46 @@ var Vue = (function (exports) {
439
450
  }
440
451
  run(fn) {
441
452
  if (this.active) {
453
+ const currentEffectScope = activeEffectScope;
442
454
  try {
443
- this.on();
455
+ activeEffectScope = this;
444
456
  return fn();
445
457
  }
446
458
  finally {
447
- this.off();
459
+ activeEffectScope = currentEffectScope;
448
460
  }
449
461
  }
450
462
  else {
451
463
  warn(`cannot run an inactive effect scope.`);
452
464
  }
453
465
  }
466
+ /**
467
+ * This should only be called on non-detached scopes
468
+ * @internal
469
+ */
454
470
  on() {
455
- if (this.active) {
456
- effectScopeStack.push(this);
457
- activeEffectScope = this;
458
- }
471
+ activeEffectScope = this;
459
472
  }
473
+ /**
474
+ * This should only be called on non-detached scopes
475
+ * @internal
476
+ */
460
477
  off() {
461
- if (this.active) {
462
- effectScopeStack.pop();
463
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
464
- }
478
+ activeEffectScope = this.parent;
465
479
  }
466
480
  stop(fromParent) {
467
481
  if (this.active) {
468
- this.effects.forEach(e => e.stop());
469
- this.cleanups.forEach(cleanup => cleanup());
482
+ let i, l;
483
+ for (i = 0, l = this.effects.length; i < l; i++) {
484
+ this.effects[i].stop();
485
+ }
486
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
487
+ this.cleanups[i]();
488
+ }
470
489
  if (this.scopes) {
471
- this.scopes.forEach(e => e.stop(true));
490
+ for (i = 0, l = this.scopes.length; i < l; i++) {
491
+ this.scopes[i].stop(true);
492
+ }
472
493
  }
473
494
  // nested scope, dereference from parent to avoid memory leaks
474
495
  if (this.parent && !fromParent) {
@@ -486,8 +507,7 @@ var Vue = (function (exports) {
486
507
  function effectScope(detached) {
487
508
  return new EffectScope(detached);
488
509
  }
489
- function recordEffectScope(effect, scope) {
490
- scope = scope || activeEffectScope;
510
+ function recordEffectScope(effect, scope = activeEffectScope) {
491
511
  if (scope && scope.active) {
492
512
  scope.effects.push(effect);
493
513
  }
@@ -550,7 +570,6 @@ var Vue = (function (exports) {
550
570
  * When recursion depth is greater, fall back to using a full cleanup.
551
571
  */
552
572
  const maxMarkerBits = 30;
553
- const effectStack = [];
554
573
  let activeEffect;
555
574
  const ITERATE_KEY = Symbol('iterate' );
556
575
  const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
@@ -560,35 +579,42 @@ var Vue = (function (exports) {
560
579
  this.scheduler = scheduler;
561
580
  this.active = true;
562
581
  this.deps = [];
582
+ this.parent = undefined;
563
583
  recordEffectScope(this, scope);
564
584
  }
565
585
  run() {
566
586
  if (!this.active) {
567
587
  return this.fn();
568
588
  }
569
- if (!effectStack.length || !effectStack.includes(this)) {
570
- try {
571
- effectStack.push((activeEffect = this));
572
- enableTracking();
573
- trackOpBit = 1 << ++effectTrackDepth;
574
- if (effectTrackDepth <= maxMarkerBits) {
575
- initDepMarkers(this);
576
- }
577
- else {
578
- cleanupEffect(this);
579
- }
580
- return this.fn();
589
+ let parent = activeEffect;
590
+ let lastShouldTrack = shouldTrack;
591
+ while (parent) {
592
+ if (parent === this) {
593
+ return;
581
594
  }
582
- finally {
583
- if (effectTrackDepth <= maxMarkerBits) {
584
- finalizeDepMarkers(this);
585
- }
586
- trackOpBit = 1 << --effectTrackDepth;
587
- resetTracking();
588
- effectStack.pop();
589
- const n = effectStack.length;
590
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
595
+ parent = parent.parent;
596
+ }
597
+ try {
598
+ this.parent = activeEffect;
599
+ activeEffect = this;
600
+ shouldTrack = true;
601
+ trackOpBit = 1 << ++effectTrackDepth;
602
+ if (effectTrackDepth <= maxMarkerBits) {
603
+ initDepMarkers(this);
604
+ }
605
+ else {
606
+ cleanupEffect(this);
607
+ }
608
+ return this.fn();
609
+ }
610
+ finally {
611
+ if (effectTrackDepth <= maxMarkerBits) {
612
+ finalizeDepMarkers(this);
591
613
  }
614
+ trackOpBit = 1 << --effectTrackDepth;
615
+ activeEffect = this.parent;
616
+ shouldTrack = lastShouldTrack;
617
+ this.parent = undefined;
592
618
  }
593
619
  }
594
620
  stop() {
@@ -636,32 +662,24 @@ var Vue = (function (exports) {
636
662
  trackStack.push(shouldTrack);
637
663
  shouldTrack = false;
638
664
  }
639
- function enableTracking() {
640
- trackStack.push(shouldTrack);
641
- shouldTrack = true;
642
- }
643
665
  function resetTracking() {
644
666
  const last = trackStack.pop();
645
667
  shouldTrack = last === undefined ? true : last;
646
668
  }
647
669
  function track(target, type, key) {
648
- if (!isTracking()) {
649
- return;
650
- }
651
- let depsMap = targetMap.get(target);
652
- if (!depsMap) {
653
- targetMap.set(target, (depsMap = new Map()));
654
- }
655
- let dep = depsMap.get(key);
656
- if (!dep) {
657
- depsMap.set(key, (dep = createDep()));
670
+ if (shouldTrack && activeEffect) {
671
+ let depsMap = targetMap.get(target);
672
+ if (!depsMap) {
673
+ targetMap.set(target, (depsMap = new Map()));
674
+ }
675
+ let dep = depsMap.get(key);
676
+ if (!dep) {
677
+ depsMap.set(key, (dep = createDep()));
678
+ }
679
+ const eventInfo = { effect: activeEffect, target, type, key }
680
+ ;
681
+ trackEffects(dep, eventInfo);
658
682
  }
659
- const eventInfo = { effect: activeEffect, target, type, key }
660
- ;
661
- trackEffects(dep, eventInfo);
662
- }
663
- function isTracking() {
664
- return shouldTrack && activeEffect !== undefined;
665
683
  }
666
684
  function trackEffects(dep, debuggerEventExtraInfo) {
667
685
  let shouldTrack = false;
@@ -679,9 +697,7 @@ var Vue = (function (exports) {
679
697
  dep.add(activeEffect);
680
698
  activeEffect.deps.push(dep);
681
699
  if (activeEffect.onTrack) {
682
- activeEffect.onTrack(Object.assign({
683
- effect: activeEffect
684
- }, debuggerEventExtraInfo));
700
+ activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
685
701
  }
686
702
  }
687
703
  }
@@ -1346,13 +1362,10 @@ var Vue = (function (exports) {
1346
1362
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1347
1363
 
1348
1364
  function trackRefValue(ref) {
1349
- if (isTracking()) {
1365
+ if (shouldTrack && activeEffect) {
1350
1366
  ref = toRaw(ref);
1351
- if (!ref.dep) {
1352
- ref.dep = createDep();
1353
- }
1354
1367
  {
1355
- trackEffects(ref.dep, {
1368
+ trackEffects(ref.dep || (ref.dep = createDep()), {
1356
1369
  target: ref,
1357
1370
  type: "get" /* GET */,
1358
1371
  key: 'value'
@@ -1374,7 +1387,7 @@ var Vue = (function (exports) {
1374
1387
  }
1375
1388
  }
1376
1389
  function isRef(r) {
1377
- return Boolean(r && r.__v_isRef === true);
1390
+ return !!(r && r.__v_isRef === true);
1378
1391
  }
1379
1392
  function ref(value) {
1380
1393
  return createRef(value, false);
@@ -3168,12 +3181,10 @@ var Vue = (function (exports) {
3168
3181
  return doWatch(effect, null, options);
3169
3182
  }
3170
3183
  function watchPostEffect(effect, options) {
3171
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3172
- ));
3184
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
3173
3185
  }
3174
3186
  function watchSyncEffect(effect, options) {
3175
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3176
- ));
3187
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
3177
3188
  }
3178
3189
  // initial value for watchers to trigger on undefined initial values
3179
3190
  const INITIAL_WATCHER_VALUE = {};
@@ -3470,7 +3481,9 @@ var Vue = (function (exports) {
3470
3481
  const { mode } = rawProps;
3471
3482
  // check mode
3472
3483
  if (mode &&
3473
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3484
+ mode !== 'in-out' &&
3485
+ mode !== 'out-in' &&
3486
+ mode !== 'default') {
3474
3487
  warn$1(`invalid <transition> mode: ${mode}`);
3475
3488
  }
3476
3489
  // at this point children has a guaranteed length of 1.
@@ -3697,20 +3710,24 @@ var Vue = (function (exports) {
3697
3710
  vnode.transition = hooks;
3698
3711
  }
3699
3712
  }
3700
- function getTransitionRawChildren(children, keepComment = false) {
3713
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3701
3714
  let ret = [];
3702
3715
  let keyedFragmentCount = 0;
3703
3716
  for (let i = 0; i < children.length; i++) {
3704
- const child = children[i];
3717
+ let child = children[i];
3718
+ // #5360 inherit parent key in case of <template v-for>
3719
+ const key = parentKey == null
3720
+ ? child.key
3721
+ : String(parentKey) + String(child.key != null ? child.key : i);
3705
3722
  // handle fragment children case, e.g. v-for
3706
3723
  if (child.type === Fragment) {
3707
3724
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3708
3725
  keyedFragmentCount++;
3709
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3726
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3710
3727
  }
3711
3728
  // comment placeholders should be skipped, e.g. v-if
3712
3729
  else if (keepComment || child.type !== Comment) {
3713
- ret.push(child);
3730
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3714
3731
  }
3715
3732
  }
3716
3733
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4676,6 +4693,10 @@ var Vue = (function (exports) {
4676
4693
  const propsToUpdate = instance.vnode.dynamicProps;
4677
4694
  for (let i = 0; i < propsToUpdate.length; i++) {
4678
4695
  let key = propsToUpdate[i];
4696
+ // skip if the prop key is a declared emit event listener
4697
+ if (isEmitListener(instance.emitsOptions, key)) {
4698
+ continue;
4699
+ }
4679
4700
  // PROPS flag guarantees rawProps to be non-null
4680
4701
  const value = rawProps[key];
4681
4702
  if (options) {
@@ -5186,7 +5207,6 @@ var Vue = (function (exports) {
5186
5207
  [bar, this.y]
5187
5208
  ])
5188
5209
  */
5189
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5190
5210
  function validateDirectiveName(name) {
5191
5211
  if (isBuiltInDirective(name)) {
5192
5212
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5201,7 +5221,8 @@ var Vue = (function (exports) {
5201
5221
  warn$1(`withDirectives can only be used inside render functions.`);
5202
5222
  return vnode;
5203
5223
  }
5204
- const instance = internalInstance.proxy;
5224
+ const instance = getExposeProxy(internalInstance) ||
5225
+ internalInstance.proxy;
5205
5226
  const bindings = vnode.dirs || (vnode.dirs = []);
5206
5227
  for (let i = 0; i < directives.length; i++) {
5207
5228
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -5273,6 +5294,9 @@ var Vue = (function (exports) {
5273
5294
  let uid = 0;
5274
5295
  function createAppAPI(render, hydrate) {
5275
5296
  return function createApp(rootComponent, rootProps = null) {
5297
+ if (!isFunction(rootComponent)) {
5298
+ rootComponent = Object.assign({}, rootComponent);
5299
+ }
5276
5300
  if (rootProps != null && !isObject(rootProps)) {
5277
5301
  warn$1(`root props passed to app.mount() must be an object.`);
5278
5302
  rootProps = null;
@@ -5469,6 +5493,9 @@ var Vue = (function (exports) {
5469
5493
  if (!isArray(existing)) {
5470
5494
  if (_isString) {
5471
5495
  refs[ref] = [refValue];
5496
+ if (hasOwn(setupState, ref)) {
5497
+ setupState[ref] = refs[ref];
5498
+ }
5472
5499
  }
5473
5500
  else {
5474
5501
  ref.value = [refValue];
@@ -5667,7 +5694,8 @@ var Vue = (function (exports) {
5667
5694
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5668
5695
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5669
5696
  // skip props & children if this is hoisted static nodes
5670
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5697
+ // #5405 in dev, always hydrate children for HMR
5698
+ {
5671
5699
  if (dirs) {
5672
5700
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
5673
5701
  }
@@ -5840,7 +5868,7 @@ var Vue = (function (exports) {
5840
5868
  perf.mark(`vue-${type}-${instance.uid}`);
5841
5869
  }
5842
5870
  {
5843
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5871
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
5844
5872
  }
5845
5873
  }
5846
5874
  function endMeasure(instance, type) {
@@ -5853,7 +5881,7 @@ var Vue = (function (exports) {
5853
5881
  perf.clearMarks(endTag);
5854
5882
  }
5855
5883
  {
5856
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5884
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
5857
5885
  }
5858
5886
  }
5859
5887
  function isSupported() {
@@ -8201,9 +8229,11 @@ var Vue = (function (exports) {
8201
8229
  const { data, setupState, ctx } = instance;
8202
8230
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8203
8231
  setupState[key] = value;
8232
+ return true;
8204
8233
  }
8205
8234
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8206
8235
  data[key] = value;
8236
+ return true;
8207
8237
  }
8208
8238
  else if (hasOwn(instance.props, key)) {
8209
8239
  warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
@@ -8237,6 +8267,16 @@ var Vue = (function (exports) {
8237
8267
  hasOwn(ctx, key) ||
8238
8268
  hasOwn(publicPropertiesMap, key) ||
8239
8269
  hasOwn(appContext.config.globalProperties, key));
8270
+ },
8271
+ defineProperty(target, key, descriptor) {
8272
+ if (descriptor.get != null) {
8273
+ // invalidate key cache of a getter based property #5417
8274
+ target.$.accessCache[key] = 0;
8275
+ }
8276
+ else if (hasOwn(descriptor, 'value')) {
8277
+ this.set(target, key, descriptor.value, null);
8278
+ }
8279
+ return Reflect.defineProperty(target, key, descriptor);
8240
8280
  }
8241
8281
  };
8242
8282
  {
@@ -9107,7 +9147,7 @@ var Vue = (function (exports) {
9107
9147
  }
9108
9148
 
9109
9149
  // Core API ------------------------------------------------------------------
9110
- const version = "3.2.29";
9150
+ const version = "3.2.32";
9111
9151
  /**
9112
9152
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9113
9153
  * @internal
@@ -11375,13 +11415,13 @@ var Vue = (function (exports) {
11375
11415
  message: `Platform-native elements with "is" prop will no longer be ` +
11376
11416
  `treated as components in Vue 3 unless the "is" value is explicitly ` +
11377
11417
  `prefixed with "vue:".`,
11378
- link: `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
11418
+ link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
11379
11419
  },
11380
11420
  ["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
11381
11421
  message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
11382
11422
  `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
11383
11423
  `\`v-model:${key}\`.`,
11384
- link: `https://v3.vuejs.org/guide/migration/v-model.html`
11424
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
11385
11425
  },
11386
11426
  ["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
11387
11427
  message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
@@ -11393,11 +11433,11 @@ var Vue = (function (exports) {
11393
11433
  `that appears before v-bind in the case of conflict. ` +
11394
11434
  `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
11395
11435
  `You can also suppress this warning if the usage is intended.`,
11396
- link: `https://v3.vuejs.org/guide/migration/v-bind.html`
11436
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
11397
11437
  },
11398
11438
  ["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
11399
11439
  message: `.native modifier for v-on has been removed as is no longer necessary.`,
11400
- link: `https://v3.vuejs.org/guide/migration/v-on-native-modifier-removed.html`
11440
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
11401
11441
  },
11402
11442
  ["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
11403
11443
  message: `v-if / v-for precedence when used on the same element has changed ` +
@@ -11405,7 +11445,7 @@ var Vue = (function (exports) {
11405
11445
  `access to v-for scope variables. It is best to avoid the ambiguity ` +
11406
11446
  `with <template> tags or use a computed property that filters v-for ` +
11407
11447
  `data source.`,
11408
- link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
11448
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
11409
11449
  },
11410
11450
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
11411
11451
  message: `<template> with no special directives will render as a native template ` +
@@ -11413,13 +11453,13 @@ var Vue = (function (exports) {
11413
11453
  },
11414
11454
  ["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
11415
11455
  message: `"inline-template" has been removed in Vue 3.`,
11416
- link: `https://v3.vuejs.org/guide/migration/inline-template-attribute.html`
11456
+ link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
11417
11457
  },
11418
11458
  ["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
11419
11459
  message: `filters have been removed in Vue 3. ` +
11420
11460
  `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
11421
11461
  `Use method calls or computed properties instead.`,
11422
- link: `https://v3.vuejs.org/guide/migration/filters.html`
11462
+ link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
11423
11463
  }
11424
11464
  };
11425
11465
  function getCompatValue(key, context) {
@@ -14423,7 +14463,7 @@ var Vue = (function (exports) {
14423
14463
  }
14424
14464
  }
14425
14465
  }
14426
- else {
14466
+ else if (!isBuiltInDirective(name)) {
14427
14467
  // no built-in transform, this is a user custom directive.
14428
14468
  runtimeDirectives.push(prop);
14429
14469
  // custom dirs may use beforeUpdate so they need to force blocks