@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.
@@ -156,6 +156,7 @@ function emit(event, ...args) {
156
156
  }
157
157
  }
158
158
  function setDevtoolsHook(hook, target) {
159
+ var _a, _b;
159
160
  devtools = hook;
160
161
  if (devtools) {
161
162
  devtools.enabled = true;
@@ -168,7 +169,10 @@ function setDevtoolsHook(hook, target) {
168
169
  // (#4815)
169
170
  // eslint-disable-next-line no-restricted-globals
170
171
  typeof window !== 'undefined' &&
171
- !navigator.userAgent.includes('jsdom')) {
172
+ // some envs mock window but not fully
173
+ window.HTMLElement &&
174
+ // also exclude jsdom
175
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
172
176
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
173
177
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
174
178
  replay.push((newHook) => {
@@ -1263,7 +1267,9 @@ const BaseTransitionImpl = {
1263
1267
  const rawProps = toRaw(props);
1264
1268
  const { mode } = rawProps;
1265
1269
  // check mode
1266
- if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
1270
+ if ((process.env.NODE_ENV !== 'production') &&
1271
+ mode &&
1272
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
1267
1273
  warn(`invalid <transition> mode: ${mode}`);
1268
1274
  }
1269
1275
  // at this point children has a guaranteed length of 1.
@@ -1903,7 +1909,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
1903
1909
  }
1904
1910
  current = current.parent;
1905
1911
  }
1906
- hook();
1912
+ return hook();
1907
1913
  });
1908
1914
  injectHook(type, wrappedHook, target);
1909
1915
  // In addition to registering it on the target instance, we walk up the parent
@@ -2571,7 +2577,7 @@ function setFullProps(instance, rawProps, props, attrs) {
2571
2577
  }
2572
2578
  }
2573
2579
  else if (!isEmitListener(instance.emitsOptions, key)) {
2574
- if (value !== attrs[key]) {
2580
+ if (!(key in attrs) || value !== attrs[key]) {
2575
2581
  attrs[key] = value;
2576
2582
  hasAttrsChanged = true;
2577
2583
  }
@@ -3216,6 +3222,102 @@ function createAppAPI(render, hydrate) {
3216
3222
  };
3217
3223
  }
3218
3224
 
3225
+ /**
3226
+ * Function for handling a template ref
3227
+ */
3228
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
3229
+ if (isArray(rawRef)) {
3230
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
3231
+ return;
3232
+ }
3233
+ if (isAsyncWrapper(vnode) && !isUnmount) {
3234
+ // when mounting async components, nothing needs to be done,
3235
+ // because the template ref is forwarded to inner component
3236
+ return;
3237
+ }
3238
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
3239
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
3240
+ : vnode.el;
3241
+ const value = isUnmount ? null : refValue;
3242
+ const { i: owner, r: ref } = rawRef;
3243
+ if ((process.env.NODE_ENV !== 'production') && !owner) {
3244
+ warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
3245
+ `A vnode with ref must be created inside the render function.`);
3246
+ return;
3247
+ }
3248
+ const oldRef = oldRawRef && oldRawRef.r;
3249
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
3250
+ const setupState = owner.setupState;
3251
+ // dynamic ref changed. unset old ref
3252
+ if (oldRef != null && oldRef !== ref) {
3253
+ if (isString(oldRef)) {
3254
+ refs[oldRef] = null;
3255
+ if (hasOwn(setupState, oldRef)) {
3256
+ setupState[oldRef] = null;
3257
+ }
3258
+ }
3259
+ else if (isRef(oldRef)) {
3260
+ oldRef.value = null;
3261
+ }
3262
+ }
3263
+ if (isFunction(ref)) {
3264
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
3265
+ }
3266
+ else {
3267
+ const _isString = isString(ref);
3268
+ const _isRef = isRef(ref);
3269
+ if (_isString || _isRef) {
3270
+ const doSet = () => {
3271
+ if (rawRef.f) {
3272
+ const existing = _isString ? refs[ref] : ref.value;
3273
+ if (isUnmount) {
3274
+ isArray(existing) && remove(existing, refValue);
3275
+ }
3276
+ else {
3277
+ if (!isArray(existing)) {
3278
+ if (_isString) {
3279
+ refs[ref] = [refValue];
3280
+ }
3281
+ else {
3282
+ ref.value = [refValue];
3283
+ if (rawRef.k)
3284
+ refs[rawRef.k] = ref.value;
3285
+ }
3286
+ }
3287
+ else if (!existing.includes(refValue)) {
3288
+ existing.push(refValue);
3289
+ }
3290
+ }
3291
+ }
3292
+ else if (_isString) {
3293
+ refs[ref] = value;
3294
+ if (hasOwn(setupState, ref)) {
3295
+ setupState[ref] = value;
3296
+ }
3297
+ }
3298
+ else if (isRef(ref)) {
3299
+ ref.value = value;
3300
+ if (rawRef.k)
3301
+ refs[rawRef.k] = value;
3302
+ }
3303
+ else if ((process.env.NODE_ENV !== 'production')) {
3304
+ warn('Invalid template ref type:', ref, `(${typeof ref})`);
3305
+ }
3306
+ };
3307
+ if (value) {
3308
+ doSet.id = -1;
3309
+ queuePostRenderEffect(doSet, parentSuspense);
3310
+ }
3311
+ else {
3312
+ doSet();
3313
+ }
3314
+ }
3315
+ else if ((process.env.NODE_ENV !== 'production')) {
3316
+ warn('Invalid template ref type:', ref, `(${typeof ref})`);
3317
+ }
3318
+ }
3319
+ }
3320
+
3219
3321
  let hasMismatch = false;
3220
3322
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
3221
3323
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -3604,7 +3706,7 @@ function initFeatureFlags() {
3604
3706
  `which expects these compile-time feature flags to be globally injected ` +
3605
3707
  `via the bundler config in order to get better tree-shaking in the ` +
3606
3708
  `production bundle.\n\n` +
3607
- `For more details, see http://link.vuejs.org/feature-flags.`);
3709
+ `For more details, see https://link.vuejs.org/feature-flags.`);
3608
3710
  }
3609
3711
  }
3610
3712
 
@@ -3894,12 +3996,15 @@ function baseCreateRenderer(options, createHydrationFns) {
3894
3996
  const oldProps = n1.props || EMPTY_OBJ;
3895
3997
  const newProps = n2.props || EMPTY_OBJ;
3896
3998
  let vnodeHook;
3999
+ // disable recurse in beforeUpdate hooks
4000
+ parentComponent && toggleRecurse(parentComponent, false);
3897
4001
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
3898
4002
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
3899
4003
  }
3900
4004
  if (dirs) {
3901
4005
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
3902
4006
  }
4007
+ parentComponent && toggleRecurse(parentComponent, true);
3903
4008
  if ((process.env.NODE_ENV !== 'production') && isHmrUpdating) {
3904
4009
  // HMR updated, force full diff
3905
4010
  patchFlag = 0;
@@ -4179,7 +4284,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4179
4284
  const { el, props } = initialVNode;
4180
4285
  const { bm, m, parent } = instance;
4181
4286
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
4182
- effect.allowRecurse = false;
4287
+ toggleRecurse(instance, false);
4183
4288
  // beforeMount hook
4184
4289
  if (bm) {
4185
4290
  invokeArrayFns(bm);
@@ -4189,7 +4294,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4189
4294
  (vnodeHook = props && props.onVnodeBeforeMount)) {
4190
4295
  invokeVNodeHook(vnodeHook, parent, initialVNode);
4191
4296
  }
4192
- effect.allowRecurse = true;
4297
+ toggleRecurse(instance, true);
4193
4298
  if (el && hydrateNode) {
4194
4299
  // vnode has adopted host node - perform hydration instead of mount.
4195
4300
  const hydrateSubTree = () => {
@@ -4271,7 +4376,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4271
4376
  pushWarningContext(next || instance.vnode);
4272
4377
  }
4273
4378
  // Disallow component effect recursion during pre-lifecycle hooks.
4274
- effect.allowRecurse = false;
4379
+ toggleRecurse(instance, false);
4275
4380
  if (next) {
4276
4381
  next.el = vnode.el;
4277
4382
  updateComponentPreRender(instance, next, optimized);
@@ -4287,7 +4392,7 @@ function baseCreateRenderer(options, createHydrationFns) {
4287
4392
  if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
4288
4393
  invokeVNodeHook(vnodeHook, parent, next, vnode);
4289
4394
  }
4290
- effect.allowRecurse = true;
4395
+ toggleRecurse(instance, true);
4291
4396
  // render
4292
4397
  if ((process.env.NODE_ENV !== 'production')) {
4293
4398
  startMeasure(instance, `render`);
@@ -4333,13 +4438,13 @@ function baseCreateRenderer(options, createHydrationFns) {
4333
4438
  }
4334
4439
  };
4335
4440
  // create reactive effect for rendering
4336
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
4337
- );
4441
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
4442
+ ));
4338
4443
  const update = (instance.update = effect.run.bind(effect));
4339
4444
  update.id = instance.uid;
4340
4445
  // allowRecurse
4341
4446
  // #1801, #2043 component render effects should allow recursive updates
4342
- effect.allowRecurse = update.allowRecurse = true;
4447
+ toggleRecurse(instance, true);
4343
4448
  if ((process.env.NODE_ENV !== 'production')) {
4344
4449
  effect.onTrack = instance.rtc
4345
4450
  ? e => invokeArrayFns(instance.rtc, e)
@@ -4863,85 +4968,8 @@ function baseCreateRenderer(options, createHydrationFns) {
4863
4968
  createApp: createAppAPI(render, hydrate)
4864
4969
  };
4865
4970
  }
4866
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
4867
- if (isArray(rawRef)) {
4868
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
4869
- return;
4870
- }
4871
- if (isAsyncWrapper(vnode) && !isUnmount) {
4872
- // when mounting async components, nothing needs to be done,
4873
- // because the template ref is forwarded to inner component
4874
- return;
4875
- }
4876
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4877
- ? getExposeProxy(vnode.component) || vnode.component.proxy
4878
- : vnode.el;
4879
- const value = isUnmount ? null : refValue;
4880
- const { i: owner, r: ref } = rawRef;
4881
- if ((process.env.NODE_ENV !== 'production') && !owner) {
4882
- warn(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
4883
- `A vnode with ref must be created inside the render function.`);
4884
- return;
4885
- }
4886
- const oldRef = oldRawRef && oldRawRef.r;
4887
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
4888
- const setupState = owner.setupState;
4889
- // dynamic ref changed. unset old ref
4890
- if (oldRef != null && oldRef !== ref) {
4891
- if (isString(oldRef)) {
4892
- refs[oldRef] = null;
4893
- if (hasOwn(setupState, oldRef)) {
4894
- setupState[oldRef] = null;
4895
- }
4896
- }
4897
- else if (isRef(oldRef)) {
4898
- oldRef.value = null;
4899
- }
4900
- }
4901
- if (isString(ref)) {
4902
- const doSet = () => {
4903
- {
4904
- refs[ref] = value;
4905
- }
4906
- if (hasOwn(setupState, ref)) {
4907
- setupState[ref] = value;
4908
- }
4909
- };
4910
- // #1789: for non-null values, set them after render
4911
- // null values means this is unmount and it should not overwrite another
4912
- // ref with the same key
4913
- if (value) {
4914
- doSet.id = -1;
4915
- queuePostRenderEffect(doSet, parentSuspense);
4916
- }
4917
- else {
4918
- doSet();
4919
- }
4920
- }
4921
- else if (isRef(ref)) {
4922
- const doSet = () => {
4923
- ref.value = value;
4924
- };
4925
- if (value) {
4926
- doSet.id = -1;
4927
- queuePostRenderEffect(doSet, parentSuspense);
4928
- }
4929
- else {
4930
- doSet();
4931
- }
4932
- }
4933
- else if (isFunction(ref)) {
4934
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4935
- }
4936
- else if ((process.env.NODE_ENV !== 'production')) {
4937
- warn('Invalid template ref type:', value, `(${typeof value})`);
4938
- }
4939
- }
4940
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
4941
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
4942
- vnode,
4943
- prevVNode
4944
- ]);
4971
+ function toggleRecurse({ effect, update }, allowed) {
4972
+ effect.allowRecurse = update.allowRecurse = allowed;
4945
4973
  }
4946
4974
  /**
4947
4975
  * #1156
@@ -4951,8 +4979,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
4951
4979
  *
4952
4980
  * #2080
4953
4981
  * Inside keyed `template` fragment static children, if a fragment is moved,
4954
- * the children will always moved so that need inherit el form previous nodes
4955
- * to ensure correct moved position.
4982
+ * the children will always be moved. Therefore, in order to ensure correct move
4983
+ * position, el should be inherited from previous nodes.
4956
4984
  */
4957
4985
  function traverseStaticChildren(n1, n2, shallow = false) {
4958
4986
  const ch1 = n1.children;
@@ -5405,10 +5433,10 @@ const createVNodeWithArgsTransform = (...args) => {
5405
5433
  };
5406
5434
  const InternalObjectKey = `__vInternal`;
5407
5435
  const normalizeKey = ({ key }) => key != null ? key : null;
5408
- const normalizeRef = ({ ref }) => {
5436
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
5409
5437
  return (ref != null
5410
5438
  ? isString(ref) || isRef(ref) || isFunction(ref)
5411
- ? { i: currentRenderingInstance, r: ref }
5439
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
5412
5440
  : ref
5413
5441
  : null);
5414
5442
  };
@@ -5737,7 +5765,8 @@ function mergeProps(...args) {
5737
5765
  else if (isOn(key)) {
5738
5766
  const existing = ret[key];
5739
5767
  const incoming = toMerge[key];
5740
- if (existing !== incoming) {
5768
+ if (existing !== incoming &&
5769
+ !(isArray(existing) && existing.includes(incoming))) {
5741
5770
  ret[key] = existing
5742
5771
  ? [].concat(existing, incoming)
5743
5772
  : incoming;
@@ -5749,6 +5778,12 @@ function mergeProps(...args) {
5749
5778
  }
5750
5779
  }
5751
5780
  return ret;
5781
+ }
5782
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
5783
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
5784
+ vnode,
5785
+ prevVNode
5786
+ ]);
5752
5787
  }
5753
5788
 
5754
5789
  /**
@@ -5941,23 +5976,23 @@ const PublicInstanceProxyHandlers = {
5941
5976
  const n = accessCache[key];
5942
5977
  if (n !== undefined) {
5943
5978
  switch (n) {
5944
- case 0 /* SETUP */:
5979
+ case 1 /* SETUP */:
5945
5980
  return setupState[key];
5946
- case 1 /* DATA */:
5981
+ case 2 /* DATA */:
5947
5982
  return data[key];
5948
- case 3 /* CONTEXT */:
5983
+ case 4 /* CONTEXT */:
5949
5984
  return ctx[key];
5950
- case 2 /* PROPS */:
5985
+ case 3 /* PROPS */:
5951
5986
  return props[key];
5952
5987
  // default: just fallthrough
5953
5988
  }
5954
5989
  }
5955
5990
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5956
- accessCache[key] = 0 /* SETUP */;
5991
+ accessCache[key] = 1 /* SETUP */;
5957
5992
  return setupState[key];
5958
5993
  }
5959
5994
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5960
- accessCache[key] = 1 /* DATA */;
5995
+ accessCache[key] = 2 /* DATA */;
5961
5996
  return data[key];
5962
5997
  }
5963
5998
  else if (
@@ -5965,15 +6000,15 @@ const PublicInstanceProxyHandlers = {
5965
6000
  // props
5966
6001
  (normalizedProps = instance.propsOptions[0]) &&
5967
6002
  hasOwn(normalizedProps, key)) {
5968
- accessCache[key] = 2 /* PROPS */;
6003
+ accessCache[key] = 3 /* PROPS */;
5969
6004
  return props[key];
5970
6005
  }
5971
6006
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
5972
- accessCache[key] = 3 /* CONTEXT */;
6007
+ accessCache[key] = 4 /* CONTEXT */;
5973
6008
  return ctx[key];
5974
6009
  }
5975
6010
  else if (!__VUE_OPTIONS_API__ || shouldCacheAccess) {
5976
- accessCache[key] = 4 /* OTHER */;
6011
+ accessCache[key] = 0 /* OTHER */;
5977
6012
  }
5978
6013
  }
5979
6014
  const publicGetter = publicPropertiesMap[key];
@@ -5994,7 +6029,7 @@ const PublicInstanceProxyHandlers = {
5994
6029
  }
5995
6030
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
5996
6031
  // user may set custom properties to `this` that start with `$`
5997
- accessCache[key] = 3 /* CONTEXT */;
6032
+ accessCache[key] = 4 /* CONTEXT */;
5998
6033
  return ctx[key];
5999
6034
  }
6000
6035
  else if (
@@ -6058,7 +6093,7 @@ const PublicInstanceProxyHandlers = {
6058
6093
  },
6059
6094
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
6060
6095
  let normalizedProps;
6061
- return (accessCache[key] !== undefined ||
6096
+ return (!!accessCache[key] ||
6062
6097
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
6063
6098
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
6064
6099
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -6164,6 +6199,7 @@ function createComponentInstance(vnode, parent, suspense) {
6164
6199
  root: null,
6165
6200
  next: null,
6166
6201
  subTree: null,
6202
+ effect: null,
6167
6203
  update: null,
6168
6204
  scope: new EffectScope(true /* detached */),
6169
6205
  render: null,
@@ -7655,7 +7691,7 @@ function isMemoSame(cached, memo) {
7655
7691
  }
7656
7692
 
7657
7693
  // Core API ------------------------------------------------------------------
7658
- const version = "3.2.21";
7694
+ const version = "3.2.25";
7659
7695
  const _ssrUtils = {
7660
7696
  createComponentInstance,
7661
7697
  setupComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.2.21",
3
+ "version": "3.2.25",
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/vue-next/tree/master/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.21",
36
- "@vue/reactivity": "3.2.21"
35
+ "@vue/shared": "3.2.25",
36
+ "@vue/reactivity": "3.2.25"
37
37
  }
38
38
  }