@vue/runtime-core 3.2.30 → 3.2.33

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.
@@ -235,7 +235,7 @@ let preFlushIndex = 0;
235
235
  const pendingPostFlushCbs = [];
236
236
  let activePostFlushCbs = null;
237
237
  let postFlushIndex = 0;
238
- const resolvedPromise = Promise.resolve();
238
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
239
239
  let currentFlushPromise = null;
240
240
  let currentPreFlushParentJob = null;
241
241
  const RECURSION_LIMIT = 100;
@@ -650,6 +650,8 @@ function devtoolsComponentEmit(component, event, params) {
650
650
  }
651
651
 
652
652
  function emit$1(instance, event, ...rawArgs) {
653
+ if (instance.isUnmounted)
654
+ return;
653
655
  const props = instance.vnode.props || shared.EMPTY_OBJ;
654
656
  {
655
657
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -1637,12 +1639,10 @@ function watchEffect(effect, options) {
1637
1639
  return doWatch(effect, null, options);
1638
1640
  }
1639
1641
  function watchPostEffect(effect, options) {
1640
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
1641
- ));
1642
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) ));
1642
1643
  }
1643
1644
  function watchSyncEffect(effect, options) {
1644
- return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
1645
- ));
1645
+ return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) ));
1646
1646
  }
1647
1647
  // initial value for watchers to trigger on undefined initial values
1648
1648
  const INITIAL_WATCHER_VALUE = {};
@@ -1945,10 +1945,22 @@ const BaseTransitionImpl = {
1945
1945
  if (!children || !children.length) {
1946
1946
  return;
1947
1947
  }
1948
- // warn multiple elements
1948
+ let child = children[0];
1949
1949
  if (children.length > 1) {
1950
- warn('<transition> can only be used on a single element or component. Use ' +
1951
- '<transition-group> for lists.');
1950
+ let hasFound = false;
1951
+ // locate first non-comment child
1952
+ for (const c of children) {
1953
+ if (c.type !== Comment) {
1954
+ if (hasFound) {
1955
+ // warn more than one non-comment child
1956
+ warn('<transition> can only be used on a single element or component. ' +
1957
+ 'Use <transition-group> for lists.');
1958
+ break;
1959
+ }
1960
+ child = c;
1961
+ hasFound = true;
1962
+ }
1963
+ }
1952
1964
  }
1953
1965
  // there's no need to track reactivity for these props so use the raw
1954
1966
  // props for a bit better perf
@@ -1956,11 +1968,11 @@ const BaseTransitionImpl = {
1956
1968
  const { mode } = rawProps;
1957
1969
  // check mode
1958
1970
  if (mode &&
1959
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
1971
+ mode !== 'in-out' &&
1972
+ mode !== 'out-in' &&
1973
+ mode !== 'default') {
1960
1974
  warn(`invalid <transition> mode: ${mode}`);
1961
1975
  }
1962
- // at this point children has a guaranteed length of 1.
1963
- const child = children[0];
1964
1976
  if (state.isLeaving) {
1965
1977
  return emptyPlaceholder(child);
1966
1978
  }
@@ -2183,20 +2195,24 @@ function setTransitionHooks(vnode, hooks) {
2183
2195
  vnode.transition = hooks;
2184
2196
  }
2185
2197
  }
2186
- function getTransitionRawChildren(children, keepComment = false) {
2198
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
2187
2199
  let ret = [];
2188
2200
  let keyedFragmentCount = 0;
2189
2201
  for (let i = 0; i < children.length; i++) {
2190
- const child = children[i];
2202
+ let child = children[i];
2203
+ // #5360 inherit parent key in case of <template v-for>
2204
+ const key = parentKey == null
2205
+ ? child.key
2206
+ : String(parentKey) + String(child.key != null ? child.key : i);
2191
2207
  // handle fragment children case, e.g. v-for
2192
2208
  if (child.type === Fragment) {
2193
2209
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
2194
2210
  keyedFragmentCount++;
2195
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
2211
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
2196
2212
  }
2197
2213
  // comment placeholders should be skipped, e.g. v-if
2198
2214
  else if (keepComment || child.type !== Comment) {
2199
- ret.push(child);
2215
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
2200
2216
  }
2201
2217
  }
2202
2218
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -3162,6 +3178,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3162
3178
  const propsToUpdate = instance.vnode.dynamicProps;
3163
3179
  for (let i = 0; i < propsToUpdate.length; i++) {
3164
3180
  let key = propsToUpdate[i];
3181
+ // skip if the prop key is a declared emit event listener
3182
+ if (isEmitListener(instance.emitsOptions, key)) {
3183
+ continue;
3184
+ }
3165
3185
  // PROPS flag guarantees rawProps to be non-null
3166
3186
  const value = rawProps[key];
3167
3187
  if (options) {
@@ -3686,7 +3706,8 @@ function withDirectives(vnode, directives) {
3686
3706
  warn(`withDirectives can only be used inside render functions.`);
3687
3707
  return vnode;
3688
3708
  }
3689
- const instance = internalInstance.proxy;
3709
+ const instance = getExposeProxy(internalInstance) ||
3710
+ internalInstance.proxy;
3690
3711
  const bindings = vnode.dirs || (vnode.dirs = []);
3691
3712
  for (let i = 0; i < directives.length; i++) {
3692
3713
  let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
@@ -3758,6 +3779,9 @@ function createAppContext() {
3758
3779
  let uid = 0;
3759
3780
  function createAppAPI(render, hydrate) {
3760
3781
  return function createApp(rootComponent, rootProps = null) {
3782
+ if (!shared.isFunction(rootComponent)) {
3783
+ rootComponent = Object.assign({}, rootComponent);
3784
+ }
3761
3785
  if (rootProps != null && !shared.isObject(rootProps)) {
3762
3786
  warn(`root props passed to app.mount() must be an object.`);
3763
3787
  rootProps = null;
@@ -3954,6 +3978,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3954
3978
  if (!shared.isArray(existing)) {
3955
3979
  if (_isString) {
3956
3980
  refs[ref] = [refValue];
3981
+ if (shared.hasOwn(setupState, ref)) {
3982
+ setupState[ref] = refs[ref];
3983
+ }
3957
3984
  }
3958
3985
  else {
3959
3986
  ref.value = [refValue];
@@ -4152,7 +4179,8 @@ function createHydrationFunctions(rendererInternals) {
4152
4179
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
4153
4180
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
4154
4181
  // skip props & children if this is hoisted static nodes
4155
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
4182
+ // #5405 in dev, always hydrate children for HMR
4183
+ {
4156
4184
  if (dirs) {
4157
4185
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
4158
4186
  }
@@ -4325,7 +4353,7 @@ function startMeasure(instance, type) {
4325
4353
  perf.mark(`vue-${type}-${instance.uid}`);
4326
4354
  }
4327
4355
  {
4328
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
4356
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
4329
4357
  }
4330
4358
  }
4331
4359
  function endMeasure(instance, type) {
@@ -4338,7 +4366,7 @@ function endMeasure(instance, type) {
4338
4366
  perf.clearMarks(endTag);
4339
4367
  }
4340
4368
  {
4341
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
4369
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
4342
4370
  }
4343
4371
  }
4344
4372
  function isSupported() {
@@ -5466,7 +5494,22 @@ function baseCreateRenderer(options, createHydrationFns) {
5466
5494
  const remove = vnode => {
5467
5495
  const { type, el, anchor, transition } = vnode;
5468
5496
  if (type === Fragment) {
5469
- removeFragment(el, anchor);
5497
+ if (vnode.patchFlag > 0 &&
5498
+ vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
5499
+ transition &&
5500
+ !transition.persisted) {
5501
+ vnode.children.forEach(child => {
5502
+ if (child.type === Comment) {
5503
+ hostRemove(child.el);
5504
+ }
5505
+ else {
5506
+ remove(child);
5507
+ }
5508
+ });
5509
+ }
5510
+ else {
5511
+ removeFragment(el, anchor);
5512
+ }
5470
5513
  return;
5471
5514
  }
5472
5515
  if (type === Static) {
@@ -6485,7 +6528,10 @@ function renderSlot(slots, name, props = {},
6485
6528
  // this is not a user-facing function, so the fallback is always generated by
6486
6529
  // the compiler and guaranteed to be a function returning an array
6487
6530
  fallback, noSlotted) {
6488
- if (currentRenderingInstance.isCE) {
6531
+ if (currentRenderingInstance.isCE ||
6532
+ (currentRenderingInstance.parent &&
6533
+ isAsyncWrapper(currentRenderingInstance.parent) &&
6534
+ currentRenderingInstance.parent.isCE)) {
6489
6535
  return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
6490
6536
  }
6491
6537
  let slot = slots[name];
@@ -6558,7 +6604,10 @@ const getPublicInstance = (i) => {
6558
6604
  return getExposeProxy(i) || i.proxy;
6559
6605
  return getPublicInstance(i.parent);
6560
6606
  };
6561
- const publicPropertiesMap = shared.extend(Object.create(null), {
6607
+ const publicPropertiesMap =
6608
+ // Move PURE marker to new line to workaround compiler discarding it
6609
+ // due to type annotation
6610
+ /*#__PURE__*/ shared.extend(Object.create(null), {
6562
6611
  $: i => i,
6563
6612
  $el: i => i.vnode.el,
6564
6613
  $data: i => i.data,
@@ -6686,9 +6735,11 @@ const PublicInstanceProxyHandlers = {
6686
6735
  const { data, setupState, ctx } = instance;
6687
6736
  if (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) {
6688
6737
  setupState[key] = value;
6738
+ return true;
6689
6739
  }
6690
6740
  else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
6691
6741
  data[key] = value;
6742
+ return true;
6692
6743
  }
6693
6744
  else if (shared.hasOwn(instance.props, key)) {
6694
6745
  warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
@@ -6722,6 +6773,16 @@ const PublicInstanceProxyHandlers = {
6722
6773
  shared.hasOwn(ctx, key) ||
6723
6774
  shared.hasOwn(publicPropertiesMap, key) ||
6724
6775
  shared.hasOwn(appContext.config.globalProperties, key));
6776
+ },
6777
+ defineProperty(target, key, descriptor) {
6778
+ if (descriptor.get != null) {
6779
+ // invalidate key cache of a getter based property #5417
6780
+ target._.accessCache[key] = 0;
6781
+ }
6782
+ else if (shared.hasOwn(descriptor, 'value')) {
6783
+ this.set(target, key, descriptor.value, null);
6784
+ }
6785
+ return Reflect.defineProperty(target, key, descriptor);
6725
6786
  }
6726
6787
  };
6727
6788
  {
@@ -6924,6 +6985,7 @@ function setupComponent(instance, isSSR = false) {
6924
6985
  return setupResult;
6925
6986
  }
6926
6987
  function setupStatefulComponent(instance, isSSR) {
6988
+ var _a;
6927
6989
  const Component = instance.type;
6928
6990
  {
6929
6991
  if (Component.name) {
@@ -6981,6 +7043,13 @@ function setupStatefulComponent(instance, isSSR) {
6981
7043
  // async setup returned Promise.
6982
7044
  // bail here and wait for re-entry.
6983
7045
  instance.asyncDep = setupResult;
7046
+ if (!instance.suspense) {
7047
+ const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
7048
+ warn(`Component <${name}>: setup function returned a promise, but no ` +
7049
+ `<Suspense> boundary was found in the parent component tree. ` +
7050
+ `A component with async setup() must be nested in a <Suspense> ` +
7051
+ `in order to be rendered.`);
7052
+ }
6984
7053
  }
6985
7054
  }
6986
7055
  else {
@@ -7605,7 +7674,7 @@ function isMemoSame(cached, memo) {
7605
7674
  }
7606
7675
 
7607
7676
  // Core API ------------------------------------------------------------------
7608
- const version = "3.2.30";
7677
+ const version = "3.2.33";
7609
7678
  const _ssrUtils = {
7610
7679
  createComponentInstance,
7611
7680
  setupComponent,
@@ -184,7 +184,7 @@ let preFlushIndex = 0;
184
184
  const pendingPostFlushCbs = [];
185
185
  let activePostFlushCbs = null;
186
186
  let postFlushIndex = 0;
187
- const resolvedPromise = Promise.resolve();
187
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
188
188
  let currentFlushPromise = null;
189
189
  let currentPreFlushParentJob = null;
190
190
  function nextTick(fn) {
@@ -375,6 +375,8 @@ function setDevtoolsHook(hook, target) {
375
375
  }
376
376
 
377
377
  function emit(instance, event, ...rawArgs) {
378
+ if (instance.isUnmounted)
379
+ return;
378
380
  const props = instance.vnode.props || shared.EMPTY_OBJ;
379
381
  let args = rawArgs;
380
382
  const isModelListener = event.startsWith('update:');
@@ -1472,12 +1474,20 @@ const BaseTransitionImpl = {
1472
1474
  if (!children || !children.length) {
1473
1475
  return;
1474
1476
  }
1477
+ let child = children[0];
1478
+ if (children.length > 1) {
1479
+ // locate first non-comment child
1480
+ for (const c of children) {
1481
+ if (c.type !== Comment) {
1482
+ child = c;
1483
+ break;
1484
+ }
1485
+ }
1486
+ }
1475
1487
  // there's no need to track reactivity for these props so use the raw
1476
1488
  // props for a bit better perf
1477
1489
  const rawProps = reactivity.toRaw(props);
1478
1490
  const { mode } = rawProps;
1479
- // at this point children has a guaranteed length of 1.
1480
- const child = children[0];
1481
1491
  if (state.isLeaving) {
1482
1492
  return emptyPlaceholder(child);
1483
1493
  }
@@ -1700,20 +1710,24 @@ function setTransitionHooks(vnode, hooks) {
1700
1710
  vnode.transition = hooks;
1701
1711
  }
1702
1712
  }
1703
- function getTransitionRawChildren(children, keepComment = false) {
1713
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1704
1714
  let ret = [];
1705
1715
  let keyedFragmentCount = 0;
1706
1716
  for (let i = 0; i < children.length; i++) {
1707
- const child = children[i];
1717
+ let child = children[i];
1718
+ // #5360 inherit parent key in case of <template v-for>
1719
+ const key = parentKey == null
1720
+ ? child.key
1721
+ : String(parentKey) + String(child.key != null ? child.key : i);
1708
1722
  // handle fragment children case, e.g. v-for
1709
1723
  if (child.type === Fragment) {
1710
1724
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
1711
1725
  keyedFragmentCount++;
1712
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
1726
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
1713
1727
  }
1714
1728
  // comment placeholders should be skipped, e.g. v-if
1715
1729
  else if (keepComment || child.type !== Comment) {
1716
- ret.push(child);
1730
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
1717
1731
  }
1718
1732
  }
1719
1733
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -2557,6 +2571,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
2557
2571
  const propsToUpdate = instance.vnode.dynamicProps;
2558
2572
  for (let i = 0; i < propsToUpdate.length; i++) {
2559
2573
  let key = propsToUpdate[i];
2574
+ // skip if the prop key is a declared emit event listener
2575
+ if (isEmitListener(instance.emitsOptions, key)) {
2576
+ continue;
2577
+ }
2560
2578
  // PROPS flag guarantees rawProps to be non-null
2561
2579
  const value = rawProps[key];
2562
2580
  if (options) {
@@ -2914,7 +2932,8 @@ function withDirectives(vnode, directives) {
2914
2932
  if (internalInstance === null) {
2915
2933
  return vnode;
2916
2934
  }
2917
- const instance = internalInstance.proxy;
2935
+ const instance = getExposeProxy(internalInstance) ||
2936
+ internalInstance.proxy;
2918
2937
  const bindings = vnode.dirs || (vnode.dirs = []);
2919
2938
  for (let i = 0; i < directives.length; i++) {
2920
2939
  let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i];
@@ -2986,6 +3005,9 @@ function createAppContext() {
2986
3005
  let uid = 0;
2987
3006
  function createAppAPI(render, hydrate) {
2988
3007
  return function createApp(rootComponent, rootProps = null) {
3008
+ if (!shared.isFunction(rootComponent)) {
3009
+ rootComponent = Object.assign({}, rootComponent);
3010
+ }
2989
3011
  if (rootProps != null && !shared.isObject(rootProps)) {
2990
3012
  rootProps = null;
2991
3013
  }
@@ -3125,6 +3147,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3125
3147
  if (!shared.isArray(existing)) {
3126
3148
  if (_isString) {
3127
3149
  refs[ref] = [refValue];
3150
+ if (shared.hasOwn(setupState, ref)) {
3151
+ setupState[ref] = refs[ref];
3152
+ }
3128
3153
  }
3129
3154
  else {
3130
3155
  ref.value = [refValue];
@@ -3311,6 +3336,7 @@ function createHydrationFunctions(rendererInternals) {
3311
3336
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
3312
3337
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
3313
3338
  // skip props & children if this is hoisted static nodes
3339
+ // #5405 in dev, always hydrate children for HMR
3314
3340
  if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
3315
3341
  if (dirs) {
3316
3342
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
@@ -4432,7 +4458,9 @@ function baseCreateRenderer(options, createHydrationFns) {
4432
4458
  const remove = vnode => {
4433
4459
  const { type, el, anchor, transition } = vnode;
4434
4460
  if (type === Fragment) {
4435
- removeFragment(el, anchor);
4461
+ {
4462
+ removeFragment(el, anchor);
4463
+ }
4436
4464
  return;
4437
4465
  }
4438
4466
  if (type === Static) {
@@ -5361,7 +5389,10 @@ function renderSlot(slots, name, props = {},
5361
5389
  // this is not a user-facing function, so the fallback is always generated by
5362
5390
  // the compiler and guaranteed to be a function returning an array
5363
5391
  fallback, noSlotted) {
5364
- if (currentRenderingInstance.isCE) {
5392
+ if (currentRenderingInstance.isCE ||
5393
+ (currentRenderingInstance.parent &&
5394
+ isAsyncWrapper(currentRenderingInstance.parent) &&
5395
+ currentRenderingInstance.parent.isCE)) {
5365
5396
  return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5366
5397
  }
5367
5398
  let slot = slots[name];
@@ -5424,7 +5455,10 @@ const getPublicInstance = (i) => {
5424
5455
  return getExposeProxy(i) || i.proxy;
5425
5456
  return getPublicInstance(i.parent);
5426
5457
  };
5427
- const publicPropertiesMap = shared.extend(Object.create(null), {
5458
+ const publicPropertiesMap =
5459
+ // Move PURE marker to new line to workaround compiler discarding it
5460
+ // due to type annotation
5461
+ /*#__PURE__*/ shared.extend(Object.create(null), {
5428
5462
  $: i => i,
5429
5463
  $el: i => i.vnode.el,
5430
5464
  $data: i => i.data,
@@ -5523,9 +5557,11 @@ const PublicInstanceProxyHandlers = {
5523
5557
  const { data, setupState, ctx } = instance;
5524
5558
  if (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) {
5525
5559
  setupState[key] = value;
5560
+ return true;
5526
5561
  }
5527
5562
  else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
5528
5563
  data[key] = value;
5564
+ return true;
5529
5565
  }
5530
5566
  else if (shared.hasOwn(instance.props, key)) {
5531
5567
  return false;
@@ -5549,6 +5585,16 @@ const PublicInstanceProxyHandlers = {
5549
5585
  shared.hasOwn(ctx, key) ||
5550
5586
  shared.hasOwn(publicPropertiesMap, key) ||
5551
5587
  shared.hasOwn(appContext.config.globalProperties, key));
5588
+ },
5589
+ defineProperty(target, key, descriptor) {
5590
+ if (descriptor.get != null) {
5591
+ // invalidate key cache of a getter based property #5417
5592
+ target._.accessCache[key] = 0;
5593
+ }
5594
+ else if (shared.hasOwn(descriptor, 'value')) {
5595
+ this.set(target, key, descriptor.value, null);
5596
+ }
5597
+ return Reflect.defineProperty(target, key, descriptor);
5552
5598
  }
5553
5599
  };
5554
5600
  const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ shared.extend({}, PublicInstanceProxyHandlers, {
@@ -6069,7 +6115,7 @@ function isMemoSame(cached, memo) {
6069
6115
  }
6070
6116
 
6071
6117
  // Core API ------------------------------------------------------------------
6072
- const version = "3.2.30";
6118
+ const version = "3.2.33";
6073
6119
  const _ssrUtils = {
6074
6120
  createComponentInstance,
6075
6121
  setupComponent,
@@ -904,7 +904,7 @@ export declare const getCurrentInstance: () => ComponentInternalInstance | null;
904
904
 
905
905
  export { getCurrentScope }
906
906
 
907
- export declare function getTransitionRawChildren(children: VNode[], keepComment?: boolean): VNode[];
907
+ export declare function getTransitionRawChildren(children: VNode[], keepComment?: boolean, parentKey?: VNode['key']): VNode[];
908
908
 
909
909
  export declare function guardReactiveProps(props: (Data & VNodeProps) | null): (Data & VNodeProps) | null;
910
910
 
@@ -237,7 +237,7 @@ let preFlushIndex = 0;
237
237
  const pendingPostFlushCbs = [];
238
238
  let activePostFlushCbs = null;
239
239
  let postFlushIndex = 0;
240
- const resolvedPromise = Promise.resolve();
240
+ const resolvedPromise = /*#__PURE__*/ Promise.resolve();
241
241
  let currentFlushPromise = null;
242
242
  let currentPreFlushParentJob = null;
243
243
  const RECURSION_LIMIT = 100;
@@ -656,6 +656,8 @@ function devtoolsComponentEmit(component, event, params) {
656
656
  }
657
657
 
658
658
  function emit$1(instance, event, ...rawArgs) {
659
+ if (instance.isUnmounted)
660
+ return;
659
661
  const props = instance.vnode.props || EMPTY_OBJ;
660
662
  if ((process.env.NODE_ENV !== 'production')) {
661
663
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -1645,13 +1647,11 @@ function watchEffect(effect, options) {
1645
1647
  }
1646
1648
  function watchPostEffect(effect, options) {
1647
1649
  return doWatch(effect, null, ((process.env.NODE_ENV !== 'production')
1648
- ? Object.assign(options || {}, { flush: 'post' })
1649
- : { flush: 'post' }));
1650
+ ? Object.assign(Object.assign({}, options), { flush: 'post' }) : { flush: 'post' }));
1650
1651
  }
1651
1652
  function watchSyncEffect(effect, options) {
1652
1653
  return doWatch(effect, null, ((process.env.NODE_ENV !== 'production')
1653
- ? Object.assign(options || {}, { flush: 'sync' })
1654
- : { flush: 'sync' }));
1654
+ ? Object.assign(Object.assign({}, options), { flush: 'sync' }) : { flush: 'sync' }));
1655
1655
  }
1656
1656
  // initial value for watchers to trigger on undefined initial values
1657
1657
  const INITIAL_WATCHER_VALUE = {};
@@ -1954,10 +1954,24 @@ const BaseTransitionImpl = {
1954
1954
  if (!children || !children.length) {
1955
1955
  return;
1956
1956
  }
1957
- // warn multiple elements
1958
- if ((process.env.NODE_ENV !== 'production') && children.length > 1) {
1959
- warn('<transition> can only be used on a single element or component. Use ' +
1960
- '<transition-group> for lists.');
1957
+ let child = children[0];
1958
+ if (children.length > 1) {
1959
+ let hasFound = false;
1960
+ // locate first non-comment child
1961
+ for (const c of children) {
1962
+ if (c.type !== Comment) {
1963
+ if ((process.env.NODE_ENV !== 'production') && hasFound) {
1964
+ // warn more than one non-comment child
1965
+ warn('<transition> can only be used on a single element or component. ' +
1966
+ 'Use <transition-group> for lists.');
1967
+ break;
1968
+ }
1969
+ child = c;
1970
+ hasFound = true;
1971
+ if (!(process.env.NODE_ENV !== 'production'))
1972
+ break;
1973
+ }
1974
+ }
1961
1975
  }
1962
1976
  // there's no need to track reactivity for these props so use the raw
1963
1977
  // props for a bit better perf
@@ -1966,11 +1980,11 @@ const BaseTransitionImpl = {
1966
1980
  // check mode
1967
1981
  if ((process.env.NODE_ENV !== 'production') &&
1968
1982
  mode &&
1969
- mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
1983
+ mode !== 'in-out' &&
1984
+ mode !== 'out-in' &&
1985
+ mode !== 'default') {
1970
1986
  warn(`invalid <transition> mode: ${mode}`);
1971
1987
  }
1972
- // at this point children has a guaranteed length of 1.
1973
- const child = children[0];
1974
1988
  if (state.isLeaving) {
1975
1989
  return emptyPlaceholder(child);
1976
1990
  }
@@ -2193,20 +2207,24 @@ function setTransitionHooks(vnode, hooks) {
2193
2207
  vnode.transition = hooks;
2194
2208
  }
2195
2209
  }
2196
- function getTransitionRawChildren(children, keepComment = false) {
2210
+ function getTransitionRawChildren(children, keepComment = false, parentKey) {
2197
2211
  let ret = [];
2198
2212
  let keyedFragmentCount = 0;
2199
2213
  for (let i = 0; i < children.length; i++) {
2200
- const child = children[i];
2214
+ let child = children[i];
2215
+ // #5360 inherit parent key in case of <template v-for>
2216
+ const key = parentKey == null
2217
+ ? child.key
2218
+ : String(parentKey) + String(child.key != null ? child.key : i);
2201
2219
  // handle fragment children case, e.g. v-for
2202
2220
  if (child.type === Fragment) {
2203
2221
  if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
2204
2222
  keyedFragmentCount++;
2205
- ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
2223
+ ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key));
2206
2224
  }
2207
2225
  // comment placeholders should be skipped, e.g. v-if
2208
2226
  else if (keepComment || child.type !== Comment) {
2209
- ret.push(child);
2227
+ ret.push(key != null ? cloneVNode(child, { key }) : child);
2210
2228
  }
2211
2229
  }
2212
2230
  // #1126 if a transition children list contains multiple sub fragments, these
@@ -3178,6 +3196,10 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3178
3196
  const propsToUpdate = instance.vnode.dynamicProps;
3179
3197
  for (let i = 0; i < propsToUpdate.length; i++) {
3180
3198
  let key = propsToUpdate[i];
3199
+ // skip if the prop key is a declared emit event listener
3200
+ if (isEmitListener(instance.emitsOptions, key)) {
3201
+ continue;
3202
+ }
3181
3203
  // PROPS flag guarantees rawProps to be non-null
3182
3204
  const value = rawProps[key];
3183
3205
  if (options) {
@@ -3704,7 +3726,8 @@ function withDirectives(vnode, directives) {
3704
3726
  (process.env.NODE_ENV !== 'production') && warn(`withDirectives can only be used inside render functions.`);
3705
3727
  return vnode;
3706
3728
  }
3707
- const instance = internalInstance.proxy;
3729
+ const instance = getExposeProxy(internalInstance) ||
3730
+ internalInstance.proxy;
3708
3731
  const bindings = vnode.dirs || (vnode.dirs = []);
3709
3732
  for (let i = 0; i < directives.length; i++) {
3710
3733
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -3776,6 +3799,9 @@ function createAppContext() {
3776
3799
  let uid = 0;
3777
3800
  function createAppAPI(render, hydrate) {
3778
3801
  return function createApp(rootComponent, rootProps = null) {
3802
+ if (!isFunction(rootComponent)) {
3803
+ rootComponent = Object.assign({}, rootComponent);
3804
+ }
3779
3805
  if (rootProps != null && !isObject(rootProps)) {
3780
3806
  (process.env.NODE_ENV !== 'production') && warn(`root props passed to app.mount() must be an object.`);
3781
3807
  rootProps = null;
@@ -3975,6 +4001,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3975
4001
  if (!isArray(existing)) {
3976
4002
  if (_isString) {
3977
4003
  refs[ref] = [refValue];
4004
+ if (hasOwn(setupState, ref)) {
4005
+ setupState[ref] = refs[ref];
4006
+ }
3978
4007
  }
3979
4008
  else {
3980
4009
  ref.value = [refValue];
@@ -4175,7 +4204,8 @@ function createHydrationFunctions(rendererInternals) {
4175
4204
  // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
4176
4205
  const forcePatchValue = (type === 'input' && dirs) || type === 'option';
4177
4206
  // skip props & children if this is hoisted static nodes
4178
- if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
4207
+ // #5405 in dev, always hydrate children for HMR
4208
+ if ((process.env.NODE_ENV !== 'production') || forcePatchValue || patchFlag !== -1 /* HOISTED */) {
4179
4209
  if (dirs) {
4180
4210
  invokeDirectiveHook(vnode, null, parentComponent, 'created');
4181
4211
  }
@@ -4350,7 +4380,7 @@ function startMeasure(instance, type) {
4350
4380
  perf.mark(`vue-${type}-${instance.uid}`);
4351
4381
  }
4352
4382
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
4353
- devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
4383
+ devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
4354
4384
  }
4355
4385
  }
4356
4386
  function endMeasure(instance, type) {
@@ -4363,7 +4393,7 @@ function endMeasure(instance, type) {
4363
4393
  perf.clearMarks(endTag);
4364
4394
  }
4365
4395
  if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
4366
- devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
4396
+ devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
4367
4397
  }
4368
4398
  }
4369
4399
  function isSupported() {
@@ -5533,7 +5563,23 @@ function baseCreateRenderer(options, createHydrationFns) {
5533
5563
  const remove = vnode => {
5534
5564
  const { type, el, anchor, transition } = vnode;
5535
5565
  if (type === Fragment) {
5536
- removeFragment(el, anchor);
5566
+ if ((process.env.NODE_ENV !== 'production') &&
5567
+ vnode.patchFlag > 0 &&
5568
+ vnode.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */ &&
5569
+ transition &&
5570
+ !transition.persisted) {
5571
+ vnode.children.forEach(child => {
5572
+ if (child.type === Comment) {
5573
+ hostRemove(child.el);
5574
+ }
5575
+ else {
5576
+ remove(child);
5577
+ }
5578
+ });
5579
+ }
5580
+ else {
5581
+ removeFragment(el, anchor);
5582
+ }
5537
5583
  return;
5538
5584
  }
5539
5585
  if (type === Static) {
@@ -6557,7 +6603,10 @@ function renderSlot(slots, name, props = {},
6557
6603
  // this is not a user-facing function, so the fallback is always generated by
6558
6604
  // the compiler and guaranteed to be a function returning an array
6559
6605
  fallback, noSlotted) {
6560
- if (currentRenderingInstance.isCE) {
6606
+ if (currentRenderingInstance.isCE ||
6607
+ (currentRenderingInstance.parent &&
6608
+ isAsyncWrapper(currentRenderingInstance.parent) &&
6609
+ currentRenderingInstance.parent.isCE)) {
6561
6610
  return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
6562
6611
  }
6563
6612
  let slot = slots[name];
@@ -6630,7 +6679,10 @@ const getPublicInstance = (i) => {
6630
6679
  return getExposeProxy(i) || i.proxy;
6631
6680
  return getPublicInstance(i.parent);
6632
6681
  };
6633
- const publicPropertiesMap = extend(Object.create(null), {
6682
+ const publicPropertiesMap =
6683
+ // Move PURE marker to new line to workaround compiler discarding it
6684
+ // due to type annotation
6685
+ /*#__PURE__*/ extend(Object.create(null), {
6634
6686
  $: i => i,
6635
6687
  $el: i => i.vnode.el,
6636
6688
  $data: i => i.data,
@@ -6760,9 +6812,11 @@ const PublicInstanceProxyHandlers = {
6760
6812
  const { data, setupState, ctx } = instance;
6761
6813
  if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
6762
6814
  setupState[key] = value;
6815
+ return true;
6763
6816
  }
6764
6817
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
6765
6818
  data[key] = value;
6819
+ return true;
6766
6820
  }
6767
6821
  else if (hasOwn(instance.props, key)) {
6768
6822
  (process.env.NODE_ENV !== 'production') &&
@@ -6798,6 +6852,16 @@ const PublicInstanceProxyHandlers = {
6798
6852
  hasOwn(ctx, key) ||
6799
6853
  hasOwn(publicPropertiesMap, key) ||
6800
6854
  hasOwn(appContext.config.globalProperties, key));
6855
+ },
6856
+ defineProperty(target, key, descriptor) {
6857
+ if (descriptor.get != null) {
6858
+ // invalidate key cache of a getter based property #5417
6859
+ target._.accessCache[key] = 0;
6860
+ }
6861
+ else if (hasOwn(descriptor, 'value')) {
6862
+ this.set(target, key, descriptor.value, null);
6863
+ }
6864
+ return Reflect.defineProperty(target, key, descriptor);
6801
6865
  }
6802
6866
  };
6803
6867
  if ((process.env.NODE_ENV !== 'production') && !false) {
@@ -7003,6 +7067,7 @@ function setupComponent(instance, isSSR = false) {
7003
7067
  return setupResult;
7004
7068
  }
7005
7069
  function setupStatefulComponent(instance, isSSR) {
7070
+ var _a;
7006
7071
  const Component = instance.type;
7007
7072
  if ((process.env.NODE_ENV !== 'production')) {
7008
7073
  if (Component.name) {
@@ -7060,6 +7125,13 @@ function setupStatefulComponent(instance, isSSR) {
7060
7125
  // async setup returned Promise.
7061
7126
  // bail here and wait for re-entry.
7062
7127
  instance.asyncDep = setupResult;
7128
+ if ((process.env.NODE_ENV !== 'production') && !instance.suspense) {
7129
+ const name = (_a = Component.name) !== null && _a !== void 0 ? _a : 'Anonymous';
7130
+ warn(`Component <${name}>: setup function returned a promise, but no ` +
7131
+ `<Suspense> boundary was found in the parent component tree. ` +
7132
+ `A component with async setup() must be nested in a <Suspense> ` +
7133
+ `in order to be rendered.`);
7134
+ }
7063
7135
  }
7064
7136
  }
7065
7137
  else {
@@ -7701,7 +7773,7 @@ function isMemoSame(cached, memo) {
7701
7773
  }
7702
7774
 
7703
7775
  // Core API ------------------------------------------------------------------
7704
- const version = "3.2.30";
7776
+ const version = "3.2.33";
7705
7777
  const _ssrUtils = {
7706
7778
  createComponentInstance,
7707
7779
  setupComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.2.30",
3
+ "version": "3.2.33",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.30",
36
- "@vue/reactivity": "3.2.30"
35
+ "@vue/shared": "3.2.33",
36
+ "@vue/reactivity": "3.2.33"
37
37
  }
38
38
  }