@vue/compat 3.2.22 → 3.2.26

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 === '';
@@ -342,7 +342,7 @@ const isIntegerKey = (key) => isString(key) &&
342
342
  '' + parseInt(key, 10) === key;
343
343
  const isReservedProp = /*#__PURE__*/ makeMap(
344
344
  // the leading comma is intentional so empty string "" is also included
345
- ',key,ref,' +
345
+ ',key,ref,ref_for,ref_key,' +
346
346
  'onVnodeBeforeMount,onVnodeMounted,' +
347
347
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
348
348
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -531,7 +531,7 @@ const targetMap = new WeakMap();
531
531
  let effectTrackDepth = 0;
532
532
  let trackOpBit = 1;
533
533
  /**
534
- * The bitwise track markers support at most 30 levels op recursion.
534
+ * The bitwise track markers support at most 30 levels of recursion.
535
535
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
536
536
  * When recursion depth is greater, fall back to using a full cleanup.
537
537
  */
@@ -860,7 +860,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
860
860
  function createSetter(shallow = false) {
861
861
  return function set(target, key, value, receiver) {
862
862
  let oldValue = target[key];
863
- if (!shallow) {
863
+ if (!shallow && !isReadonly(value)) {
864
864
  value = toRaw(value);
865
865
  oldValue = toRaw(oldValue);
866
866
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1452,21 +1452,25 @@ function toRefs(object) {
1452
1452
  return ret;
1453
1453
  }
1454
1454
  class ObjectRefImpl {
1455
- constructor(_object, _key) {
1455
+ constructor(_object, _key, _defaultValue) {
1456
1456
  this._object = _object;
1457
1457
  this._key = _key;
1458
+ this._defaultValue = _defaultValue;
1458
1459
  this.__v_isRef = true;
1459
1460
  }
1460
1461
  get value() {
1461
- return this._object[this._key];
1462
+ const val = this._object[this._key];
1463
+ return val === undefined ? this._defaultValue : val;
1462
1464
  }
1463
1465
  set value(newVal) {
1464
1466
  this._object[this._key] = newVal;
1465
1467
  }
1466
1468
  }
1467
- function toRef(object, key) {
1469
+ function toRef(object, key, defaultValue) {
1468
1470
  const val = object[key];
1469
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1471
+ return isRef(val)
1472
+ ? val
1473
+ : new ObjectRefImpl(object, key, defaultValue);
1470
1474
  }
1471
1475
 
1472
1476
  class ComputedRefImpl {
@@ -1913,11 +1917,6 @@ const deprecationData = {
1913
1917
  `Use "${newHook}" instead.`,
1914
1918
  link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
1915
1919
  },
1916
- ["V_FOR_REF" /* V_FOR_REF */]: {
1917
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
1918
- `Consider using function refs or refactor to avoid ref usage altogether.`,
1919
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
1920
- },
1921
1920
  ["V_ON_KEYCODE_MODIFIER" /* V_ON_KEYCODE_MODIFIER */]: {
1922
1921
  message: `Using keyCode as v-on modifier is no longer supported. ` +
1923
1922
  `Use kebab-case key name modifiers instead.`,
@@ -3328,7 +3327,9 @@ const BaseTransitionImpl = {
3328
3327
  const rawProps = toRaw(props);
3329
3328
  const { mode } = rawProps;
3330
3329
  // check mode
3331
- if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3330
+ if ((process.env.NODE_ENV !== 'production') &&
3331
+ mode &&
3332
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3332
3333
  warn$1(`invalid <transition> mode: ${mode}`);
3333
3334
  }
3334
3335
  // at this point children has a guaranteed length of 1.
@@ -3974,7 +3975,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3974
3975
  }
3975
3976
  current = current.parent;
3976
3977
  }
3977
- hook();
3978
+ return hook();
3978
3979
  });
3979
3980
  injectHook(type, wrappedHook, target);
3980
3981
  // In addition to registering it on the target instance, we walk up the parent
@@ -4759,7 +4760,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4759
4760
  continue;
4760
4761
  }
4761
4762
  }
4762
- if (value !== attrs[key]) {
4763
+ if (!(key in attrs) || value !== attrs[key]) {
4763
4764
  attrs[key] = value;
4764
4765
  hasAttrsChanged = true;
4765
4766
  }
@@ -5342,7 +5343,7 @@ function createCompatVue(createApp, createSingletonApp) {
5342
5343
  return vm;
5343
5344
  }
5344
5345
  }
5345
- Vue.version = "3.2.22";
5346
+ Vue.version = "3.2.26";
5346
5347
  Vue.config = singletonApp.config;
5347
5348
  Vue.use = (p, ...options) => {
5348
5349
  if (p && isFunction(p.install)) {
@@ -5695,7 +5696,7 @@ const methodsToPatch = [
5695
5696
  ];
5696
5697
  const patched = new WeakSet();
5697
5698
  function defineReactive(obj, key, val) {
5698
- // it's possible for the orignial object to be mutated after being defined
5699
+ // it's possible for the original object to be mutated after being defined
5699
5700
  // and expecting reactivity... we are covering it here because this seems to
5700
5701
  // be a bit more common.
5701
5702
  if (isObject(val) && !isReactive(val) && !patched.has(val)) {
@@ -5918,6 +5919,102 @@ function createAppAPI(render, hydrate) {
5918
5919
  };
5919
5920
  }
5920
5921
 
5922
+ /**
5923
+ * Function for handling a template ref
5924
+ */
5925
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5926
+ if (isArray(rawRef)) {
5927
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
5928
+ return;
5929
+ }
5930
+ if (isAsyncWrapper(vnode) && !isUnmount) {
5931
+ // when mounting async components, nothing needs to be done,
5932
+ // because the template ref is forwarded to inner component
5933
+ return;
5934
+ }
5935
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
5936
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
5937
+ : vnode.el;
5938
+ const value = isUnmount ? null : refValue;
5939
+ const { i: owner, r: ref } = rawRef;
5940
+ if ((process.env.NODE_ENV !== 'production') && !owner) {
5941
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
5942
+ `A vnode with ref must be created inside the render function.`);
5943
+ return;
5944
+ }
5945
+ const oldRef = oldRawRef && oldRawRef.r;
5946
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
5947
+ const setupState = owner.setupState;
5948
+ // dynamic ref changed. unset old ref
5949
+ if (oldRef != null && oldRef !== ref) {
5950
+ if (isString(oldRef)) {
5951
+ refs[oldRef] = null;
5952
+ if (hasOwn(setupState, oldRef)) {
5953
+ setupState[oldRef] = null;
5954
+ }
5955
+ }
5956
+ else if (isRef(oldRef)) {
5957
+ oldRef.value = null;
5958
+ }
5959
+ }
5960
+ if (isFunction(ref)) {
5961
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
5962
+ }
5963
+ else {
5964
+ const _isString = isString(ref);
5965
+ const _isRef = isRef(ref);
5966
+ if (_isString || _isRef) {
5967
+ const doSet = () => {
5968
+ if (rawRef.f) {
5969
+ const existing = _isString ? refs[ref] : ref.value;
5970
+ if (isUnmount) {
5971
+ isArray(existing) && remove(existing, refValue);
5972
+ }
5973
+ else {
5974
+ if (!isArray(existing)) {
5975
+ if (_isString) {
5976
+ refs[ref] = [refValue];
5977
+ }
5978
+ else {
5979
+ ref.value = [refValue];
5980
+ if (rawRef.k)
5981
+ refs[rawRef.k] = ref.value;
5982
+ }
5983
+ }
5984
+ else if (!existing.includes(refValue)) {
5985
+ existing.push(refValue);
5986
+ }
5987
+ }
5988
+ }
5989
+ else if (_isString) {
5990
+ refs[ref] = value;
5991
+ if (hasOwn(setupState, ref)) {
5992
+ setupState[ref] = value;
5993
+ }
5994
+ }
5995
+ else if (isRef(ref)) {
5996
+ ref.value = value;
5997
+ if (rawRef.k)
5998
+ refs[rawRef.k] = value;
5999
+ }
6000
+ else if ((process.env.NODE_ENV !== 'production')) {
6001
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
6002
+ }
6003
+ };
6004
+ if (value) {
6005
+ doSet.id = -1;
6006
+ queuePostRenderEffect(doSet, parentSuspense);
6007
+ }
6008
+ else {
6009
+ doSet();
6010
+ }
6011
+ }
6012
+ else if ((process.env.NODE_ENV !== 'production')) {
6013
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
6014
+ }
6015
+ }
6016
+ }
6017
+
5921
6018
  let hasMismatch = false;
5922
6019
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
5923
6020
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -6306,45 +6403,7 @@ function initFeatureFlags() {
6306
6403
  `which expects these compile-time feature flags to be globally injected ` +
6307
6404
  `via the bundler config in order to get better tree-shaking in the ` +
6308
6405
  `production bundle.\n\n` +
6309
- `For more details, see http://link.vuejs.org/feature-flags.`);
6310
- }
6311
- }
6312
-
6313
- function convertLegacyRefInFor(vnode) {
6314
- // refInFor
6315
- if (vnode.props && vnode.props.refInFor) {
6316
- delete vnode.props.refInFor;
6317
- if (vnode.ref) {
6318
- if (isArray(vnode.ref)) {
6319
- vnode.ref.forEach(r => (r.f = true));
6320
- }
6321
- else {
6322
- vnode.ref.f = true;
6323
- }
6324
- }
6325
- }
6326
- }
6327
- function registerLegacyRef(refs, key, value, owner, isInFor, isUnmount) {
6328
- const existing = refs[key];
6329
- if (isUnmount) {
6330
- if (isArray(existing)) {
6331
- remove(existing, value);
6332
- }
6333
- else {
6334
- refs[key] = null;
6335
- }
6336
- }
6337
- else if (isInFor) {
6338
- (process.env.NODE_ENV !== 'production') && warnDeprecation("V_FOR_REF" /* V_FOR_REF */, owner);
6339
- if (!isArray(existing)) {
6340
- refs[key] = [value];
6341
- }
6342
- else if (!existing.includes(value)) {
6343
- existing.push(value);
6344
- }
6345
- }
6346
- else {
6347
- refs[key] = value;
6406
+ `For more details, see https://link.vuejs.org/feature-flags.`);
6348
6407
  }
6349
6408
  }
6350
6409
 
@@ -6634,12 +6693,15 @@ function baseCreateRenderer(options, createHydrationFns) {
6634
6693
  const oldProps = n1.props || EMPTY_OBJ;
6635
6694
  const newProps = n2.props || EMPTY_OBJ;
6636
6695
  let vnodeHook;
6696
+ // disable recurse in beforeUpdate hooks
6697
+ parentComponent && toggleRecurse(parentComponent, false);
6637
6698
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
6638
6699
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6639
6700
  }
6640
6701
  if (dirs) {
6641
6702
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
6642
6703
  }
6704
+ parentComponent && toggleRecurse(parentComponent, true);
6643
6705
  if ((process.env.NODE_ENV !== 'production') && isHmrUpdating) {
6644
6706
  // HMR updated, force full diff
6645
6707
  patchFlag = 0;
@@ -6923,7 +6985,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6923
6985
  const { el, props } = initialVNode;
6924
6986
  const { bm, m, parent } = instance;
6925
6987
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6926
- effect.allowRecurse = false;
6988
+ toggleRecurse(instance, false);
6927
6989
  // beforeMount hook
6928
6990
  if (bm) {
6929
6991
  invokeArrayFns(bm);
@@ -6936,7 +6998,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6936
6998
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6937
6999
  instance.emit('hook:beforeMount');
6938
7000
  }
6939
- effect.allowRecurse = true;
7001
+ toggleRecurse(instance, true);
6940
7002
  if (el && hydrateNode) {
6941
7003
  // vnode has adopted host node - perform hydration instead of mount.
6942
7004
  const hydrateSubTree = () => {
@@ -7024,7 +7086,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7024
7086
  pushWarningContext(next || instance.vnode);
7025
7087
  }
7026
7088
  // Disallow component effect recursion during pre-lifecycle hooks.
7027
- effect.allowRecurse = false;
7089
+ toggleRecurse(instance, false);
7028
7090
  if (next) {
7029
7091
  next.el = vnode.el;
7030
7092
  updateComponentPreRender(instance, next, optimized);
@@ -7043,7 +7105,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7043
7105
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
7044
7106
  instance.emit('hook:beforeUpdate');
7045
7107
  }
7046
- effect.allowRecurse = true;
7108
+ toggleRecurse(instance, true);
7047
7109
  // render
7048
7110
  if ((process.env.NODE_ENV !== 'production')) {
7049
7111
  startMeasure(instance, `render`);
@@ -7092,13 +7154,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7092
7154
  }
7093
7155
  };
7094
7156
  // create reactive effect for rendering
7095
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7096
- );
7157
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7158
+ ));
7097
7159
  const update = (instance.update = effect.run.bind(effect));
7098
7160
  update.id = instance.uid;
7099
7161
  // allowRecurse
7100
7162
  // #1801, #2043 component render effects should allow recursive updates
7101
- effect.allowRecurse = update.allowRecurse = true;
7163
+ toggleRecurse(instance, true);
7102
7164
  if ((process.env.NODE_ENV !== 'production')) {
7103
7165
  effect.onTrack = instance.rtc
7104
7166
  ? e => invokeArrayFns(instance.rtc, e)
@@ -7628,88 +7690,8 @@ function baseCreateRenderer(options, createHydrationFns) {
7628
7690
  createApp: createAppAPI(render, hydrate)
7629
7691
  };
7630
7692
  }
7631
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7632
- if (isArray(rawRef)) {
7633
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
7634
- return;
7635
- }
7636
- if (isAsyncWrapper(vnode) && !isUnmount) {
7637
- // when mounting async components, nothing needs to be done,
7638
- // because the template ref is forwarded to inner component
7639
- return;
7640
- }
7641
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
7642
- ? getExposeProxy(vnode.component) || vnode.component.proxy
7643
- : vnode.el;
7644
- const value = isUnmount ? null : refValue;
7645
- const { i: owner, r: ref } = rawRef;
7646
- if ((process.env.NODE_ENV !== 'production') && !owner) {
7647
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
7648
- `A vnode with ref must be created inside the render function.`);
7649
- return;
7650
- }
7651
- const oldRef = oldRawRef && oldRawRef.r;
7652
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
7653
- const setupState = owner.setupState;
7654
- // dynamic ref changed. unset old ref
7655
- if (oldRef != null && oldRef !== ref) {
7656
- if (isString(oldRef)) {
7657
- refs[oldRef] = null;
7658
- if (hasOwn(setupState, oldRef)) {
7659
- setupState[oldRef] = null;
7660
- }
7661
- }
7662
- else if (isRef(oldRef)) {
7663
- oldRef.value = null;
7664
- }
7665
- }
7666
- if (isString(ref)) {
7667
- const doSet = () => {
7668
- if (isCompatEnabled("V_FOR_REF" /* V_FOR_REF */, owner)) {
7669
- registerLegacyRef(refs, ref, refValue, owner, rawRef.f, isUnmount);
7670
- }
7671
- else {
7672
- refs[ref] = value;
7673
- }
7674
- if (hasOwn(setupState, ref)) {
7675
- setupState[ref] = value;
7676
- }
7677
- };
7678
- // #1789: for non-null values, set them after render
7679
- // null values means this is unmount and it should not overwrite another
7680
- // ref with the same key
7681
- if (value) {
7682
- doSet.id = -1;
7683
- queuePostRenderEffect(doSet, parentSuspense);
7684
- }
7685
- else {
7686
- doSet();
7687
- }
7688
- }
7689
- else if (isRef(ref)) {
7690
- const doSet = () => {
7691
- ref.value = value;
7692
- };
7693
- if (value) {
7694
- doSet.id = -1;
7695
- queuePostRenderEffect(doSet, parentSuspense);
7696
- }
7697
- else {
7698
- doSet();
7699
- }
7700
- }
7701
- else if (isFunction(ref)) {
7702
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
7703
- }
7704
- else if ((process.env.NODE_ENV !== 'production')) {
7705
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
7706
- }
7707
- }
7708
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7709
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7710
- vnode,
7711
- prevVNode
7712
- ]);
7693
+ function toggleRecurse({ effect, update }, allowed) {
7694
+ effect.allowRecurse = update.allowRecurse = allowed;
7713
7695
  }
7714
7696
  /**
7715
7697
  * #1156
@@ -8362,6 +8344,7 @@ function convertLegacyFunctionalComponent(comp) {
8362
8344
  };
8363
8345
  Func.props = comp.props;
8364
8346
  Func.displayName = comp.name;
8347
+ Func.compatConfig = comp.compatConfig;
8365
8348
  // v2 functional components do not inherit attrs
8366
8349
  Func.inheritAttrs = false;
8367
8350
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8508,10 +8491,10 @@ const createVNodeWithArgsTransform = (...args) => {
8508
8491
  };
8509
8492
  const InternalObjectKey = `__vInternal`;
8510
8493
  const normalizeKey = ({ key }) => key != null ? key : null;
8511
- const normalizeRef = ({ ref }) => {
8494
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
8512
8495
  return (ref != null
8513
8496
  ? isString(ref) || isRef(ref) || isFunction(ref)
8514
- ? { i: currentRenderingInstance, r: ref }
8497
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
8515
8498
  : ref
8516
8499
  : null);
8517
8500
  };
@@ -8579,7 +8562,6 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
8579
8562
  }
8580
8563
  {
8581
8564
  convertLegacyVModelProps(vnode);
8582
- convertLegacyRefInFor(vnode);
8583
8565
  defineLegacyVNodeProperties(vnode);
8584
8566
  }
8585
8567
  return vnode;
@@ -8865,6 +8847,12 @@ function mergeProps(...args) {
8865
8847
  }
8866
8848
  }
8867
8849
  return ret;
8850
+ }
8851
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8852
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8853
+ vnode,
8854
+ prevVNode
8855
+ ]);
8868
8856
  }
8869
8857
 
8870
8858
  function getCompatChildren(instance) {
@@ -9298,23 +9286,23 @@ const PublicInstanceProxyHandlers = {
9298
9286
  const n = accessCache[key];
9299
9287
  if (n !== undefined) {
9300
9288
  switch (n) {
9301
- case 0 /* SETUP */:
9289
+ case 1 /* SETUP */:
9302
9290
  return setupState[key];
9303
- case 1 /* DATA */:
9291
+ case 2 /* DATA */:
9304
9292
  return data[key];
9305
- case 3 /* CONTEXT */:
9293
+ case 4 /* CONTEXT */:
9306
9294
  return ctx[key];
9307
- case 2 /* PROPS */:
9295
+ case 3 /* PROPS */:
9308
9296
  return props[key];
9309
9297
  // default: just fallthrough
9310
9298
  }
9311
9299
  }
9312
9300
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9313
- accessCache[key] = 0 /* SETUP */;
9301
+ accessCache[key] = 1 /* SETUP */;
9314
9302
  return setupState[key];
9315
9303
  }
9316
9304
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9317
- accessCache[key] = 1 /* DATA */;
9305
+ accessCache[key] = 2 /* DATA */;
9318
9306
  return data[key];
9319
9307
  }
9320
9308
  else if (
@@ -9322,15 +9310,15 @@ const PublicInstanceProxyHandlers = {
9322
9310
  // props
9323
9311
  (normalizedProps = instance.propsOptions[0]) &&
9324
9312
  hasOwn(normalizedProps, key)) {
9325
- accessCache[key] = 2 /* PROPS */;
9313
+ accessCache[key] = 3 /* PROPS */;
9326
9314
  return props[key];
9327
9315
  }
9328
9316
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9329
- accessCache[key] = 3 /* CONTEXT */;
9317
+ accessCache[key] = 4 /* CONTEXT */;
9330
9318
  return ctx[key];
9331
9319
  }
9332
9320
  else if (!__VUE_OPTIONS_API__ || shouldCacheAccess) {
9333
- accessCache[key] = 4 /* OTHER */;
9321
+ accessCache[key] = 0 /* OTHER */;
9334
9322
  }
9335
9323
  }
9336
9324
  const publicGetter = publicPropertiesMap[key];
@@ -9351,7 +9339,7 @@ const PublicInstanceProxyHandlers = {
9351
9339
  }
9352
9340
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9353
9341
  // user may set custom properties to `this` that start with `$`
9354
- accessCache[key] = 3 /* CONTEXT */;
9342
+ accessCache[key] = 4 /* CONTEXT */;
9355
9343
  return ctx[key];
9356
9344
  }
9357
9345
  else if (
@@ -9422,7 +9410,7 @@ const PublicInstanceProxyHandlers = {
9422
9410
  },
9423
9411
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9424
9412
  let normalizedProps;
9425
- return (accessCache[key] !== undefined ||
9413
+ return (!!accessCache[key] ||
9426
9414
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9427
9415
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9428
9416
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -9528,6 +9516,7 @@ function createComponentInstance(vnode, parent, suspense) {
9528
9516
  root: null,
9529
9517
  next: null,
9530
9518
  subTree: null,
9519
+ effect: null,
9531
9520
  update: null,
9532
9521
  scope: new EffectScope(true /* detached */),
9533
9522
  render: null,
@@ -11047,7 +11036,7 @@ function isMemoSame(cached, memo) {
11047
11036
  }
11048
11037
 
11049
11038
  // Core API ------------------------------------------------------------------
11050
- const version = "3.2.22";
11039
+ const version = "3.2.26";
11051
11040
  const _ssrUtils = {
11052
11041
  createComponentInstance,
11053
11042
  setupComponent,
@@ -11322,12 +11311,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11322
11311
  el[key] = value == null ? '' : value;
11323
11312
  return;
11324
11313
  }
11325
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11314
+ if (key === 'value' &&
11315
+ el.tagName !== 'PROGRESS' &&
11316
+ // custom elements may use _value internally
11317
+ !el.tagName.includes('-')) {
11326
11318
  // store value as _value as well since
11327
11319
  // non-string values will be stringified.
11328
11320
  el._value = value;
11329
11321
  const newValue = value == null ? '' : value;
11330
- if (el.value !== newValue) {
11322
+ if (el.value !== newValue ||
11323
+ // #4956: always set for OPTION elements because its value falls back to
11324
+ // textContent if no value attribute is present. And setting .value for
11325
+ // OPTION has no side effect
11326
+ el.tagName === 'OPTION') {
11331
11327
  el.value = newValue;
11332
11328
  }
11333
11329
  if (value == null) {
@@ -11724,7 +11720,7 @@ class VueElement extends BaseClass {
11724
11720
  // HMR
11725
11721
  if ((process.env.NODE_ENV !== 'production')) {
11726
11722
  instance.ceReload = newStyles => {
11727
- // alawys reset styles
11723
+ // always reset styles
11728
11724
  if (this._styles) {
11729
11725
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11730
11726
  this._styles.length = 0;
@@ -13504,12 +13500,12 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
13504
13500
  }
13505
13501
  else if (p.name === 'bind' &&
13506
13502
  (p.exp || allowEmpty) &&
13507
- isBindKey(p.arg, name)) {
13503
+ isStaticArgOf(p.arg, name)) {
13508
13504
  return p;
13509
13505
  }
13510
13506
  }
13511
13507
  }
13512
- function isBindKey(arg, name) {
13508
+ function isStaticArgOf(arg, name) {
13513
13509
  return !!(arg && isStaticExp(arg) && arg.content === name);
13514
13510
  }
13515
13511
  function hasDynamicKeyVBind(node) {
@@ -13552,7 +13548,6 @@ function getUnnormalizedProps(props, callPath = []) {
13552
13548
  }
13553
13549
  function injectProp(node, prop, context) {
13554
13550
  let propsWithInjection;
13555
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13556
13551
  /**
13557
13552
  * 1. mergeProps(...)
13558
13553
  * 2. toHandlers(...)
@@ -13561,7 +13556,7 @@ function injectProp(node, prop, context) {
13561
13556
  *
13562
13557
  * we need to get the real props before normalization
13563
13558
  */
13564
- let props = originalProps;
13559
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13565
13560
  let callPath = [];
13566
13561
  let parentCall;
13567
13562
  if (props &&
@@ -13700,11 +13695,6 @@ const deprecationData$1 = {
13700
13695
  `data source.`,
13701
13696
  link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
13702
13697
  },
13703
- ["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
13704
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
13705
- `Consider using function refs or refactor to avoid ref usage altogether.`,
13706
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
13707
- },
13708
13698
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
13709
13699
  message: `<template> with no special directives will render as a native template ` +
13710
13700
  `element instead of its inner content in Vue 3.`
@@ -14224,7 +14214,7 @@ function isComponent(tag, props, context) {
14224
14214
  else if (
14225
14215
  // :is on plain element - only treat as component in compat mode
14226
14216
  p.name === 'bind' &&
14227
- isBindKey(p.arg, 'is') &&
14217
+ isStaticArgOf(p.arg, 'is') &&
14228
14218
  true &&
14229
14219
  checkCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
14230
14220
  return true;
@@ -14584,15 +14574,6 @@ function isSingleElementRoot(root, child) {
14584
14574
  !isSlotOutlet(child));
14585
14575
  }
14586
14576
  function walk$1(node, context, doNotHoistNode = false) {
14587
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14588
- // static bindings with expressions. These expressions are guaranteed to be
14589
- // constant so they are still eligible for hoisting, but they are only
14590
- // available at runtime and therefore cannot be evaluated ahead of time.
14591
- // This is only a concern for pre-stringification (via transformHoist by
14592
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14593
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14594
- // stringification threshold is met.
14595
- let canStringify = true;
14596
14577
  const { children } = node;
14597
14578
  const originalCount = children.length;
14598
14579
  let hoistedCount = 0;
@@ -14605,9 +14586,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14605
14586
  ? 0 /* NOT_CONSTANT */
14606
14587
  : getConstantType(child, context);
14607
14588
  if (constantType > 0 /* NOT_CONSTANT */) {
14608
- if (constantType < 3 /* CAN_STRINGIFY */) {
14609
- canStringify = false;
14610
- }
14611
14589
  if (constantType >= 2 /* CAN_HOIST */) {
14612
14590
  child.codegenNode.patchFlag =
14613
14591
  -1 /* HOISTED */ + ((process.env.NODE_ENV !== 'production') ? ` /* HOISTED */` : ``);
@@ -14638,17 +14616,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14638
14616
  }
14639
14617
  }
14640
14618
  }
14641
- else if (child.type === 12 /* TEXT_CALL */) {
14642
- const contentType = getConstantType(child.content, context);
14643
- if (contentType > 0) {
14644
- if (contentType < 3 /* CAN_STRINGIFY */) {
14645
- canStringify = false;
14646
- }
14647
- if (contentType >= 2 /* CAN_HOIST */) {
14648
- child.codegenNode = context.hoist(child.codegenNode);
14649
- hoistedCount++;
14650
- }
14651
- }
14619
+ else if (child.type === 12 /* TEXT_CALL */ &&
14620
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14621
+ child.codegenNode = context.hoist(child.codegenNode);
14622
+ hoistedCount++;
14652
14623
  }
14653
14624
  // walk further
14654
14625
  if (child.type === 1 /* ELEMENT */) {
@@ -14672,7 +14643,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14672
14643
  }
14673
14644
  }
14674
14645
  }
14675
- if (canStringify && hoistedCount && context.transformHoist) {
14646
+ if (hoistedCount && context.transformHoist) {
14676
14647
  context.transformHoist(children, context, node);
14677
14648
  }
14678
14649
  // all children were hoisted - the entire children array is hoistable.
@@ -14701,6 +14672,11 @@ function getConstantType(node, context) {
14701
14672
  if (codegenNode.type !== 13 /* VNODE_CALL */) {
14702
14673
  return 0 /* NOT_CONSTANT */;
14703
14674
  }
14675
+ if (codegenNode.isBlock &&
14676
+ node.tag !== 'svg' &&
14677
+ node.tag !== 'foreignObject') {
14678
+ return 0 /* NOT_CONSTANT */;
14679
+ }
14704
14680
  const flag = getPatchFlag(codegenNode);
14705
14681
  if (!flag) {
14706
14682
  let returnType = 3 /* CAN_STRINGIFY */;
@@ -14838,7 +14814,7 @@ function getGeneratedPropsConstantType(node, context) {
14838
14814
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14839
14815
  // some helper calls can be hoisted,
14840
14816
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14841
- // in this case we need to respect the ConstantType of the helper's argments
14817
+ // in this case we need to respect the ConstantType of the helper's arguments
14842
14818
  valueType = getConstantTypeOfHelperCall(value, context);
14843
14819
  }
14844
14820
  else {
@@ -16511,10 +16487,7 @@ const transformElement = (node, context) => {
16511
16487
  // updates inside get proper isSVG flag at runtime. (#639, #643)
16512
16488
  // This is technically web-specific, but splitting the logic out of core
16513
16489
  // leads to too much unnecessary complexity.
16514
- (tag === 'svg' ||
16515
- tag === 'foreignObject' ||
16516
- // #938: elements with dynamic keys should be forced into blocks
16517
- findProp(node, 'key', true)));
16490
+ (tag === 'svg' || tag === 'foreignObject'));
16518
16491
  // props
16519
16492
  if (props.length > 0) {
16520
16493
  const propsBuildResult = buildProps(node, context);
@@ -16526,6 +16499,9 @@ const transformElement = (node, context) => {
16526
16499
  directives && directives.length
16527
16500
  ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
16528
16501
  : undefined;
16502
+ if (propsBuildResult.shouldUseBlock) {
16503
+ shouldUseBlock = true;
16504
+ }
16529
16505
  }
16530
16506
  // children
16531
16507
  if (node.children.length > 0) {
@@ -16657,11 +16633,13 @@ function resolveComponentType(node, context, ssr = false) {
16657
16633
  return toValidAssetId(tag, `component`);
16658
16634
  }
16659
16635
  function buildProps(node, context, props = node.props, ssr = false) {
16660
- const { tag, loc: elementLoc } = node;
16636
+ const { tag, loc: elementLoc, children } = node;
16661
16637
  const isComponent = node.tagType === 1 /* COMPONENT */;
16662
16638
  let properties = [];
16663
16639
  const mergeArgs = [];
16664
16640
  const runtimeDirectives = [];
16641
+ const hasChildren = children.length > 0;
16642
+ let shouldUseBlock = false;
16665
16643
  // patchFlag analysis
16666
16644
  let patchFlag = 0;
16667
16645
  let hasRef = false;
@@ -16724,9 +16702,12 @@ function buildProps(node, context, props = node.props, ssr = false) {
16724
16702
  const prop = props[i];
16725
16703
  if (prop.type === 6 /* ATTRIBUTE */) {
16726
16704
  const { loc, name, value } = prop;
16727
- let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
16705
+ let isStatic = true;
16728
16706
  if (name === 'ref') {
16729
16707
  hasRef = true;
16708
+ if (context.scopes.vFor > 0) {
16709
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
16710
+ }
16730
16711
  }
16731
16712
  // skip is on <component>, or is="vue:xxx"
16732
16713
  if (name === 'is' &&
@@ -16735,7 +16716,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
16735
16716
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
16736
16717
  continue;
16737
16718
  }
16738
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
16719
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
16739
16720
  }
16740
16721
  else {
16741
16722
  // directives
@@ -16756,7 +16737,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
16756
16737
  // skip v-is and :is on <component>
16757
16738
  if (name === 'is' ||
16758
16739
  (isVBind &&
16759
- isBindKey(arg, 'is') &&
16740
+ isStaticArgOf(arg, 'is') &&
16760
16741
  (isComponentTag(tag) ||
16761
16742
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
16762
16743
  continue;
@@ -16765,6 +16746,17 @@ function buildProps(node, context, props = node.props, ssr = false) {
16765
16746
  if (isVOn && ssr) {
16766
16747
  continue;
16767
16748
  }
16749
+ if (
16750
+ // #938: elements with dynamic keys should be forced into blocks
16751
+ (isVBind && isStaticArgOf(arg, 'key')) ||
16752
+ // inline before-update hooks need to force block so that it is invoked
16753
+ // before children
16754
+ (isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
16755
+ shouldUseBlock = true;
16756
+ }
16757
+ if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
16758
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
16759
+ }
16768
16760
  // special case for v-bind and v-on with no argument
16769
16761
  if (!arg && (isVBind || isVOn)) {
16770
16762
  hasDynamicKeys = true;
@@ -16838,14 +16830,13 @@ function buildProps(node, context, props = node.props, ssr = false) {
16838
16830
  else {
16839
16831
  // no built-in transform, this is a user custom directive.
16840
16832
  runtimeDirectives.push(prop);
16833
+ // custom dirs may use beforeUpdate so they need to force blocks
16834
+ // to ensure before-update gets called before children update
16835
+ if (hasChildren) {
16836
+ shouldUseBlock = true;
16837
+ }
16841
16838
  }
16842
16839
  }
16843
- if (prop.type === 6 /* ATTRIBUTE */ &&
16844
- prop.name === 'ref' &&
16845
- context.scopes.vFor > 0 &&
16846
- checkCompatEnabled$1("COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */, context, prop.loc)) {
16847
- properties.push(createObjectProperty(createSimpleExpression('refInFor', true), createSimpleExpression('true', false)));
16848
- }
16849
16840
  }
16850
16841
  let propsExpression = undefined;
16851
16842
  // has v-bind="object" or v-on="object", wrap with mergeProps
@@ -16882,7 +16873,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
16882
16873
  patchFlag |= 32 /* HYDRATE_EVENTS */;
16883
16874
  }
16884
16875
  }
16885
- if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
16876
+ if (!shouldUseBlock &&
16877
+ (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
16886
16878
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
16887
16879
  patchFlag |= 512 /* NEED_PATCH */;
16888
16880
  }
@@ -16949,7 +16941,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
16949
16941
  props: propsExpression,
16950
16942
  directives: runtimeDirectives,
16951
16943
  patchFlag,
16952
- dynamicPropNames
16944
+ dynamicPropNames,
16945
+ shouldUseBlock
16953
16946
  };
16954
16947
  }
16955
16948
  // Dedupe props in an object literal.
@@ -17085,7 +17078,7 @@ function processSlotOutlet(node, context) {
17085
17078
  }
17086
17079
  }
17087
17080
  else {
17088
- if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
17081
+ if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
17089
17082
  if (p.exp)
17090
17083
  slotName = p.exp;
17091
17084
  }
@@ -17119,7 +17112,11 @@ const transformOn = (dir, node, context, augmentor) => {
17119
17112
  let eventName;
17120
17113
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
17121
17114
  if (arg.isStatic) {
17122
- const rawName = arg.content;
17115
+ let rawName = arg.content;
17116
+ // TODO deprecate @vnodeXXX usage
17117
+ if (rawName.startsWith('vue:')) {
17118
+ rawName = `vnode-${rawName.slice(4)}`;
17119
+ }
17123
17120
  // for all event listeners, auto convert it to camelCase. See issue #2249
17124
17121
  eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
17125
17122
  }