@vue/runtime-dom 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.
@@ -198,13 +198,15 @@ function looseIndexOf(arr, val) {
198
198
  * @private
199
199
  */
200
200
  const toDisplayString = (val) => {
201
- return val == null
202
- ? ''
203
- : isArray(val) ||
204
- (isObject(val) &&
205
- (val.toString === objectToString || !isFunction(val.toString)))
206
- ? JSON.stringify(val, replacer, 2)
207
- : String(val);
201
+ return isString(val)
202
+ ? val
203
+ : val == null
204
+ ? ''
205
+ : isArray(val) ||
206
+ (isObject(val) &&
207
+ (val.toString === objectToString || !isFunction(val.toString)))
208
+ ? JSON.stringify(val, replacer, 2)
209
+ : String(val);
208
210
  };
209
211
  const replacer = (_key, val) => {
210
212
  // can't use isRef here since @vue/shared has no deps
@@ -278,6 +280,7 @@ const isReservedProp = /*#__PURE__*/ makeMap(
278
280
  'onVnodeBeforeMount,onVnodeMounted,' +
279
281
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
280
282
  'onVnodeBeforeUnmount,onVnodeUnmounted');
283
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
281
284
  const cacheStringFunction = (fn) => {
282
285
  const cache = Object.create(null);
283
286
  return ((str) => {
@@ -343,11 +346,19 @@ function warn(msg, ...args) {
343
346
  }
344
347
 
345
348
  let activeEffectScope;
346
- const effectScopeStack = [];
347
349
  class EffectScope {
348
350
  constructor(detached = false) {
351
+ /**
352
+ * @internal
353
+ */
349
354
  this.active = true;
355
+ /**
356
+ * @internal
357
+ */
350
358
  this.effects = [];
359
+ /**
360
+ * @internal
361
+ */
351
362
  this.cleanups = [];
352
363
  if (!detached && activeEffectScope) {
353
364
  this.parent = activeEffectScope;
@@ -357,36 +368,46 @@ class EffectScope {
357
368
  }
358
369
  run(fn) {
359
370
  if (this.active) {
371
+ const currentEffectScope = activeEffectScope;
360
372
  try {
361
- this.on();
373
+ activeEffectScope = this;
362
374
  return fn();
363
375
  }
364
376
  finally {
365
- this.off();
377
+ activeEffectScope = currentEffectScope;
366
378
  }
367
379
  }
368
380
  else {
369
381
  warn(`cannot run an inactive effect scope.`);
370
382
  }
371
383
  }
384
+ /**
385
+ * This should only be called on non-detached scopes
386
+ * @internal
387
+ */
372
388
  on() {
373
- if (this.active) {
374
- effectScopeStack.push(this);
375
- activeEffectScope = this;
376
- }
389
+ activeEffectScope = this;
377
390
  }
391
+ /**
392
+ * This should only be called on non-detached scopes
393
+ * @internal
394
+ */
378
395
  off() {
379
- if (this.active) {
380
- effectScopeStack.pop();
381
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
382
- }
396
+ activeEffectScope = this.parent;
383
397
  }
384
398
  stop(fromParent) {
385
399
  if (this.active) {
386
- this.effects.forEach(e => e.stop());
387
- this.cleanups.forEach(cleanup => cleanup());
400
+ let i, l;
401
+ for (i = 0, l = this.effects.length; i < l; i++) {
402
+ this.effects[i].stop();
403
+ }
404
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
405
+ this.cleanups[i]();
406
+ }
388
407
  if (this.scopes) {
389
- this.scopes.forEach(e => e.stop(true));
408
+ for (i = 0, l = this.scopes.length; i < l; i++) {
409
+ this.scopes[i].stop(true);
410
+ }
390
411
  }
391
412
  // nested scope, dereference from parent to avoid memory leaks
392
413
  if (this.parent && !fromParent) {
@@ -404,8 +425,7 @@ class EffectScope {
404
425
  function effectScope(detached) {
405
426
  return new EffectScope(detached);
406
427
  }
407
- function recordEffectScope(effect, scope) {
408
- scope = scope || activeEffectScope;
428
+ function recordEffectScope(effect, scope = activeEffectScope) {
409
429
  if (scope && scope.active) {
410
430
  scope.effects.push(effect);
411
431
  }
@@ -468,7 +488,6 @@ let trackOpBit = 1;
468
488
  * When recursion depth is greater, fall back to using a full cleanup.
469
489
  */
470
490
  const maxMarkerBits = 30;
471
- const effectStack = [];
472
491
  let activeEffect;
473
492
  const ITERATE_KEY = Symbol('iterate' );
474
493
  const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
@@ -478,35 +497,42 @@ class ReactiveEffect {
478
497
  this.scheduler = scheduler;
479
498
  this.active = true;
480
499
  this.deps = [];
500
+ this.parent = undefined;
481
501
  recordEffectScope(this, scope);
482
502
  }
483
503
  run() {
484
504
  if (!this.active) {
485
505
  return this.fn();
486
506
  }
487
- if (!effectStack.length || !effectStack.includes(this)) {
488
- try {
489
- effectStack.push((activeEffect = this));
490
- enableTracking();
491
- trackOpBit = 1 << ++effectTrackDepth;
492
- if (effectTrackDepth <= maxMarkerBits) {
493
- initDepMarkers(this);
494
- }
495
- else {
496
- cleanupEffect(this);
497
- }
498
- return this.fn();
507
+ let parent = activeEffect;
508
+ let lastShouldTrack = shouldTrack;
509
+ while (parent) {
510
+ if (parent === this) {
511
+ return;
499
512
  }
500
- finally {
501
- if (effectTrackDepth <= maxMarkerBits) {
502
- finalizeDepMarkers(this);
503
- }
504
- trackOpBit = 1 << --effectTrackDepth;
505
- resetTracking();
506
- effectStack.pop();
507
- const n = effectStack.length;
508
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
513
+ parent = parent.parent;
514
+ }
515
+ try {
516
+ this.parent = activeEffect;
517
+ activeEffect = this;
518
+ shouldTrack = true;
519
+ trackOpBit = 1 << ++effectTrackDepth;
520
+ if (effectTrackDepth <= maxMarkerBits) {
521
+ initDepMarkers(this);
522
+ }
523
+ else {
524
+ cleanupEffect(this);
509
525
  }
526
+ return this.fn();
527
+ }
528
+ finally {
529
+ if (effectTrackDepth <= maxMarkerBits) {
530
+ finalizeDepMarkers(this);
531
+ }
532
+ trackOpBit = 1 << --effectTrackDepth;
533
+ activeEffect = this.parent;
534
+ shouldTrack = lastShouldTrack;
535
+ this.parent = undefined;
510
536
  }
511
537
  }
512
538
  stop() {
@@ -554,32 +580,24 @@ function pauseTracking() {
554
580
  trackStack.push(shouldTrack);
555
581
  shouldTrack = false;
556
582
  }
557
- function enableTracking() {
558
- trackStack.push(shouldTrack);
559
- shouldTrack = true;
560
- }
561
583
  function resetTracking() {
562
584
  const last = trackStack.pop();
563
585
  shouldTrack = last === undefined ? true : last;
564
586
  }
565
587
  function track(target, type, key) {
566
- if (!isTracking()) {
567
- return;
568
- }
569
- let depsMap = targetMap.get(target);
570
- if (!depsMap) {
571
- targetMap.set(target, (depsMap = new Map()));
572
- }
573
- let dep = depsMap.get(key);
574
- if (!dep) {
575
- depsMap.set(key, (dep = createDep()));
588
+ if (shouldTrack && activeEffect) {
589
+ let depsMap = targetMap.get(target);
590
+ if (!depsMap) {
591
+ targetMap.set(target, (depsMap = new Map()));
592
+ }
593
+ let dep = depsMap.get(key);
594
+ if (!dep) {
595
+ depsMap.set(key, (dep = createDep()));
596
+ }
597
+ const eventInfo = { effect: activeEffect, target, type, key }
598
+ ;
599
+ trackEffects(dep, eventInfo);
576
600
  }
577
- const eventInfo = { effect: activeEffect, target, type, key }
578
- ;
579
- trackEffects(dep, eventInfo);
580
- }
581
- function isTracking() {
582
- return shouldTrack && activeEffect !== undefined;
583
601
  }
584
602
  function trackEffects(dep, debuggerEventExtraInfo) {
585
603
  let shouldTrack = false;
@@ -597,9 +615,7 @@ function trackEffects(dep, debuggerEventExtraInfo) {
597
615
  dep.add(activeEffect);
598
616
  activeEffect.deps.push(dep);
599
617
  if (activeEffect.onTrack) {
600
- activeEffect.onTrack(Object.assign({
601
- effect: activeEffect
602
- }, debuggerEventExtraInfo));
618
+ activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
603
619
  }
604
620
  }
605
621
  }
@@ -1264,13 +1280,10 @@ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1264
1280
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1265
1281
 
1266
1282
  function trackRefValue(ref) {
1267
- if (isTracking()) {
1283
+ if (shouldTrack && activeEffect) {
1268
1284
  ref = toRaw(ref);
1269
- if (!ref.dep) {
1270
- ref.dep = createDep();
1271
- }
1272
1285
  {
1273
- trackEffects(ref.dep, {
1286
+ trackEffects(ref.dep || (ref.dep = createDep()), {
1274
1287
  target: ref,
1275
1288
  type: "get" /* GET */,
1276
1289
  key: 'value'
@@ -1292,7 +1305,7 @@ function triggerRefValue(ref, newVal) {
1292
1305
  }
1293
1306
  }
1294
1307
  function isRef(r) {
1295
- return Boolean(r && r.__v_isRef === true);
1308
+ return !!(r && r.__v_isRef === true);
1296
1309
  }
1297
1310
  function ref(value) {
1298
1311
  return createRef(value, false);
@@ -3087,12 +3100,10 @@ function watchEffect(effect, options) {
3087
3100
  return doWatch(effect, null, options);
3088
3101
  }
3089
3102
  function watchPostEffect(effect, options) {
3090
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3091
- ));
3103
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
3092
3104
  }
3093
3105
  function watchSyncEffect(effect, options) {
3094
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3095
- ));
3106
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
3096
3107
  }
3097
3108
  // initial value for watchers to trigger on undefined initial values
3098
3109
  const INITIAL_WATCHER_VALUE = {};
@@ -3389,7 +3400,9 @@ const BaseTransitionImpl = {
3389
3400
  const { mode } = rawProps;
3390
3401
  // check mode
3391
3402
  if (mode &&
3392
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3403
+ mode !== 'in-out' &&
3404
+ mode !== 'out-in' &&
3405
+ mode !== 'default') {
3393
3406
  warn$1(`invalid <transition> mode: ${mode}`);
3394
3407
  }
3395
3408
  // at this point children has a guaranteed length of 1.
@@ -3616,20 +3629,24 @@ function setTransitionHooks(vnode, hooks) {
3616
3629
  vnode.transition = hooks;
3617
3630
  }
3618
3631
  }
3619
- function getTransitionRawChildren(children, keepComment = false) {
3632
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3620
3633
  let ret = [];
3621
3634
  let keyedFragmentCount = 0;
3622
3635
  for (let i = 0; i < children.length; i++) {
3623
- const child = children[i];
3636
+ let child = children[i];
3637
+ // #5360 inherit parent key in case of <template v-for>
3638
+ const key = parentKey == null
3639
+ ? child.key
3640
+ : String(parentKey) + String(child.key != null ? child.key : i);
3624
3641
  // handle fragment children case, e.g. v-for
3625
3642
  if (child.type === Fragment) {
3626
3643
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3627
3644
  keyedFragmentCount++;
3628
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3645
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3629
3646
  }
3630
3647
  // comment placeholders should be skipped, e.g. v-if
3631
3648
  else if (keepComment || child.type !== Comment) {
3632
- ret.push(child);
3649
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3633
3650
  }
3634
3651
  }
3635
3652
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4595,6 +4612,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
4595
4612
  const propsToUpdate = instance.vnode.dynamicProps;
4596
4613
  for (let i = 0; i < propsToUpdate.length; i++) {
4597
4614
  let key = propsToUpdate[i];
4615
+ // skip if the prop key is a declared emit event listener
4616
+ if (isEmitListener(instance.emitsOptions, key)) {
4617
+ continue;
4618
+ }
4598
4619
  // PROPS flag guarantees rawProps to be non-null
4599
4620
  const value = rawProps[key];
4600
4621
  if (options) {
@@ -5105,7 +5126,6 @@ return withDirectives(h(comp), [
5105
5126
  [bar, this.y]
5106
5127
  ])
5107
5128
  */
5108
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5109
5129
  function validateDirectiveName(name) {
5110
5130
  if (isBuiltInDirective(name)) {
5111
5131
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5120,7 +5140,8 @@ function withDirectives(vnode, directives) {
5120
5140
  warn$1(`withDirectives can only be used inside render functions.`);
5121
5141
  return vnode;
5122
5142
  }
5123
- const instance = internalInstance.proxy;
5143
+ const instance = getExposeProxy(internalInstance) ||
5144
+ internalInstance.proxy;
5124
5145
  const bindings = vnode.dirs || (vnode.dirs = []);
5125
5146
  for (let i = 0; i < directives.length; i++) {
5126
5147
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -5192,6 +5213,9 @@ function createAppContext() {
5192
5213
  let uid = 0;
5193
5214
  function createAppAPI(render, hydrate) {
5194
5215
  return function createApp(rootComponent, rootProps = null) {
5216
+ if (!isFunction(rootComponent)) {
5217
+ rootComponent = Object.assign({}, rootComponent);
5218
+ }
5195
5219
  if (rootProps != null && !isObject(rootProps)) {
5196
5220
  warn$1(`root props passed to app.mount() must be an object.`);
5197
5221
  rootProps = null;
@@ -5388,6 +5412,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5388
5412
  if (!isArray(existing)) {
5389
5413
  if (_isString) {
5390
5414
  refs[ref] = [refValue];
5415
+ if (hasOwn(setupState, ref)) {
5416
+ setupState[ref] = refs[ref];
5417
+ }
5391
5418
  }
5392
5419
  else {
5393
5420
  ref.value = [refValue];
@@ -5586,7 +5613,8 @@ function createHydrationFunctions(rendererInternals) {
5586
5613
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5587
5614
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5588
5615
  // skip props & children if this is hoisted static nodes
5589
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5616
+ // #5405 in dev, always hydrate children for HMR
5617
+ {
5590
5618
  if (dirs) {
5591
5619
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
5592
5620
  }
@@ -5759,7 +5787,7 @@ function startMeasure(instance, type) {
5759
5787
  perf.mark(`vue-${type}-${instance.uid}`);
5760
5788
  }
5761
5789
  {
5762
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5790
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
5763
5791
  }
5764
5792
  }
5765
5793
  function endMeasure(instance, type) {
@@ -5772,7 +5800,7 @@ function endMeasure(instance, type) {
5772
5800
  perf.clearMarks(endTag);
5773
5801
  }
5774
5802
  {
5775
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5803
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
5776
5804
  }
5777
5805
  }
5778
5806
  function isSupported() {
@@ -8120,9 +8148,11 @@ const PublicInstanceProxyHandlers = {
8120
8148
  const { data, setupState, ctx } = instance;
8121
8149
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8122
8150
  setupState[key] = value;
8151
+ return true;
8123
8152
  }
8124
8153
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8125
8154
  data[key] = value;
8155
+ return true;
8126
8156
  }
8127
8157
  else if (hasOwn(instance.props, key)) {
8128
8158
  warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
@@ -8156,6 +8186,16 @@ const PublicInstanceProxyHandlers = {
8156
8186
  hasOwn(ctx, key) ||
8157
8187
  hasOwn(publicPropertiesMap, key) ||
8158
8188
  hasOwn(appContext.config.globalProperties, key));
8189
+ },
8190
+ defineProperty(target, key, descriptor) {
8191
+ if (descriptor.get != null) {
8192
+ // invalidate key cache of a getter based property #5417
8193
+ target.$.accessCache[key] = 0;
8194
+ }
8195
+ else if (hasOwn(descriptor, 'value')) {
8196
+ this.set(target, key, descriptor.value, null);
8197
+ }
8198
+ return Reflect.defineProperty(target, key, descriptor);
8159
8199
  }
8160
8200
  };
8161
8201
  {
@@ -9031,7 +9071,7 @@ function isMemoSame(cached, memo) {
9031
9071
  }
9032
9072
 
9033
9073
  // Core API ------------------------------------------------------------------
9034
- const version = "3.2.29";
9074
+ const version = "3.2.32";
9035
9075
  /**
9036
9076
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9037
9077
  * @internal