@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.
@@ -201,13 +201,15 @@ var VueRuntimeDOM = (function (exports) {
201
201
  * @private
202
202
  */
203
203
  const toDisplayString = (val) => {
204
- return val == null
205
- ? ''
206
- : isArray(val) ||
207
- (isObject(val) &&
208
- (val.toString === objectToString || !isFunction(val.toString)))
209
- ? JSON.stringify(val, replacer, 2)
210
- : String(val);
204
+ return isString(val)
205
+ ? val
206
+ : val == null
207
+ ? ''
208
+ : isArray(val) ||
209
+ (isObject(val) &&
210
+ (val.toString === objectToString || !isFunction(val.toString)))
211
+ ? JSON.stringify(val, replacer, 2)
212
+ : String(val);
211
213
  };
212
214
  const replacer = (_key, val) => {
213
215
  // can't use isRef here since @vue/shared has no deps
@@ -281,6 +283,7 @@ var VueRuntimeDOM = (function (exports) {
281
283
  'onVnodeBeforeMount,onVnodeMounted,' +
282
284
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
283
285
  'onVnodeBeforeUnmount,onVnodeUnmounted');
286
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
284
287
  const cacheStringFunction = (fn) => {
285
288
  const cache = Object.create(null);
286
289
  return ((str) => {
@@ -346,11 +349,19 @@ var VueRuntimeDOM = (function (exports) {
346
349
  }
347
350
 
348
351
  let activeEffectScope;
349
- const effectScopeStack = [];
350
352
  class EffectScope {
351
353
  constructor(detached = false) {
354
+ /**
355
+ * @internal
356
+ */
352
357
  this.active = true;
358
+ /**
359
+ * @internal
360
+ */
353
361
  this.effects = [];
362
+ /**
363
+ * @internal
364
+ */
354
365
  this.cleanups = [];
355
366
  if (!detached && activeEffectScope) {
356
367
  this.parent = activeEffectScope;
@@ -360,36 +371,46 @@ var VueRuntimeDOM = (function (exports) {
360
371
  }
361
372
  run(fn) {
362
373
  if (this.active) {
374
+ const currentEffectScope = activeEffectScope;
363
375
  try {
364
- this.on();
376
+ activeEffectScope = this;
365
377
  return fn();
366
378
  }
367
379
  finally {
368
- this.off();
380
+ activeEffectScope = currentEffectScope;
369
381
  }
370
382
  }
371
383
  else {
372
384
  warn(`cannot run an inactive effect scope.`);
373
385
  }
374
386
  }
387
+ /**
388
+ * This should only be called on non-detached scopes
389
+ * @internal
390
+ */
375
391
  on() {
376
- if (this.active) {
377
- effectScopeStack.push(this);
378
- activeEffectScope = this;
379
- }
392
+ activeEffectScope = this;
380
393
  }
394
+ /**
395
+ * This should only be called on non-detached scopes
396
+ * @internal
397
+ */
381
398
  off() {
382
- if (this.active) {
383
- effectScopeStack.pop();
384
- activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
385
- }
399
+ activeEffectScope = this.parent;
386
400
  }
387
401
  stop(fromParent) {
388
402
  if (this.active) {
389
- this.effects.forEach(e => e.stop());
390
- this.cleanups.forEach(cleanup => cleanup());
403
+ let i, l;
404
+ for (i = 0, l = this.effects.length; i < l; i++) {
405
+ this.effects[i].stop();
406
+ }
407
+ for (i = 0, l = this.cleanups.length; i < l; i++) {
408
+ this.cleanups[i]();
409
+ }
391
410
  if (this.scopes) {
392
- this.scopes.forEach(e => e.stop(true));
411
+ for (i = 0, l = this.scopes.length; i < l; i++) {
412
+ this.scopes[i].stop(true);
413
+ }
393
414
  }
394
415
  // nested scope, dereference from parent to avoid memory leaks
395
416
  if (this.parent && !fromParent) {
@@ -407,8 +428,7 @@ var VueRuntimeDOM = (function (exports) {
407
428
  function effectScope(detached) {
408
429
  return new EffectScope(detached);
409
430
  }
410
- function recordEffectScope(effect, scope) {
411
- scope = scope || activeEffectScope;
431
+ function recordEffectScope(effect, scope = activeEffectScope) {
412
432
  if (scope && scope.active) {
413
433
  scope.effects.push(effect);
414
434
  }
@@ -471,7 +491,6 @@ var VueRuntimeDOM = (function (exports) {
471
491
  * When recursion depth is greater, fall back to using a full cleanup.
472
492
  */
473
493
  const maxMarkerBits = 30;
474
- const effectStack = [];
475
494
  let activeEffect;
476
495
  const ITERATE_KEY = Symbol('iterate' );
477
496
  const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
@@ -481,35 +500,42 @@ var VueRuntimeDOM = (function (exports) {
481
500
  this.scheduler = scheduler;
482
501
  this.active = true;
483
502
  this.deps = [];
503
+ this.parent = undefined;
484
504
  recordEffectScope(this, scope);
485
505
  }
486
506
  run() {
487
507
  if (!this.active) {
488
508
  return this.fn();
489
509
  }
490
- if (!effectStack.length || !effectStack.includes(this)) {
491
- try {
492
- effectStack.push((activeEffect = this));
493
- enableTracking();
494
- trackOpBit = 1 << ++effectTrackDepth;
495
- if (effectTrackDepth <= maxMarkerBits) {
496
- initDepMarkers(this);
497
- }
498
- else {
499
- cleanupEffect(this);
500
- }
501
- return this.fn();
510
+ let parent = activeEffect;
511
+ let lastShouldTrack = shouldTrack;
512
+ while (parent) {
513
+ if (parent === this) {
514
+ return;
502
515
  }
503
- finally {
504
- if (effectTrackDepth <= maxMarkerBits) {
505
- finalizeDepMarkers(this);
506
- }
507
- trackOpBit = 1 << --effectTrackDepth;
508
- resetTracking();
509
- effectStack.pop();
510
- const n = effectStack.length;
511
- activeEffect = n > 0 ? effectStack[n - 1] : undefined;
516
+ parent = parent.parent;
517
+ }
518
+ try {
519
+ this.parent = activeEffect;
520
+ activeEffect = this;
521
+ shouldTrack = true;
522
+ trackOpBit = 1 << ++effectTrackDepth;
523
+ if (effectTrackDepth <= maxMarkerBits) {
524
+ initDepMarkers(this);
525
+ }
526
+ else {
527
+ cleanupEffect(this);
512
528
  }
529
+ return this.fn();
530
+ }
531
+ finally {
532
+ if (effectTrackDepth <= maxMarkerBits) {
533
+ finalizeDepMarkers(this);
534
+ }
535
+ trackOpBit = 1 << --effectTrackDepth;
536
+ activeEffect = this.parent;
537
+ shouldTrack = lastShouldTrack;
538
+ this.parent = undefined;
513
539
  }
514
540
  }
515
541
  stop() {
@@ -557,32 +583,24 @@ var VueRuntimeDOM = (function (exports) {
557
583
  trackStack.push(shouldTrack);
558
584
  shouldTrack = false;
559
585
  }
560
- function enableTracking() {
561
- trackStack.push(shouldTrack);
562
- shouldTrack = true;
563
- }
564
586
  function resetTracking() {
565
587
  const last = trackStack.pop();
566
588
  shouldTrack = last === undefined ? true : last;
567
589
  }
568
590
  function track(target, type, key) {
569
- if (!isTracking()) {
570
- return;
571
- }
572
- let depsMap = targetMap.get(target);
573
- if (!depsMap) {
574
- targetMap.set(target, (depsMap = new Map()));
575
- }
576
- let dep = depsMap.get(key);
577
- if (!dep) {
578
- depsMap.set(key, (dep = createDep()));
591
+ if (shouldTrack && activeEffect) {
592
+ let depsMap = targetMap.get(target);
593
+ if (!depsMap) {
594
+ targetMap.set(target, (depsMap = new Map()));
595
+ }
596
+ let dep = depsMap.get(key);
597
+ if (!dep) {
598
+ depsMap.set(key, (dep = createDep()));
599
+ }
600
+ const eventInfo = { effect: activeEffect, target, type, key }
601
+ ;
602
+ trackEffects(dep, eventInfo);
579
603
  }
580
- const eventInfo = { effect: activeEffect, target, type, key }
581
- ;
582
- trackEffects(dep, eventInfo);
583
- }
584
- function isTracking() {
585
- return shouldTrack && activeEffect !== undefined;
586
604
  }
587
605
  function trackEffects(dep, debuggerEventExtraInfo) {
588
606
  let shouldTrack = false;
@@ -600,9 +618,7 @@ var VueRuntimeDOM = (function (exports) {
600
618
  dep.add(activeEffect);
601
619
  activeEffect.deps.push(dep);
602
620
  if (activeEffect.onTrack) {
603
- activeEffect.onTrack(Object.assign({
604
- effect: activeEffect
605
- }, debuggerEventExtraInfo));
621
+ activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo));
606
622
  }
607
623
  }
608
624
  }
@@ -1267,13 +1283,10 @@ var VueRuntimeDOM = (function (exports) {
1267
1283
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1268
1284
 
1269
1285
  function trackRefValue(ref) {
1270
- if (isTracking()) {
1286
+ if (shouldTrack && activeEffect) {
1271
1287
  ref = toRaw(ref);
1272
- if (!ref.dep) {
1273
- ref.dep = createDep();
1274
- }
1275
1288
  {
1276
- trackEffects(ref.dep, {
1289
+ trackEffects(ref.dep || (ref.dep = createDep()), {
1277
1290
  target: ref,
1278
1291
  type: "get" /* GET */,
1279
1292
  key: 'value'
@@ -1295,7 +1308,7 @@ var VueRuntimeDOM = (function (exports) {
1295
1308
  }
1296
1309
  }
1297
1310
  function isRef(r) {
1298
- return Boolean(r && r.__v_isRef === true);
1311
+ return !!(r && r.__v_isRef === true);
1299
1312
  }
1300
1313
  function ref(value) {
1301
1314
  return createRef(value, false);
@@ -3089,12 +3102,10 @@ var VueRuntimeDOM = (function (exports) {
3089
3102
  return doWatch(effect, null, options);
3090
3103
  }
3091
3104
  function watchPostEffect(effect, options) {
3092
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3093
- ));
3105
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
3094
3106
  }
3095
3107
  function watchSyncEffect(effect, options) {
3096
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3097
- ));
3108
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
3098
3109
  }
3099
3110
  // initial value for watchers to trigger on undefined initial values
3100
3111
  const INITIAL_WATCHER_VALUE = {};
@@ -3391,7 +3402,9 @@ var VueRuntimeDOM = (function (exports) {
3391
3402
  const { mode } = rawProps;
3392
3403
  // check mode
3393
3404
  if (mode &&
3394
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3405
+ mode !== 'in-out' &&
3406
+ mode !== 'out-in' &&
3407
+ mode !== 'default') {
3395
3408
  warn$1(`invalid <transition> mode: ${mode}`);
3396
3409
  }
3397
3410
  // at this point children has a guaranteed length of 1.
@@ -3618,20 +3631,24 @@ var VueRuntimeDOM = (function (exports) {
3618
3631
  vnode.transition = hooks;
3619
3632
  }
3620
3633
  }
3621
- function getTransitionRawChildren(children, keepComment = false) {
3634
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3622
3635
  let ret = [];
3623
3636
  let keyedFragmentCount = 0;
3624
3637
  for (let i = 0; i < children.length; i++) {
3625
- const child = children[i];
3638
+ let child = children[i];
3639
+ // #5360 inherit parent key in case of <template v-for>
3640
+ const key = parentKey == null
3641
+ ? child.key
3642
+ : String(parentKey) + String(child.key != null ? child.key : i);
3626
3643
  // handle fragment children case, e.g. v-for
3627
3644
  if (child.type === Fragment) {
3628
3645
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3629
3646
  keyedFragmentCount++;
3630
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3647
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
3631
3648
  }
3632
3649
  // comment placeholders should be skipped, e.g. v-if
3633
3650
  else if (keepComment || child.type !== Comment) {
3634
- ret.push(child);
3651
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
3635
3652
  }
3636
3653
  }
3637
3654
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -4597,6 +4614,10 @@ var VueRuntimeDOM = (function (exports) {
4597
4614
  const propsToUpdate = instance.vnode.dynamicProps;
4598
4615
  for (let i = 0; i < propsToUpdate.length; i++) {
4599
4616
  let key = propsToUpdate[i];
4617
+ // skip if the prop key is a declared emit event listener
4618
+ if (isEmitListener(instance.emitsOptions, key)) {
4619
+ continue;
4620
+ }
4600
4621
  // PROPS flag guarantees rawProps to be non-null
4601
4622
  const value = rawProps[key];
4602
4623
  if (options) {
@@ -5107,7 +5128,6 @@ var VueRuntimeDOM = (function (exports) {
5107
5128
  [bar, this.y]
5108
5129
  ])
5109
5130
  */
5110
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5111
5131
  function validateDirectiveName(name) {
5112
5132
  if (isBuiltInDirective(name)) {
5113
5133
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5122,7 +5142,8 @@ var VueRuntimeDOM = (function (exports) {
5122
5142
  warn$1(`withDirectives can only be used inside render functions.`);
5123
5143
  return vnode;
5124
5144
  }
5125
- const instance = internalInstance.proxy;
5145
+ const instance = getExposeProxy(internalInstance) ||
5146
+ internalInstance.proxy;
5126
5147
  const bindings = vnode.dirs || (vnode.dirs = []);
5127
5148
  for (let i = 0; i < directives.length; i++) {
5128
5149
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -5194,6 +5215,9 @@ var VueRuntimeDOM = (function (exports) {
5194
5215
  let uid = 0;
5195
5216
  function createAppAPI(render, hydrate) {
5196
5217
  return function createApp(rootComponent, rootProps = null) {
5218
+ if (!isFunction(rootComponent)) {
5219
+ rootComponent = Object.assign({}, rootComponent);
5220
+ }
5197
5221
  if (rootProps != null && !isObject(rootProps)) {
5198
5222
  warn$1(`root props passed to app.mount() must be an object.`);
5199
5223
  rootProps = null;
@@ -5390,6 +5414,9 @@ var VueRuntimeDOM = (function (exports) {
5390
5414
  if (!isArray(existing)) {
5391
5415
  if (_isString) {
5392
5416
  refs[ref] = [refValue];
5417
+ if (hasOwn(setupState, ref)) {
5418
+ setupState[ref] = refs[ref];
5419
+ }
5393
5420
  }
5394
5421
  else {
5395
5422
  ref.value = [refValue];
@@ -5588,7 +5615,8 @@ var VueRuntimeDOM = (function (exports) {
5588
5615
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5589
5616
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5590
5617
  // skip props & children if this is hoisted static nodes
5591
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
5618
+ // #5405 in dev, always hydrate children for HMR
5619
+ {
5592
5620
  if (dirs) {
5593
5621
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
5594
5622
  }
@@ -5761,7 +5789,7 @@ var VueRuntimeDOM = (function (exports) {
5761
5789
  perf.mark(`vue-${type}-${instance.uid}`);
5762
5790
  }
5763
5791
  {
5764
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5792
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
5765
5793
  }
5766
5794
  }
5767
5795
  function endMeasure(instance, type) {
@@ -5774,7 +5802,7 @@ var VueRuntimeDOM = (function (exports) {
5774
5802
  perf.clearMarks(endTag);
5775
5803
  }
5776
5804
  {
5777
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5805
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
5778
5806
  }
5779
5807
  }
5780
5808
  function isSupported() {
@@ -8122,9 +8150,11 @@ var VueRuntimeDOM = (function (exports) {
8122
8150
  const { data, setupState, ctx } = instance;
8123
8151
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8124
8152
  setupState[key] = value;
8153
+ return true;
8125
8154
  }
8126
8155
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8127
8156
  data[key] = value;
8157
+ return true;
8128
8158
  }
8129
8159
  else if (hasOwn(instance.props, key)) {
8130
8160
  warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
@@ -8158,6 +8188,16 @@ var VueRuntimeDOM = (function (exports) {
8158
8188
  hasOwn(ctx, key) ||
8159
8189
  hasOwn(publicPropertiesMap, key) ||
8160
8190
  hasOwn(appContext.config.globalProperties, key));
8191
+ },
8192
+ defineProperty(target, key, descriptor) {
8193
+ if (descriptor.get != null) {
8194
+ // invalidate key cache of a getter based property #5417
8195
+ target.$.accessCache[key] = 0;
8196
+ }
8197
+ else if (hasOwn(descriptor, 'value')) {
8198
+ this.set(target, key, descriptor.value, null);
8199
+ }
8200
+ return Reflect.defineProperty(target, key, descriptor);
8161
8201
  }
8162
8202
  };
8163
8203
  {
@@ -9028,7 +9068,7 @@ var VueRuntimeDOM = (function (exports) {
9028
9068
  }
9029
9069
 
9030
9070
  // Core API ------------------------------------------------------------------
9031
- const version = "3.2.29";
9071
+ const version = "3.2.32";
9032
9072
  /**
9033
9073
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9034
9074
  * @internal