@vue/compat 3.2.24 → 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.
@@ -37,7 +37,7 @@ var Vue = (function () {
37
37
  const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
38
38
  /**
39
39
  * Boolean attributes should be included if the value is truthy or ''.
40
- * e.g. <select multiple> compiles to { multiple: '' }
40
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
41
41
  */
42
42
  function includeBooleanAttr(value) {
43
43
  return !!value || value === '';
@@ -269,7 +269,7 @@ var Vue = (function () {
269
269
  '' + parseInt(key, 10) === key;
270
270
  const isReservedProp = /*#__PURE__*/ makeMap(
271
271
  // the leading comma is intentional so empty string "" is also included
272
- ',key,ref,' +
272
+ ',key,ref,ref_for,ref_key,' +
273
273
  'onVnodeBeforeMount,onVnodeMounted,' +
274
274
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
275
275
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -1364,21 +1364,25 @@ var Vue = (function () {
1364
1364
  return ret;
1365
1365
  }
1366
1366
  class ObjectRefImpl {
1367
- constructor(_object, _key) {
1367
+ constructor(_object, _key, _defaultValue) {
1368
1368
  this._object = _object;
1369
1369
  this._key = _key;
1370
+ this._defaultValue = _defaultValue;
1370
1371
  this.__v_isRef = true;
1371
1372
  }
1372
1373
  get value() {
1373
- return this._object[this._key];
1374
+ const val = this._object[this._key];
1375
+ return val === undefined ? this._defaultValue : val;
1374
1376
  }
1375
1377
  set value(newVal) {
1376
1378
  this._object[this._key] = newVal;
1377
1379
  }
1378
1380
  }
1379
- function toRef(object, key) {
1381
+ function toRef(object, key, defaultValue) {
1380
1382
  const val = object[key];
1381
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1383
+ return isRef(val)
1384
+ ? val
1385
+ : new ObjectRefImpl(object, key, defaultValue);
1382
1386
  }
1383
1387
 
1384
1388
  class ComputedRefImpl {
@@ -1824,11 +1828,6 @@ var Vue = (function () {
1824
1828
  `Use "${newHook}" instead.`,
1825
1829
  link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
1826
1830
  },
1827
- ["V_FOR_REF" /* V_FOR_REF */]: {
1828
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
1829
- `Consider using function refs or refactor to avoid ref usage altogether.`,
1830
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
1831
- },
1832
1831
  ["V_ON_KEYCODE_MODIFIER" /* V_ON_KEYCODE_MODIFIER */]: {
1833
1832
  message: `Using keyCode as v-on modifier is no longer supported. ` +
1834
1833
  `Use kebab-case key name modifiers instead.`,
@@ -5241,7 +5240,7 @@ var Vue = (function () {
5241
5240
  return vm;
5242
5241
  }
5243
5242
  }
5244
- Vue.version = "3.2.24";
5243
+ Vue.version = "3.2.25";
5245
5244
  Vue.config = singletonApp.config;
5246
5245
  Vue.use = (p, ...options) => {
5247
5246
  if (p && isFunction(p.install)) {
@@ -5592,7 +5591,7 @@ var Vue = (function () {
5592
5591
  ];
5593
5592
  const patched = new WeakSet();
5594
5593
  function defineReactive(obj, key, val) {
5595
- // it's possible for the orignial object to be mutated after being defined
5594
+ // it's possible for the original object to be mutated after being defined
5596
5595
  // and expecting reactivity... we are covering it here because this seems to
5597
5596
  // be a bit more common.
5598
5597
  if (isObject(val) && !isReactive(val) && !patched.has(val)) {
@@ -5812,6 +5811,102 @@ var Vue = (function () {
5812
5811
  };
5813
5812
  }
5814
5813
 
5814
+ /**
5815
+ * Function for handling a template ref
5816
+ */
5817
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5818
+ if (isArray(rawRef)) {
5819
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
5820
+ return;
5821
+ }
5822
+ if (isAsyncWrapper(vnode) && !isUnmount) {
5823
+ // when mounting async components, nothing needs to be done,
5824
+ // because the template ref is forwarded to inner component
5825
+ return;
5826
+ }
5827
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
5828
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
5829
+ : vnode.el;
5830
+ const value = isUnmount ? null : refValue;
5831
+ const { i: owner, r: ref } = rawRef;
5832
+ if (!owner) {
5833
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
5834
+ `A vnode with ref must be created inside the render function.`);
5835
+ return;
5836
+ }
5837
+ const oldRef = oldRawRef && oldRawRef.r;
5838
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
5839
+ const setupState = owner.setupState;
5840
+ // dynamic ref changed. unset old ref
5841
+ if (oldRef != null && oldRef !== ref) {
5842
+ if (isString(oldRef)) {
5843
+ refs[oldRef] = null;
5844
+ if (hasOwn(setupState, oldRef)) {
5845
+ setupState[oldRef] = null;
5846
+ }
5847
+ }
5848
+ else if (isRef(oldRef)) {
5849
+ oldRef.value = null;
5850
+ }
5851
+ }
5852
+ if (isFunction(ref)) {
5853
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
5854
+ }
5855
+ else {
5856
+ const _isString = isString(ref);
5857
+ const _isRef = isRef(ref);
5858
+ if (_isString || _isRef) {
5859
+ const doSet = () => {
5860
+ if (rawRef.f) {
5861
+ const existing = _isString ? refs[ref] : ref.value;
5862
+ if (isUnmount) {
5863
+ isArray(existing) && remove(existing, refValue);
5864
+ }
5865
+ else {
5866
+ if (!isArray(existing)) {
5867
+ if (_isString) {
5868
+ refs[ref] = [refValue];
5869
+ }
5870
+ else {
5871
+ ref.value = [refValue];
5872
+ if (rawRef.k)
5873
+ refs[rawRef.k] = ref.value;
5874
+ }
5875
+ }
5876
+ else if (!existing.includes(refValue)) {
5877
+ existing.push(refValue);
5878
+ }
5879
+ }
5880
+ }
5881
+ else if (_isString) {
5882
+ refs[ref] = value;
5883
+ if (hasOwn(setupState, ref)) {
5884
+ setupState[ref] = value;
5885
+ }
5886
+ }
5887
+ else if (isRef(ref)) {
5888
+ ref.value = value;
5889
+ if (rawRef.k)
5890
+ refs[rawRef.k] = value;
5891
+ }
5892
+ else {
5893
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5894
+ }
5895
+ };
5896
+ if (value) {
5897
+ doSet.id = -1;
5898
+ queuePostRenderEffect(doSet, parentSuspense);
5899
+ }
5900
+ else {
5901
+ doSet();
5902
+ }
5903
+ }
5904
+ else {
5905
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5906
+ }
5907
+ }
5908
+ }
5909
+
5815
5910
  let hasMismatch = false;
5816
5911
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
5817
5912
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -6173,44 +6268,6 @@ var Vue = (function () {
6173
6268
  return supported;
6174
6269
  }
6175
6270
 
6176
- function convertLegacyRefInFor(vnode) {
6177
- // refInFor
6178
- if (vnode.props && vnode.props.refInFor) {
6179
- delete vnode.props.refInFor;
6180
- if (vnode.ref) {
6181
- if (isArray(vnode.ref)) {
6182
- vnode.ref.forEach(r => (r.f = true));
6183
- }
6184
- else {
6185
- vnode.ref.f = true;
6186
- }
6187
- }
6188
- }
6189
- }
6190
- function registerLegacyRef(refs, key, value, owner, isInFor, isUnmount) {
6191
- const existing = refs[key];
6192
- if (isUnmount) {
6193
- if (isArray(existing)) {
6194
- remove(existing, value);
6195
- }
6196
- else {
6197
- refs[key] = null;
6198
- }
6199
- }
6200
- else if (isInFor) {
6201
- warnDeprecation("V_FOR_REF" /* V_FOR_REF */, owner);
6202
- if (!isArray(existing)) {
6203
- refs[key] = [value];
6204
- }
6205
- else if (!existing.includes(value)) {
6206
- existing.push(value);
6207
- }
6208
- }
6209
- else {
6210
- refs[key] = value;
6211
- }
6212
- }
6213
-
6214
6271
  const queuePostRenderEffect = queueEffectWithSuspense
6215
6272
  ;
6216
6273
  /**
@@ -6482,12 +6539,15 @@ var Vue = (function () {
6482
6539
  const oldProps = n1.props || EMPTY_OBJ;
6483
6540
  const newProps = n2.props || EMPTY_OBJ;
6484
6541
  let vnodeHook;
6542
+ // disable recurse in beforeUpdate hooks
6543
+ parentComponent && toggleRecurse(parentComponent, false);
6485
6544
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
6486
6545
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6487
6546
  }
6488
6547
  if (dirs) {
6489
6548
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
6490
6549
  }
6550
+ parentComponent && toggleRecurse(parentComponent, true);
6491
6551
  if (isHmrUpdating) {
6492
6552
  // HMR updated, force full diff
6493
6553
  patchFlag = 0;
@@ -6771,7 +6831,7 @@ var Vue = (function () {
6771
6831
  const { el, props } = initialVNode;
6772
6832
  const { bm, m, parent } = instance;
6773
6833
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6774
- effect.allowRecurse = false;
6834
+ toggleRecurse(instance, false);
6775
6835
  // beforeMount hook
6776
6836
  if (bm) {
6777
6837
  invokeArrayFns(bm);
@@ -6784,7 +6844,7 @@ var Vue = (function () {
6784
6844
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6785
6845
  instance.emit('hook:beforeMount');
6786
6846
  }
6787
- effect.allowRecurse = true;
6847
+ toggleRecurse(instance, true);
6788
6848
  if (el && hydrateNode) {
6789
6849
  // vnode has adopted host node - perform hydration instead of mount.
6790
6850
  const hydrateSubTree = () => {
@@ -6872,7 +6932,7 @@ var Vue = (function () {
6872
6932
  pushWarningContext(next || instance.vnode);
6873
6933
  }
6874
6934
  // Disallow component effect recursion during pre-lifecycle hooks.
6875
- effect.allowRecurse = false;
6935
+ toggleRecurse(instance, false);
6876
6936
  if (next) {
6877
6937
  next.el = vnode.el;
6878
6938
  updateComponentPreRender(instance, next, optimized);
@@ -6891,7 +6951,7 @@ var Vue = (function () {
6891
6951
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6892
6952
  instance.emit('hook:beforeUpdate');
6893
6953
  }
6894
- effect.allowRecurse = true;
6954
+ toggleRecurse(instance, true);
6895
6955
  // render
6896
6956
  {
6897
6957
  startMeasure(instance, `render`);
@@ -6940,13 +7000,13 @@ var Vue = (function () {
6940
7000
  }
6941
7001
  };
6942
7002
  // create reactive effect for rendering
6943
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
6944
- );
7003
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7004
+ ));
6945
7005
  const update = (instance.update = effect.run.bind(effect));
6946
7006
  update.id = instance.uid;
6947
7007
  // allowRecurse
6948
7008
  // #1801, #2043 component render effects should allow recursive updates
6949
- effect.allowRecurse = update.allowRecurse = true;
7009
+ toggleRecurse(instance, true);
6950
7010
  {
6951
7011
  effect.onTrack = instance.rtc
6952
7012
  ? e => invokeArrayFns(instance.rtc, e)
@@ -7476,88 +7536,8 @@ var Vue = (function () {
7476
7536
  createApp: createAppAPI(render, hydrate)
7477
7537
  };
7478
7538
  }
7479
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7480
- if (isArray(rawRef)) {
7481
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
7482
- return;
7483
- }
7484
- if (isAsyncWrapper(vnode) && !isUnmount) {
7485
- // when mounting async components, nothing needs to be done,
7486
- // because the template ref is forwarded to inner component
7487
- return;
7488
- }
7489
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
7490
- ? getExposeProxy(vnode.component) || vnode.component.proxy
7491
- : vnode.el;
7492
- const value = isUnmount ? null : refValue;
7493
- const { i: owner, r: ref } = rawRef;
7494
- if (!owner) {
7495
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
7496
- `A vnode with ref must be created inside the render function.`);
7497
- return;
7498
- }
7499
- const oldRef = oldRawRef && oldRawRef.r;
7500
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
7501
- const setupState = owner.setupState;
7502
- // dynamic ref changed. unset old ref
7503
- if (oldRef != null && oldRef !== ref) {
7504
- if (isString(oldRef)) {
7505
- refs[oldRef] = null;
7506
- if (hasOwn(setupState, oldRef)) {
7507
- setupState[oldRef] = null;
7508
- }
7509
- }
7510
- else if (isRef(oldRef)) {
7511
- oldRef.value = null;
7512
- }
7513
- }
7514
- if (isString(ref)) {
7515
- const doSet = () => {
7516
- if (isCompatEnabled("V_FOR_REF" /* V_FOR_REF */, owner)) {
7517
- registerLegacyRef(refs, ref, refValue, owner, rawRef.f, isUnmount);
7518
- }
7519
- else {
7520
- refs[ref] = value;
7521
- }
7522
- if (hasOwn(setupState, ref)) {
7523
- setupState[ref] = value;
7524
- }
7525
- };
7526
- // #1789: for non-null values, set them after render
7527
- // null values means this is unmount and it should not overwrite another
7528
- // ref with the same key
7529
- if (value) {
7530
- doSet.id = -1;
7531
- queuePostRenderEffect(doSet, parentSuspense);
7532
- }
7533
- else {
7534
- doSet();
7535
- }
7536
- }
7537
- else if (isRef(ref)) {
7538
- const doSet = () => {
7539
- ref.value = value;
7540
- };
7541
- if (value) {
7542
- doSet.id = -1;
7543
- queuePostRenderEffect(doSet, parentSuspense);
7544
- }
7545
- else {
7546
- doSet();
7547
- }
7548
- }
7549
- else if (isFunction(ref)) {
7550
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
7551
- }
7552
- else {
7553
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
7554
- }
7555
- }
7556
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7557
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7558
- vnode,
7559
- prevVNode
7560
- ]);
7539
+ function toggleRecurse({ effect, update }, allowed) {
7540
+ effect.allowRecurse = update.allowRecurse = allowed;
7561
7541
  }
7562
7542
  /**
7563
7543
  * #1156
@@ -8352,10 +8332,10 @@ var Vue = (function () {
8352
8332
  };
8353
8333
  const InternalObjectKey = `__vInternal`;
8354
8334
  const normalizeKey = ({ key }) => key != null ? key : null;
8355
- const normalizeRef = ({ ref }) => {
8335
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
8356
8336
  return (ref != null
8357
8337
  ? isString(ref) || isRef(ref) || isFunction(ref)
8358
- ? { i: currentRenderingInstance, r: ref }
8338
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
8359
8339
  : ref
8360
8340
  : null);
8361
8341
  };
@@ -8423,7 +8403,6 @@ var Vue = (function () {
8423
8403
  }
8424
8404
  {
8425
8405
  convertLegacyVModelProps(vnode);
8426
- convertLegacyRefInFor(vnode);
8427
8406
  defineLegacyVNodeProperties(vnode);
8428
8407
  }
8429
8408
  return vnode;
@@ -8709,6 +8688,12 @@ var Vue = (function () {
8709
8688
  }
8710
8689
  }
8711
8690
  return ret;
8691
+ }
8692
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8693
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8694
+ vnode,
8695
+ prevVNode
8696
+ ]);
8712
8697
  }
8713
8698
 
8714
8699
  function getCompatChildren(instance) {
@@ -9368,6 +9353,7 @@ var Vue = (function () {
9368
9353
  root: null,
9369
9354
  next: null,
9370
9355
  subTree: null,
9356
+ effect: null,
9371
9357
  update: null,
9372
9358
  scope: new EffectScope(true /* detached */),
9373
9359
  render: null,
@@ -10832,7 +10818,7 @@ var Vue = (function () {
10832
10818
  }
10833
10819
 
10834
10820
  // Core API ------------------------------------------------------------------
10835
- const version = "3.2.24";
10821
+ const version = "3.2.25";
10836
10822
  /**
10837
10823
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10838
10824
  * @internal