@vue/compat 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.
@@ -107,7 +107,7 @@ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomo
107
107
  const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
108
108
  /**
109
109
  * Boolean attributes should be included if the value is truthy or ''.
110
- * e.g. <select multiple> compiles to { multiple: '' }
110
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
111
111
  */
112
112
  function includeBooleanAttr(value) {
113
113
  return !!value || value === '';
@@ -341,7 +341,7 @@ const isIntegerKey = (key) => isString(key) &&
341
341
  '' + parseInt(key, 10) === key;
342
342
  const isReservedProp = /*#__PURE__*/ makeMap(
343
343
  // the leading comma is intentional so empty string "" is also included
344
- ',key,ref,' +
344
+ ',key,ref,ref_for,ref_key,' +
345
345
  'onVnodeBeforeMount,onVnodeMounted,' +
346
346
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
347
347
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -530,7 +530,7 @@ const targetMap = new WeakMap();
530
530
  let effectTrackDepth = 0;
531
531
  let trackOpBit = 1;
532
532
  /**
533
- * The bitwise track markers support at most 30 levels op recursion.
533
+ * The bitwise track markers support at most 30 levels of recursion.
534
534
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
535
535
  * When recursion depth is greater, fall back to using a full cleanup.
536
536
  */
@@ -851,7 +851,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
851
851
  function createSetter(shallow = false) {
852
852
  return function set(target, key, value, receiver) {
853
853
  let oldValue = target[key];
854
- if (!shallow) {
854
+ if (!shallow && !isReadonly(value)) {
855
855
  value = toRaw(value);
856
856
  oldValue = toRaw(oldValue);
857
857
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1436,21 +1436,25 @@ function toRefs(object) {
1436
1436
  return ret;
1437
1437
  }
1438
1438
  class ObjectRefImpl {
1439
- constructor(_object, _key) {
1439
+ constructor(_object, _key, _defaultValue) {
1440
1440
  this._object = _object;
1441
1441
  this._key = _key;
1442
+ this._defaultValue = _defaultValue;
1442
1443
  this.__v_isRef = true;
1443
1444
  }
1444
1445
  get value() {
1445
- return this._object[this._key];
1446
+ const val = this._object[this._key];
1447
+ return val === undefined ? this._defaultValue : val;
1446
1448
  }
1447
1449
  set value(newVal) {
1448
1450
  this._object[this._key] = newVal;
1449
1451
  }
1450
1452
  }
1451
- function toRef(object, key) {
1453
+ function toRef(object, key, defaultValue) {
1452
1454
  const val = object[key];
1453
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1455
+ return isRef(val)
1456
+ ? val
1457
+ : new ObjectRefImpl(object, key, defaultValue);
1454
1458
  }
1455
1459
 
1456
1460
  class ComputedRefImpl {
@@ -1657,6 +1661,7 @@ function emit(event, ...args) {
1657
1661
  }
1658
1662
  }
1659
1663
  function setDevtoolsHook(hook, target) {
1664
+ var _a, _b;
1660
1665
  devtools = hook;
1661
1666
  if (devtools) {
1662
1667
  devtools.enabled = true;
@@ -1669,7 +1674,10 @@ function setDevtoolsHook(hook, target) {
1669
1674
  // (#4815)
1670
1675
  // eslint-disable-next-line no-restricted-globals
1671
1676
  typeof window !== 'undefined' &&
1672
- !navigator.userAgent.includes('jsdom')) {
1677
+ // some envs mock window but not fully
1678
+ window.HTMLElement &&
1679
+ // also exclude jsdom
1680
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1673
1681
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1674
1682
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1675
1683
  replay.push((newHook) => {
@@ -1892,11 +1900,6 @@ const deprecationData = {
1892
1900
  `Use "${newHook}" instead.`,
1893
1901
  link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
1894
1902
  },
1895
- ["V_FOR_REF" /* V_FOR_REF */]: {
1896
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
1897
- `Consider using function refs or refactor to avoid ref usage altogether.`,
1898
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
1899
- },
1900
1903
  ["V_ON_KEYCODE_MODIFIER" /* V_ON_KEYCODE_MODIFIER */]: {
1901
1904
  message: `Using keyCode as v-on modifier is no longer supported. ` +
1902
1905
  `Use kebab-case key name modifiers instead.`,
@@ -3303,7 +3306,8 @@ const BaseTransitionImpl = {
3303
3306
  const rawProps = toRaw(props);
3304
3307
  const { mode } = rawProps;
3305
3308
  // check mode
3306
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3309
+ if (mode &&
3310
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3307
3311
  warn$1(`invalid <transition> mode: ${mode}`);
3308
3312
  }
3309
3313
  // at this point children has a guaranteed length of 1.
@@ -3949,7 +3953,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3949
3953
  }
3950
3954
  current = current.parent;
3951
3955
  }
3952
- hook();
3956
+ return hook();
3953
3957
  });
3954
3958
  injectHook(type, wrappedHook, target);
3955
3959
  // In addition to registering it on the target instance, we walk up the parent
@@ -4727,7 +4731,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4727
4731
  continue;
4728
4732
  }
4729
4733
  }
4730
- if (value !== attrs[key]) {
4734
+ if (!(key in attrs) || value !== attrs[key]) {
4731
4735
  attrs[key] = value;
4732
4736
  hasAttrsChanged = true;
4733
4737
  }
@@ -5308,7 +5312,7 @@ function createCompatVue(createApp, createSingletonApp) {
5308
5312
  return vm;
5309
5313
  }
5310
5314
  }
5311
- Vue.version = "3.2.21";
5315
+ Vue.version = "3.2.25";
5312
5316
  Vue.config = singletonApp.config;
5313
5317
  Vue.use = (p, ...options) => {
5314
5318
  if (p && isFunction(p.install)) {
@@ -5659,7 +5663,7 @@ const methodsToPatch = [
5659
5663
  ];
5660
5664
  const patched = new WeakSet();
5661
5665
  function defineReactive(obj, key, val) {
5662
- // it's possible for the orignial object to be mutated after being defined
5666
+ // it's possible for the original object to be mutated after being defined
5663
5667
  // and expecting reactivity... we are covering it here because this seems to
5664
5668
  // be a bit more common.
5665
5669
  if (isObject(val) && !isReactive(val) && !patched.has(val)) {
@@ -5879,6 +5883,102 @@ function createAppAPI(render, hydrate) {
5879
5883
  };
5880
5884
  }
5881
5885
 
5886
+ /**
5887
+ * Function for handling a template ref
5888
+ */
5889
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5890
+ if (isArray(rawRef)) {
5891
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
5892
+ return;
5893
+ }
5894
+ if (isAsyncWrapper(vnode) && !isUnmount) {
5895
+ // when mounting async components, nothing needs to be done,
5896
+ // because the template ref is forwarded to inner component
5897
+ return;
5898
+ }
5899
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
5900
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
5901
+ : vnode.el;
5902
+ const value = isUnmount ? null : refValue;
5903
+ const { i: owner, r: ref } = rawRef;
5904
+ if (!owner) {
5905
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
5906
+ `A vnode with ref must be created inside the render function.`);
5907
+ return;
5908
+ }
5909
+ const oldRef = oldRawRef && oldRawRef.r;
5910
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
5911
+ const setupState = owner.setupState;
5912
+ // dynamic ref changed. unset old ref
5913
+ if (oldRef != null && oldRef !== ref) {
5914
+ if (isString(oldRef)) {
5915
+ refs[oldRef] = null;
5916
+ if (hasOwn(setupState, oldRef)) {
5917
+ setupState[oldRef] = null;
5918
+ }
5919
+ }
5920
+ else if (isRef(oldRef)) {
5921
+ oldRef.value = null;
5922
+ }
5923
+ }
5924
+ if (isFunction(ref)) {
5925
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
5926
+ }
5927
+ else {
5928
+ const _isString = isString(ref);
5929
+ const _isRef = isRef(ref);
5930
+ if (_isString || _isRef) {
5931
+ const doSet = () => {
5932
+ if (rawRef.f) {
5933
+ const existing = _isString ? refs[ref] : ref.value;
5934
+ if (isUnmount) {
5935
+ isArray(existing) && remove(existing, refValue);
5936
+ }
5937
+ else {
5938
+ if (!isArray(existing)) {
5939
+ if (_isString) {
5940
+ refs[ref] = [refValue];
5941
+ }
5942
+ else {
5943
+ ref.value = [refValue];
5944
+ if (rawRef.k)
5945
+ refs[rawRef.k] = ref.value;
5946
+ }
5947
+ }
5948
+ else if (!existing.includes(refValue)) {
5949
+ existing.push(refValue);
5950
+ }
5951
+ }
5952
+ }
5953
+ else if (_isString) {
5954
+ refs[ref] = value;
5955
+ if (hasOwn(setupState, ref)) {
5956
+ setupState[ref] = value;
5957
+ }
5958
+ }
5959
+ else if (isRef(ref)) {
5960
+ ref.value = value;
5961
+ if (rawRef.k)
5962
+ refs[rawRef.k] = value;
5963
+ }
5964
+ else {
5965
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5966
+ }
5967
+ };
5968
+ if (value) {
5969
+ doSet.id = -1;
5970
+ queuePostRenderEffect(doSet, parentSuspense);
5971
+ }
5972
+ else {
5973
+ doSet();
5974
+ }
5975
+ }
5976
+ else {
5977
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5978
+ }
5979
+ }
5980
+ }
5981
+
5882
5982
  let hasMismatch = false;
5883
5983
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
5884
5984
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -6240,44 +6340,6 @@ function isSupported() {
6240
6340
  return supported;
6241
6341
  }
6242
6342
 
6243
- function convertLegacyRefInFor(vnode) {
6244
- // refInFor
6245
- if (vnode.props && vnode.props.refInFor) {
6246
- delete vnode.props.refInFor;
6247
- if (vnode.ref) {
6248
- if (isArray(vnode.ref)) {
6249
- vnode.ref.forEach(r => (r.f = true));
6250
- }
6251
- else {
6252
- vnode.ref.f = true;
6253
- }
6254
- }
6255
- }
6256
- }
6257
- function registerLegacyRef(refs, key, value, owner, isInFor, isUnmount) {
6258
- const existing = refs[key];
6259
- if (isUnmount) {
6260
- if (isArray(existing)) {
6261
- remove(existing, value);
6262
- }
6263
- else {
6264
- refs[key] = null;
6265
- }
6266
- }
6267
- else if (isInFor) {
6268
- warnDeprecation("V_FOR_REF" /* V_FOR_REF */, owner);
6269
- if (!isArray(existing)) {
6270
- refs[key] = [value];
6271
- }
6272
- else if (!existing.includes(value)) {
6273
- existing.push(value);
6274
- }
6275
- }
6276
- else {
6277
- refs[key] = value;
6278
- }
6279
- }
6280
-
6281
6343
  const queuePostRenderEffect = queueEffectWithSuspense
6282
6344
  ;
6283
6345
  /**
@@ -6549,12 +6611,15 @@ function baseCreateRenderer(options, createHydrationFns) {
6549
6611
  const oldProps = n1.props || EMPTY_OBJ;
6550
6612
  const newProps = n2.props || EMPTY_OBJ;
6551
6613
  let vnodeHook;
6614
+ // disable recurse in beforeUpdate hooks
6615
+ parentComponent && toggleRecurse(parentComponent, false);
6552
6616
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
6553
6617
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6554
6618
  }
6555
6619
  if (dirs) {
6556
6620
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
6557
6621
  }
6622
+ parentComponent && toggleRecurse(parentComponent, true);
6558
6623
  if (isHmrUpdating) {
6559
6624
  // HMR updated, force full diff
6560
6625
  patchFlag = 0;
@@ -6838,7 +6903,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6838
6903
  const { el, props } = initialVNode;
6839
6904
  const { bm, m, parent } = instance;
6840
6905
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6841
- effect.allowRecurse = false;
6906
+ toggleRecurse(instance, false);
6842
6907
  // beforeMount hook
6843
6908
  if (bm) {
6844
6909
  invokeArrayFns(bm);
@@ -6851,7 +6916,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6851
6916
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6852
6917
  instance.emit('hook:beforeMount');
6853
6918
  }
6854
- effect.allowRecurse = true;
6919
+ toggleRecurse(instance, true);
6855
6920
  if (el && hydrateNode) {
6856
6921
  // vnode has adopted host node - perform hydration instead of mount.
6857
6922
  const hydrateSubTree = () => {
@@ -6939,7 +7004,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6939
7004
  pushWarningContext(next || instance.vnode);
6940
7005
  }
6941
7006
  // Disallow component effect recursion during pre-lifecycle hooks.
6942
- effect.allowRecurse = false;
7007
+ toggleRecurse(instance, false);
6943
7008
  if (next) {
6944
7009
  next.el = vnode.el;
6945
7010
  updateComponentPreRender(instance, next, optimized);
@@ -6958,7 +7023,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6958
7023
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6959
7024
  instance.emit('hook:beforeUpdate');
6960
7025
  }
6961
- effect.allowRecurse = true;
7026
+ toggleRecurse(instance, true);
6962
7027
  // render
6963
7028
  {
6964
7029
  startMeasure(instance, `render`);
@@ -7007,13 +7072,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7007
7072
  }
7008
7073
  };
7009
7074
  // create reactive effect for rendering
7010
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7011
- );
7075
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7076
+ ));
7012
7077
  const update = (instance.update = effect.run.bind(effect));
7013
7078
  update.id = instance.uid;
7014
7079
  // allowRecurse
7015
7080
  // #1801, #2043 component render effects should allow recursive updates
7016
- effect.allowRecurse = update.allowRecurse = true;
7081
+ toggleRecurse(instance, true);
7017
7082
  {
7018
7083
  effect.onTrack = instance.rtc
7019
7084
  ? e => invokeArrayFns(instance.rtc, e)
@@ -7543,88 +7608,8 @@ function baseCreateRenderer(options, createHydrationFns) {
7543
7608
  createApp: createAppAPI(render, hydrate)
7544
7609
  };
7545
7610
  }
7546
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7547
- if (isArray(rawRef)) {
7548
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
7549
- return;
7550
- }
7551
- if (isAsyncWrapper(vnode) && !isUnmount) {
7552
- // when mounting async components, nothing needs to be done,
7553
- // because the template ref is forwarded to inner component
7554
- return;
7555
- }
7556
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
7557
- ? getExposeProxy(vnode.component) || vnode.component.proxy
7558
- : vnode.el;
7559
- const value = isUnmount ? null : refValue;
7560
- const { i: owner, r: ref } = rawRef;
7561
- if (!owner) {
7562
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
7563
- `A vnode with ref must be created inside the render function.`);
7564
- return;
7565
- }
7566
- const oldRef = oldRawRef && oldRawRef.r;
7567
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
7568
- const setupState = owner.setupState;
7569
- // dynamic ref changed. unset old ref
7570
- if (oldRef != null && oldRef !== ref) {
7571
- if (isString(oldRef)) {
7572
- refs[oldRef] = null;
7573
- if (hasOwn(setupState, oldRef)) {
7574
- setupState[oldRef] = null;
7575
- }
7576
- }
7577
- else if (isRef(oldRef)) {
7578
- oldRef.value = null;
7579
- }
7580
- }
7581
- if (isString(ref)) {
7582
- const doSet = () => {
7583
- if (isCompatEnabled("V_FOR_REF" /* V_FOR_REF */, owner)) {
7584
- registerLegacyRef(refs, ref, refValue, owner, rawRef.f, isUnmount);
7585
- }
7586
- else {
7587
- refs[ref] = value;
7588
- }
7589
- if (hasOwn(setupState, ref)) {
7590
- setupState[ref] = value;
7591
- }
7592
- };
7593
- // #1789: for non-null values, set them after render
7594
- // null values means this is unmount and it should not overwrite another
7595
- // ref with the same key
7596
- if (value) {
7597
- doSet.id = -1;
7598
- queuePostRenderEffect(doSet, parentSuspense);
7599
- }
7600
- else {
7601
- doSet();
7602
- }
7603
- }
7604
- else if (isRef(ref)) {
7605
- const doSet = () => {
7606
- ref.value = value;
7607
- };
7608
- if (value) {
7609
- doSet.id = -1;
7610
- queuePostRenderEffect(doSet, parentSuspense);
7611
- }
7612
- else {
7613
- doSet();
7614
- }
7615
- }
7616
- else if (isFunction(ref)) {
7617
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
7618
- }
7619
- else {
7620
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
7621
- }
7622
- }
7623
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7624
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7625
- vnode,
7626
- prevVNode
7627
- ]);
7611
+ function toggleRecurse({ effect, update }, allowed) {
7612
+ effect.allowRecurse = update.allowRecurse = allowed;
7628
7613
  }
7629
7614
  /**
7630
7615
  * #1156
@@ -7634,8 +7619,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7634
7619
  *
7635
7620
  * #2080
7636
7621
  * Inside keyed `template` fragment static children, if a fragment is moved,
7637
- * the children will always moved so that need inherit el form previous nodes
7638
- * to ensure correct moved position.
7622
+ * the children will always be moved. Therefore, in order to ensure correct move
7623
+ * position, el should be inherited from previous nodes.
7639
7624
  */
7640
7625
  function traverseStaticChildren(n1, n2, shallow = false) {
7641
7626
  const ch1 = n1.children;
@@ -8273,6 +8258,7 @@ function convertLegacyFunctionalComponent(comp) {
8273
8258
  };
8274
8259
  Func.props = comp.props;
8275
8260
  Func.displayName = comp.name;
8261
+ Func.compatConfig = comp.compatConfig;
8276
8262
  // v2 functional components do not inherit attrs
8277
8263
  Func.inheritAttrs = false;
8278
8264
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8418,10 +8404,10 @@ const createVNodeWithArgsTransform = (...args) => {
8418
8404
  };
8419
8405
  const InternalObjectKey = `__vInternal`;
8420
8406
  const normalizeKey = ({ key }) => key != null ? key : null;
8421
- const normalizeRef = ({ ref }) => {
8407
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
8422
8408
  return (ref != null
8423
8409
  ? isString(ref) || isRef(ref) || isFunction(ref)
8424
- ? { i: currentRenderingInstance, r: ref }
8410
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
8425
8411
  : ref
8426
8412
  : null);
8427
8413
  };
@@ -8489,7 +8475,6 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
8489
8475
  }
8490
8476
  {
8491
8477
  convertLegacyVModelProps(vnode);
8492
- convertLegacyRefInFor(vnode);
8493
8478
  defineLegacyVNodeProperties(vnode);
8494
8479
  }
8495
8480
  return vnode;
@@ -8762,7 +8747,8 @@ function mergeProps(...args) {
8762
8747
  else if (isOn(key)) {
8763
8748
  const existing = ret[key];
8764
8749
  const incoming = toMerge[key];
8765
- if (existing !== incoming) {
8750
+ if (existing !== incoming &&
8751
+ !(isArray(existing) && existing.includes(incoming))) {
8766
8752
  ret[key] = existing
8767
8753
  ? [].concat(existing, incoming)
8768
8754
  : incoming;
@@ -8774,6 +8760,12 @@ function mergeProps(...args) {
8774
8760
  }
8775
8761
  }
8776
8762
  return ret;
8763
+ }
8764
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8765
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8766
+ vnode,
8767
+ prevVNode
8768
+ ]);
8777
8769
  }
8778
8770
 
8779
8771
  function getCompatChildren(instance) {
@@ -9206,23 +9198,23 @@ const PublicInstanceProxyHandlers = {
9206
9198
  const n = accessCache[key];
9207
9199
  if (n !== undefined) {
9208
9200
  switch (n) {
9209
- case 0 /* SETUP */:
9201
+ case 1 /* SETUP */:
9210
9202
  return setupState[key];
9211
- case 1 /* DATA */:
9203
+ case 2 /* DATA */:
9212
9204
  return data[key];
9213
- case 3 /* CONTEXT */:
9205
+ case 4 /* CONTEXT */:
9214
9206
  return ctx[key];
9215
- case 2 /* PROPS */:
9207
+ case 3 /* PROPS */:
9216
9208
  return props[key];
9217
9209
  // default: just fallthrough
9218
9210
  }
9219
9211
  }
9220
9212
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9221
- accessCache[key] = 0 /* SETUP */;
9213
+ accessCache[key] = 1 /* SETUP */;
9222
9214
  return setupState[key];
9223
9215
  }
9224
9216
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9225
- accessCache[key] = 1 /* DATA */;
9217
+ accessCache[key] = 2 /* DATA */;
9226
9218
  return data[key];
9227
9219
  }
9228
9220
  else if (
@@ -9230,15 +9222,15 @@ const PublicInstanceProxyHandlers = {
9230
9222
  // props
9231
9223
  (normalizedProps = instance.propsOptions[0]) &&
9232
9224
  hasOwn(normalizedProps, key)) {
9233
- accessCache[key] = 2 /* PROPS */;
9225
+ accessCache[key] = 3 /* PROPS */;
9234
9226
  return props[key];
9235
9227
  }
9236
9228
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9237
- accessCache[key] = 3 /* CONTEXT */;
9229
+ accessCache[key] = 4 /* CONTEXT */;
9238
9230
  return ctx[key];
9239
9231
  }
9240
9232
  else if (shouldCacheAccess) {
9241
- accessCache[key] = 4 /* OTHER */;
9233
+ accessCache[key] = 0 /* OTHER */;
9242
9234
  }
9243
9235
  }
9244
9236
  const publicGetter = publicPropertiesMap[key];
@@ -9259,7 +9251,7 @@ const PublicInstanceProxyHandlers = {
9259
9251
  }
9260
9252
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9261
9253
  // user may set custom properties to `this` that start with `$`
9262
- accessCache[key] = 3 /* CONTEXT */;
9254
+ accessCache[key] = 4 /* CONTEXT */;
9263
9255
  return ctx[key];
9264
9256
  }
9265
9257
  else if (
@@ -9327,7 +9319,7 @@ const PublicInstanceProxyHandlers = {
9327
9319
  },
9328
9320
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9329
9321
  let normalizedProps;
9330
- return (accessCache[key] !== undefined ||
9322
+ return (!!accessCache[key] ||
9331
9323
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9332
9324
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9333
9325
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -9433,6 +9425,7 @@ function createComponentInstance(vnode, parent, suspense) {
9433
9425
  root: null,
9434
9426
  next: null,
9435
9427
  subTree: null,
9428
+ effect: null,
9436
9429
  update: null,
9437
9430
  scope: new EffectScope(true /* detached */),
9438
9431
  render: null,
@@ -10902,7 +10895,7 @@ function isMemoSame(cached, memo) {
10902
10895
  }
10903
10896
 
10904
10897
  // Core API ------------------------------------------------------------------
10905
- const version = "3.2.21";
10898
+ const version = "3.2.25";
10906
10899
  /**
10907
10900
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10908
10901
  * @internal
@@ -11169,12 +11162,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11169
11162
  el[key] = value == null ? '' : value;
11170
11163
  return;
11171
11164
  }
11172
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11165
+ if (key === 'value' &&
11166
+ el.tagName !== 'PROGRESS' &&
11167
+ // custom elements may use _value internally
11168
+ !el.tagName.includes('-')) {
11173
11169
  // store value as _value as well since
11174
11170
  // non-string values will be stringified.
11175
11171
  el._value = value;
11176
11172
  const newValue = value == null ? '' : value;
11177
- if (el.value !== newValue) {
11173
+ if (el.value !== newValue ||
11174
+ // #4956: always set for OPTION elements because its value falls back to
11175
+ // textContent if no value attribute is present. And setting .value for
11176
+ // OPTION has no side effect
11177
+ el.tagName === 'OPTION') {
11178
11178
  el.value = newValue;
11179
11179
  }
11180
11180
  if (value == null) {
@@ -11570,7 +11570,7 @@ class VueElement extends BaseClass {
11570
11570
  // HMR
11571
11571
  {
11572
11572
  instance.ceReload = newStyles => {
11573
- // alawys reset styles
11573
+ // always reset styles
11574
11574
  if (this._styles) {
11575
11575
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11576
11576
  this._styles.length = 0;
@@ -13306,12 +13306,12 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
13306
13306
  }
13307
13307
  else if (p.name === 'bind' &&
13308
13308
  (p.exp || allowEmpty) &&
13309
- isBindKey(p.arg, name)) {
13309
+ isStaticArgOf(p.arg, name)) {
13310
13310
  return p;
13311
13311
  }
13312
13312
  }
13313
13313
  }
13314
- function isBindKey(arg, name) {
13314
+ function isStaticArgOf(arg, name) {
13315
13315
  return !!(arg && isStaticExp(arg) && arg.content === name);
13316
13316
  }
13317
13317
  function hasDynamicKeyVBind(node) {
@@ -13354,7 +13354,6 @@ function getUnnormalizedProps(props, callPath = []) {
13354
13354
  }
13355
13355
  function injectProp(node, prop, context) {
13356
13356
  let propsWithInjection;
13357
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13358
13357
  /**
13359
13358
  * 1. mergeProps(...)
13360
13359
  * 2. toHandlers(...)
@@ -13363,7 +13362,7 @@ function injectProp(node, prop, context) {
13363
13362
  *
13364
13363
  * we need to get the real props before normalization
13365
13364
  */
13366
- let props = originalProps;
13365
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13367
13366
  let callPath = [];
13368
13367
  let parentCall;
13369
13368
  if (props &&
@@ -13502,11 +13501,6 @@ const deprecationData$1 = {
13502
13501
  `data source.`,
13503
13502
  link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
13504
13503
  },
13505
- ["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
13506
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
13507
- `Consider using function refs or refactor to avoid ref usage altogether.`,
13508
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
13509
- },
13510
13504
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
13511
13505
  message: `<template> with no special directives will render as a native template ` +
13512
13506
  `element instead of its inner content in Vue 3.`
@@ -14024,7 +14018,7 @@ function isComponent(tag, props, context) {
14024
14018
  else if (
14025
14019
  // :is on plain element - only treat as component in compat mode
14026
14020
  p.name === 'bind' &&
14027
- isBindKey(p.arg, 'is') &&
14021
+ isStaticArgOf(p.arg, 'is') &&
14028
14022
  true &&
14029
14023
  checkCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
14030
14024
  return true;
@@ -14384,15 +14378,6 @@ function isSingleElementRoot(root, child) {
14384
14378
  !isSlotOutlet(child));
14385
14379
  }
14386
14380
  function walk$1(node, context, doNotHoistNode = false) {
14387
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14388
- // static bindings with expressions. These expressions are guaranteed to be
14389
- // constant so they are still eligible for hoisting, but they are only
14390
- // available at runtime and therefore cannot be evaluated ahead of time.
14391
- // This is only a concern for pre-stringification (via transformHoist by
14392
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14393
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14394
- // stringification threshold is met.
14395
- let canStringify = true;
14396
14381
  const { children } = node;
14397
14382
  const originalCount = children.length;
14398
14383
  let hoistedCount = 0;
@@ -14405,9 +14390,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14405
14390
  ? 0 /* NOT_CONSTANT */
14406
14391
  : getConstantType(child, context);
14407
14392
  if (constantType > 0 /* NOT_CONSTANT */) {
14408
- if (constantType < 3 /* CAN_STRINGIFY */) {
14409
- canStringify = false;
14410
- }
14411
14393
  if (constantType >= 2 /* CAN_HOIST */) {
14412
14394
  child.codegenNode.patchFlag =
14413
14395
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -14438,17 +14420,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14438
14420
  }
14439
14421
  }
14440
14422
  }
14441
- else if (child.type === 12 /* TEXT_CALL */) {
14442
- const contentType = getConstantType(child.content, context);
14443
- if (contentType > 0) {
14444
- if (contentType < 3 /* CAN_STRINGIFY */) {
14445
- canStringify = false;
14446
- }
14447
- if (contentType >= 2 /* CAN_HOIST */) {
14448
- child.codegenNode = context.hoist(child.codegenNode);
14449
- hoistedCount++;
14450
- }
14451
- }
14423
+ else if (child.type === 12 /* TEXT_CALL */ &&
14424
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14425
+ child.codegenNode = context.hoist(child.codegenNode);
14426
+ hoistedCount++;
14452
14427
  }
14453
14428
  // walk further
14454
14429
  if (child.type === 1 /* ELEMENT */) {
@@ -14472,7 +14447,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14472
14447
  }
14473
14448
  }
14474
14449
  }
14475
- if (canStringify && hoistedCount && context.transformHoist) {
14450
+ if (hoistedCount && context.transformHoist) {
14476
14451
  context.transformHoist(children, context, node);
14477
14452
  }
14478
14453
  // all children were hoisted - the entire children array is hoistable.
@@ -14501,6 +14476,11 @@ function getConstantType(node, context) {
14501
14476
  if (codegenNode.type !== 13 /* VNODE_CALL */) {
14502
14477
  return 0 /* NOT_CONSTANT */;
14503
14478
  }
14479
+ if (codegenNode.isBlock &&
14480
+ node.tag !== 'svg' &&
14481
+ node.tag !== 'foreignObject') {
14482
+ return 0 /* NOT_CONSTANT */;
14483
+ }
14504
14484
  const flag = getPatchFlag(codegenNode);
14505
14485
  if (!flag) {
14506
14486
  let returnType = 3 /* CAN_STRINGIFY */;
@@ -14637,7 +14617,7 @@ function getGeneratedPropsConstantType(node, context) {
14637
14617
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14638
14618
  // some helper calls can be hoisted,
14639
14619
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14640
- // in this case we need to respect the ConstantType of the helper's argments
14620
+ // in this case we need to respect the ConstantType of the helper's arguments
14641
14621
  valueType = getConstantTypeOfHelperCall(value, context);
14642
14622
  }
14643
14623
  else {
@@ -16304,10 +16284,7 @@ const transformElement = (node, context) => {
16304
16284
  // updates inside get proper isSVG flag at runtime. (#639, #643)
16305
16285
  // This is technically web-specific, but splitting the logic out of core
16306
16286
  // leads to too much unnecessary complexity.
16307
- (tag === 'svg' ||
16308
- tag === 'foreignObject' ||
16309
- // #938: elements with dynamic keys should be forced into blocks
16310
- findProp(node, 'key', true)));
16287
+ (tag === 'svg' || tag === 'foreignObject'));
16311
16288
  // props
16312
16289
  if (props.length > 0) {
16313
16290
  const propsBuildResult = buildProps(node, context);
@@ -16319,6 +16296,9 @@ const transformElement = (node, context) => {
16319
16296
  directives && directives.length
16320
16297
  ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
16321
16298
  : undefined;
16299
+ if (propsBuildResult.shouldUseBlock) {
16300
+ shouldUseBlock = true;
16301
+ }
16322
16302
  }
16323
16303
  // children
16324
16304
  if (node.children.length > 0) {
@@ -16447,11 +16427,13 @@ function resolveComponentType(node, context, ssr = false) {
16447
16427
  return toValidAssetId(tag, `component`);
16448
16428
  }
16449
16429
  function buildProps(node, context, props = node.props, ssr = false) {
16450
- const { tag, loc: elementLoc } = node;
16430
+ const { tag, loc: elementLoc, children } = node;
16451
16431
  const isComponent = node.tagType === 1 /* COMPONENT */;
16452
16432
  let properties = [];
16453
16433
  const mergeArgs = [];
16454
16434
  const runtimeDirectives = [];
16435
+ const hasChildren = children.length > 0;
16436
+ let shouldUseBlock = false;
16455
16437
  // patchFlag analysis
16456
16438
  let patchFlag = 0;
16457
16439
  let hasRef = false;
@@ -16514,9 +16496,12 @@ function buildProps(node, context, props = node.props, ssr = false) {
16514
16496
  const prop = props[i];
16515
16497
  if (prop.type === 6 /* ATTRIBUTE */) {
16516
16498
  const { loc, name, value } = prop;
16517
- let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
16499
+ let isStatic = true;
16518
16500
  if (name === 'ref') {
16519
16501
  hasRef = true;
16502
+ if (context.scopes.vFor > 0) {
16503
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
16504
+ }
16520
16505
  }
16521
16506
  // skip is on <component>, or is="vue:xxx"
16522
16507
  if (name === 'is' &&
@@ -16525,7 +16510,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
16525
16510
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
16526
16511
  continue;
16527
16512
  }
16528
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
16513
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
16529
16514
  }
16530
16515
  else {
16531
16516
  // directives
@@ -16546,7 +16531,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
16546
16531
  // skip v-is and :is on <component>
16547
16532
  if (name === 'is' ||
16548
16533
  (isVBind &&
16549
- isBindKey(arg, 'is') &&
16534
+ isStaticArgOf(arg, 'is') &&
16550
16535
  (isComponentTag(tag) ||
16551
16536
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
16552
16537
  continue;
@@ -16555,6 +16540,17 @@ function buildProps(node, context, props = node.props, ssr = false) {
16555
16540
  if (isVOn && ssr) {
16556
16541
  continue;
16557
16542
  }
16543
+ if (
16544
+ // #938: elements with dynamic keys should be forced into blocks
16545
+ (isVBind && isStaticArgOf(arg, 'key')) ||
16546
+ // inline before-update hooks need to force block so that it is invoked
16547
+ // before children
16548
+ (isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
16549
+ shouldUseBlock = true;
16550
+ }
16551
+ if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
16552
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
16553
+ }
16558
16554
  // special case for v-bind and v-on with no argument
16559
16555
  if (!arg && (isVBind || isVOn)) {
16560
16556
  hasDynamicKeys = true;
@@ -16628,14 +16624,13 @@ function buildProps(node, context, props = node.props, ssr = false) {
16628
16624
  else {
16629
16625
  // no built-in transform, this is a user custom directive.
16630
16626
  runtimeDirectives.push(prop);
16627
+ // custom dirs may use beforeUpdate so they need to force blocks
16628
+ // to ensure before-update gets called before children update
16629
+ if (hasChildren) {
16630
+ shouldUseBlock = true;
16631
+ }
16631
16632
  }
16632
16633
  }
16633
- if (prop.type === 6 /* ATTRIBUTE */ &&
16634
- prop.name === 'ref' &&
16635
- context.scopes.vFor > 0 &&
16636
- checkCompatEnabled$1("COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */, context, prop.loc)) {
16637
- properties.push(createObjectProperty(createSimpleExpression('refInFor', true), createSimpleExpression('true', false)));
16638
- }
16639
16634
  }
16640
16635
  let propsExpression = undefined;
16641
16636
  // has v-bind="object" or v-on="object", wrap with mergeProps
@@ -16672,7 +16667,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
16672
16667
  patchFlag |= 32 /* HYDRATE_EVENTS */;
16673
16668
  }
16674
16669
  }
16675
- if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
16670
+ if (!shouldUseBlock &&
16671
+ (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
16676
16672
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
16677
16673
  patchFlag |= 512 /* NEED_PATCH */;
16678
16674
  }
@@ -16739,7 +16735,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
16739
16735
  props: propsExpression,
16740
16736
  directives: runtimeDirectives,
16741
16737
  patchFlag,
16742
- dynamicPropNames
16738
+ dynamicPropNames,
16739
+ shouldUseBlock
16743
16740
  };
16744
16741
  }
16745
16742
  // Dedupe props in an object literal.
@@ -16827,7 +16824,7 @@ function stringifyDynamicPropNames(props) {
16827
16824
  return propsNamesString + `]`;
16828
16825
  }
16829
16826
  function isComponentTag(tag) {
16830
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
16827
+ return tag === 'component' || tag === 'Component';
16831
16828
  }
16832
16829
 
16833
16830
  const transformSlotOutlet = (node, context) => {
@@ -16875,7 +16872,7 @@ function processSlotOutlet(node, context) {
16875
16872
  }
16876
16873
  }
16877
16874
  else {
16878
- if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
16875
+ if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
16879
16876
  if (p.exp)
16880
16877
  slotName = p.exp;
16881
16878
  }
@@ -16909,7 +16906,11 @@ const transformOn = (dir, node, context, augmentor) => {
16909
16906
  let eventName;
16910
16907
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
16911
16908
  if (arg.isStatic) {
16912
- const rawName = arg.content;
16909
+ let rawName = arg.content;
16910
+ // TODO deprecate @vnodeXXX usage
16911
+ if (rawName.startsWith('vue:')) {
16912
+ rawName = `vnode-${rawName.slice(4)}`;
16913
+ }
16913
16914
  // for all event listeners, auto convert it to camelCase. See issue #2249
16914
16915
  eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
16915
16916
  }