@vue/runtime-core 3.2.21 → 3.2.25

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.
@@ -157,6 +157,7 @@ function emit(event, ...args) {
157
157
  }
158
158
  }
159
159
  function setDevtoolsHook(hook, target) {
160
+ var _a, _b;
160
161
  exports.devtools = hook;
161
162
  if (exports.devtools) {
162
163
  exports.devtools.enabled = true;
@@ -169,7 +170,10 @@ function setDevtoolsHook(hook, target) {
169
170
  // (#4815)
170
171
  // eslint-disable-next-line no-restricted-globals
171
172
  typeof window !== 'undefined' &&
172
- !navigator.userAgent.includes('jsdom')) {
173
+ // some envs mock window but not fully
174
+ window.HTMLElement &&
175
+ // also exclude jsdom
176
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
173
177
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
174
178
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
175
179
  replay.push((newHook) => {
@@ -1263,7 +1267,8 @@ const BaseTransitionImpl = {
1263
1267
  const rawProps = reactivity.toRaw(props);
1264
1268
  const { mode } = rawProps;
1265
1269
  // check mode
1266
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
1270
+ if (mode &&
1271
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
1267
1272
  warn(`invalid <transition> mode: ${mode}`);
1268
1273
  }
1269
1274
  // at this point children has a guaranteed length of 1.
@@ -1903,7 +1908,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
1903
1908
  }
1904
1909
  current = current.parent;
1905
1910
  }
1906
- hook();
1911
+ return hook();
1907
1912
  });
1908
1913
  injectHook(type, wrappedHook, target);
1909
1914
  // In addition to registering it on the target instance, we walk up the parent
@@ -2565,7 +2570,7 @@ function setFullProps(instance, rawProps, props, attrs) {
2565
2570
  }
2566
2571
  }
2567
2572
  else if (!isEmitListener(instance.emitsOptions, key)) {
2568
- if (value !== attrs[key]) {
2573
+ if (!(key in attrs) || value !== attrs[key]) {
2569
2574
  attrs[key] = value;
2570
2575
  hasAttrsChanged = true;
2571
2576
  }
@@ -3205,6 +3210,102 @@ function createAppAPI(render, hydrate) {
3205
3210
  };
3206
3211
  }
3207
3212
 
3213
+ /**
3214
+ * Function for handling a template ref
3215
+ */
3216
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3217
+ if (shared.isArray(rawRef)) {
3218
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
3219
+ return;
3220
+ }
3221
+ if (isAsyncWrapper(vnode) && !isUnmount) {
3222
+ // when mounting async components, nothing needs to be done,
3223
+ // because the template ref is forwarded to inner component
3224
+ return;
3225
+ }
3226
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
3227
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
3228
+ : vnode.el;
3229
+ const value = isUnmount ? null : refValue;
3230
+ const { i: owner, r: ref } = rawRef;
3231
+ if (!owner) {
3232
+ warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
3233
+ `A vnode with ref must be created inside the render function.`);
3234
+ return;
3235
+ }
3236
+ const oldRef = oldRawRef && oldRawRef.r;
3237
+ const refs = owner.refs === shared.EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
3238
+ const setupState = owner.setupState;
3239
+ // dynamic ref changed. unset old ref
3240
+ if (oldRef != null && oldRef !== ref) {
3241
+ if (shared.isString(oldRef)) {
3242
+ refs[oldRef] = null;
3243
+ if (shared.hasOwn(setupState, oldRef)) {
3244
+ setupState[oldRef] = null;
3245
+ }
3246
+ }
3247
+ else if (reactivity.isRef(oldRef)) {
3248
+ oldRef.value = null;
3249
+ }
3250
+ }
3251
+ if (shared.isFunction(ref)) {
3252
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
3253
+ }
3254
+ else {
3255
+ const _isString = shared.isString(ref);
3256
+ const _isRef = reactivity.isRef(ref);
3257
+ if (_isString || _isRef) {
3258
+ const doSet = () => {
3259
+ if (rawRef.f) {
3260
+ const existing = _isString ? refs[ref] : ref.value;
3261
+ if (isUnmount) {
3262
+ shared.isArray(existing) && shared.remove(existing, refValue);
3263
+ }
3264
+ else {
3265
+ if (!shared.isArray(existing)) {
3266
+ if (_isString) {
3267
+ refs[ref] = [refValue];
3268
+ }
3269
+ else {
3270
+ ref.value = [refValue];
3271
+ if (rawRef.k)
3272
+ refs[rawRef.k] = ref.value;
3273
+ }
3274
+ }
3275
+ else if (!existing.includes(refValue)) {
3276
+ existing.push(refValue);
3277
+ }
3278
+ }
3279
+ }
3280
+ else if (_isString) {
3281
+ refs[ref] = value;
3282
+ if (shared.hasOwn(setupState, ref)) {
3283
+ setupState[ref] = value;
3284
+ }
3285
+ }
3286
+ else if (reactivity.isRef(ref)) {
3287
+ ref.value = value;
3288
+ if (rawRef.k)
3289
+ refs[rawRef.k] = value;
3290
+ }
3291
+ else {
3292
+ warn('Invalid template ref type:', ref, `(${typeof ref})`);
3293
+ }
3294
+ };
3295
+ if (value) {
3296
+ doSet.id = -1;
3297
+ queuePostRenderEffect(doSet, parentSuspense);
3298
+ }
3299
+ else {
3300
+ doSet();
3301
+ }
3302
+ }
3303
+ else {
3304
+ warn('Invalid template ref type:', ref, `(${typeof ref})`);
3305
+ }
3306
+ }
3307
+ }
3308
+
3208
3309
  let hasMismatch = false;
3209
3310
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
3210
3311
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -3837,12 +3938,15 @@ function baseCreateRenderer(options, createHydrationFns) {
3837
3938
  const oldProps = n1.props || shared.EMPTY_OBJ;
3838
3939
  const newProps = n2.props || shared.EMPTY_OBJ;
3839
3940
  let vnodeHook;
3941
+ // disable recurse in beforeUpdate hooks
3942
+ parentComponent && toggleRecurse(parentComponent, false);
3840
3943
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
3841
3944
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3842
3945
  }
3843
3946
  if (dirs) {
3844
3947
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
3845
3948
  }
3949
+ parentComponent && toggleRecurse(parentComponent, true);
3846
3950
  if (isHmrUpdating) {
3847
3951
  // HMR updated, force full diff
3848
3952
  patchFlag = 0;
@@ -4122,7 +4226,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4122
4226
  const { el, props } = initialVNode;
4123
4227
  const { bm, m, parent } = instance;
4124
4228
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4125
- effect.allowRecurse = false;
4229
+ toggleRecurse(instance, false);
4126
4230
  // beforeMount hook
4127
4231
  if (bm) {
4128
4232
  shared.invokeArrayFns(bm);
@@ -4132,7 +4236,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4132
4236
  (vnodeHook = props && props.onVnodeBeforeMount)) {
4133
4237
  invokeVNodeHook(vnodeHook, parent, initialVNode);
4134
4238
  }
4135
- effect.allowRecurse = true;
4239
+ toggleRecurse(instance, true);
4136
4240
  if (el && hydrateNode) {
4137
4241
  // vnode has adopted host node - perform hydration instead of mount.
4138
4242
  const hydrateSubTree = () => {
@@ -4214,7 +4318,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4214
4318
  pushWarningContext(next || instance.vnode);
4215
4319
  }
4216
4320
  // Disallow component effect recursion during pre-lifecycle hooks.
4217
- effect.allowRecurse = false;
4321
+ toggleRecurse(instance, false);
4218
4322
  if (next) {
4219
4323
  next.el = vnode.el;
4220
4324
  updateComponentPreRender(instance, next, optimized);
@@ -4230,7 +4334,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4230
4334
  if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
4231
4335
  invokeVNodeHook(vnodeHook, parent, next, vnode);
4232
4336
  }
4233
- effect.allowRecurse = true;
4337
+ toggleRecurse(instance, true);
4234
4338
  // render
4235
4339
  {
4236
4340
  startMeasure(instance, `render`);
@@ -4276,13 +4380,13 @@ function baseCreateRenderer(options, createHydrationFns) {
4276
4380
  }
4277
4381
  };
4278
4382
  // create reactive effect for rendering
4279
- const effect = new reactivity.ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
4280
- );
4383
+ const effect = (instance.effect = new reactivity.ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
4384
+ ));
4281
4385
  const update = (instance.update = effect.run.bind(effect));
4282
4386
  update.id = instance.uid;
4283
4387
  // allowRecurse
4284
4388
  // #1801, #2043 component render effects should allow recursive updates
4285
- effect.allowRecurse = update.allowRecurse = true;
4389
+ toggleRecurse(instance, true);
4286
4390
  {
4287
4391
  effect.onTrack = instance.rtc
4288
4392
  ? e => shared.invokeArrayFns(instance.rtc, e)
@@ -4806,85 +4910,8 @@ function baseCreateRenderer(options, createHydrationFns) {
4806
4910
  createApp: createAppAPI(render, hydrate)
4807
4911
  };
4808
4912
  }
4809
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
4810
- if (shared.isArray(rawRef)) {
4811
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (shared.isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
4812
- return;
4813
- }
4814
- if (isAsyncWrapper(vnode) && !isUnmount) {
4815
- // when mounting async components, nothing needs to be done,
4816
- // because the template ref is forwarded to inner component
4817
- return;
4818
- }
4819
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4820
- ? getExposeProxy(vnode.component) || vnode.component.proxy
4821
- : vnode.el;
4822
- const value = isUnmount ? null : refValue;
4823
- const { i: owner, r: ref } = rawRef;
4824
- if (!owner) {
4825
- warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
4826
- `A vnode with ref must be created inside the render function.`);
4827
- return;
4828
- }
4829
- const oldRef = oldRawRef && oldRawRef.r;
4830
- const refs = owner.refs === shared.EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
4831
- const setupState = owner.setupState;
4832
- // dynamic ref changed. unset old ref
4833
- if (oldRef != null && oldRef !== ref) {
4834
- if (shared.isString(oldRef)) {
4835
- refs[oldRef] = null;
4836
- if (shared.hasOwn(setupState, oldRef)) {
4837
- setupState[oldRef] = null;
4838
- }
4839
- }
4840
- else if (reactivity.isRef(oldRef)) {
4841
- oldRef.value = null;
4842
- }
4843
- }
4844
- if (shared.isString(ref)) {
4845
- const doSet = () => {
4846
- {
4847
- refs[ref] = value;
4848
- }
4849
- if (shared.hasOwn(setupState, ref)) {
4850
- setupState[ref] = value;
4851
- }
4852
- };
4853
- // #1789: for non-null values, set them after render
4854
- // null values means this is unmount and it should not overwrite another
4855
- // ref with the same key
4856
- if (value) {
4857
- doSet.id = -1;
4858
- queuePostRenderEffect(doSet, parentSuspense);
4859
- }
4860
- else {
4861
- doSet();
4862
- }
4863
- }
4864
- else if (reactivity.isRef(ref)) {
4865
- const doSet = () => {
4866
- ref.value = value;
4867
- };
4868
- if (value) {
4869
- doSet.id = -1;
4870
- queuePostRenderEffect(doSet, parentSuspense);
4871
- }
4872
- else {
4873
- doSet();
4874
- }
4875
- }
4876
- else if (shared.isFunction(ref)) {
4877
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4878
- }
4879
- else {
4880
- warn('Invalid template ref type:', value, `(${typeof value})`);
4881
- }
4882
- }
4883
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
4884
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
4885
- vnode,
4886
- prevVNode
4887
- ]);
4913
+ function toggleRecurse({ effect, update }, allowed) {
4914
+ effect.allowRecurse = update.allowRecurse = allowed;
4888
4915
  }
4889
4916
  /**
4890
4917
  * #1156
@@ -4894,8 +4921,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
4894
4921
  *
4895
4922
  * #2080
4896
4923
  * Inside keyed `template` fragment static children, if a fragment is moved,
4897
- * the children will always moved so that need inherit el form previous nodes
4898
- * to ensure correct moved position.
4924
+ * the children will always be moved. Therefore, in order to ensure correct move
4925
+ * position, el should be inherited from previous nodes.
4899
4926
  */
4900
4927
  function traverseStaticChildren(n1, n2, shallow = false) {
4901
4928
  const ch1 = n1.children;
@@ -5343,10 +5370,10 @@ const createVNodeWithArgsTransform = (...args) => {
5343
5370
  };
5344
5371
  const InternalObjectKey = `__vInternal`;
5345
5372
  const normalizeKey = ({ key }) => key != null ? key : null;
5346
- const normalizeRef = ({ ref }) => {
5373
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
5347
5374
  return (ref != null
5348
5375
  ? shared.isString(ref) || reactivity.isRef(ref) || shared.isFunction(ref)
5349
- ? { i: currentRenderingInstance, r: ref }
5376
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
5350
5377
  : ref
5351
5378
  : null);
5352
5379
  };
@@ -5675,7 +5702,8 @@ function mergeProps(...args) {
5675
5702
  else if (shared.isOn(key)) {
5676
5703
  const existing = ret[key];
5677
5704
  const incoming = toMerge[key];
5678
- if (existing !== incoming) {
5705
+ if (existing !== incoming &&
5706
+ !(shared.isArray(existing) && existing.includes(incoming))) {
5679
5707
  ret[key] = existing
5680
5708
  ? [].concat(existing, incoming)
5681
5709
  : incoming;
@@ -5687,6 +5715,12 @@ function mergeProps(...args) {
5687
5715
  }
5688
5716
  }
5689
5717
  return ret;
5718
+ }
5719
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
5720
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
5721
+ vnode,
5722
+ prevVNode
5723
+ ]);
5690
5724
  }
5691
5725
 
5692
5726
  /**
@@ -5878,23 +5912,23 @@ const PublicInstanceProxyHandlers = {
5878
5912
  const n = accessCache[key];
5879
5913
  if (n !== undefined) {
5880
5914
  switch (n) {
5881
- case 0 /* SETUP */:
5915
+ case 1 /* SETUP */:
5882
5916
  return setupState[key];
5883
- case 1 /* DATA */:
5917
+ case 2 /* DATA */:
5884
5918
  return data[key];
5885
- case 3 /* CONTEXT */:
5919
+ case 4 /* CONTEXT */:
5886
5920
  return ctx[key];
5887
- case 2 /* PROPS */:
5921
+ case 3 /* PROPS */:
5888
5922
  return props[key];
5889
5923
  // default: just fallthrough
5890
5924
  }
5891
5925
  }
5892
5926
  else if (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) {
5893
- accessCache[key] = 0 /* SETUP */;
5927
+ accessCache[key] = 1 /* SETUP */;
5894
5928
  return setupState[key];
5895
5929
  }
5896
5930
  else if (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) {
5897
- accessCache[key] = 1 /* DATA */;
5931
+ accessCache[key] = 2 /* DATA */;
5898
5932
  return data[key];
5899
5933
  }
5900
5934
  else if (
@@ -5902,15 +5936,15 @@ const PublicInstanceProxyHandlers = {
5902
5936
  // props
5903
5937
  (normalizedProps = instance.propsOptions[0]) &&
5904
5938
  shared.hasOwn(normalizedProps, key)) {
5905
- accessCache[key] = 2 /* PROPS */;
5939
+ accessCache[key] = 3 /* PROPS */;
5906
5940
  return props[key];
5907
5941
  }
5908
5942
  else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
5909
- accessCache[key] = 3 /* CONTEXT */;
5943
+ accessCache[key] = 4 /* CONTEXT */;
5910
5944
  return ctx[key];
5911
5945
  }
5912
5946
  else if (shouldCacheAccess) {
5913
- accessCache[key] = 4 /* OTHER */;
5947
+ accessCache[key] = 0 /* OTHER */;
5914
5948
  }
5915
5949
  }
5916
5950
  const publicGetter = publicPropertiesMap[key];
@@ -5931,7 +5965,7 @@ const PublicInstanceProxyHandlers = {
5931
5965
  }
5932
5966
  else if (ctx !== shared.EMPTY_OBJ && shared.hasOwn(ctx, key)) {
5933
5967
  // user may set custom properties to `this` that start with `$`
5934
- accessCache[key] = 3 /* CONTEXT */;
5968
+ accessCache[key] = 4 /* CONTEXT */;
5935
5969
  return ctx[key];
5936
5970
  }
5937
5971
  else if (
@@ -5992,7 +6026,7 @@ const PublicInstanceProxyHandlers = {
5992
6026
  },
5993
6027
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
5994
6028
  let normalizedProps;
5995
- return (accessCache[key] !== undefined ||
6029
+ return (!!accessCache[key] ||
5996
6030
  (data !== shared.EMPTY_OBJ && shared.hasOwn(data, key)) ||
5997
6031
  (setupState !== shared.EMPTY_OBJ && shared.hasOwn(setupState, key)) ||
5998
6032
  ((normalizedProps = propsOptions[0]) && shared.hasOwn(normalizedProps, key)) ||
@@ -6098,6 +6132,7 @@ function createComponentInstance(vnode, parent, suspense) {
6098
6132
  root: null,
6099
6133
  next: null,
6100
6134
  subTree: null,
6135
+ effect: null,
6101
6136
  update: null,
6102
6137
  scope: new reactivity.EffectScope(true /* detached */),
6103
6138
  render: null,
@@ -7560,7 +7595,7 @@ function isMemoSame(cached, memo) {
7560
7595
  }
7561
7596
 
7562
7597
  // Core API ------------------------------------------------------------------
7563
- const version = "3.2.21";
7598
+ const version = "3.2.25";
7564
7599
  const _ssrUtils = {
7565
7600
  createComponentInstance,
7566
7601
  setupComponent,