@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.
package/dist/vue.cjs.js CHANGED
@@ -113,7 +113,7 @@ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomo
113
113
  const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
114
114
  /**
115
115
  * Boolean attributes should be included if the value is truthy or ''.
116
- * e.g. <select multiple> compiles to { multiple: '' }
116
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
117
117
  */
118
118
  function includeBooleanAttr(value) {
119
119
  return !!value || value === '';
@@ -478,7 +478,7 @@ const isIntegerKey = (key) => isString(key) &&
478
478
  '' + parseInt(key, 10) === key;
479
479
  const isReservedProp = /*#__PURE__*/ makeMap(
480
480
  // the leading comma is intentional so empty string "" is also included
481
- ',key,ref,' +
481
+ ',key,ref,ref_for,ref_key,' +
482
482
  'onVnodeBeforeMount,onVnodeMounted,' +
483
483
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
484
484
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -667,7 +667,7 @@ const targetMap = new WeakMap();
667
667
  let effectTrackDepth = 0;
668
668
  let trackOpBit = 1;
669
669
  /**
670
- * The bitwise track markers support at most 30 levels op recursion.
670
+ * The bitwise track markers support at most 30 levels of recursion.
671
671
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
672
672
  * When recursion depth is greater, fall back to using a full cleanup.
673
673
  */
@@ -988,7 +988,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
988
988
  function createSetter(shallow = false) {
989
989
  return function set(target, key, value, receiver) {
990
990
  let oldValue = target[key];
991
- if (!shallow) {
991
+ if (!shallow && !isReadonly(value)) {
992
992
  value = toRaw(value);
993
993
  oldValue = toRaw(oldValue);
994
994
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1573,21 +1573,25 @@ function toRefs(object) {
1573
1573
  return ret;
1574
1574
  }
1575
1575
  class ObjectRefImpl {
1576
- constructor(_object, _key) {
1576
+ constructor(_object, _key, _defaultValue) {
1577
1577
  this._object = _object;
1578
1578
  this._key = _key;
1579
+ this._defaultValue = _defaultValue;
1579
1580
  this.__v_isRef = true;
1580
1581
  }
1581
1582
  get value() {
1582
- return this._object[this._key];
1583
+ const val = this._object[this._key];
1584
+ return val === undefined ? this._defaultValue : val;
1583
1585
  }
1584
1586
  set value(newVal) {
1585
1587
  this._object[this._key] = newVal;
1586
1588
  }
1587
1589
  }
1588
- function toRef(object, key) {
1590
+ function toRef(object, key, defaultValue) {
1589
1591
  const val = object[key];
1590
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1592
+ return isRef(val)
1593
+ ? val
1594
+ : new ObjectRefImpl(object, key, defaultValue);
1591
1595
  }
1592
1596
 
1593
1597
  class ComputedRefImpl {
@@ -2033,11 +2037,6 @@ const deprecationData = {
2033
2037
  `Use "${newHook}" instead.`,
2034
2038
  link: `https://v3.vuejs.org/guide/migration/custom-directives.html`
2035
2039
  },
2036
- ["V_FOR_REF" /* V_FOR_REF */]: {
2037
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
2038
- `Consider using function refs or refactor to avoid ref usage altogether.`,
2039
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
2040
- },
2041
2040
  ["V_ON_KEYCODE_MODIFIER" /* V_ON_KEYCODE_MODIFIER */]: {
2042
2041
  message: `Using keyCode as v-on modifier is no longer supported. ` +
2043
2042
  `Use kebab-case key name modifiers instead.`,
@@ -3444,7 +3443,8 @@ const BaseTransitionImpl = {
3444
3443
  const rawProps = toRaw(props);
3445
3444
  const { mode } = rawProps;
3446
3445
  // check mode
3447
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3446
+ if (mode &&
3447
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3448
3448
  warn$1(`invalid <transition> mode: ${mode}`);
3449
3449
  }
3450
3450
  // at this point children has a guaranteed length of 1.
@@ -4090,7 +4090,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
4090
4090
  }
4091
4091
  current = current.parent;
4092
4092
  }
4093
- hook();
4093
+ return hook();
4094
4094
  });
4095
4095
  injectHook(type, wrappedHook, target);
4096
4096
  // In addition to registering it on the target instance, we walk up the parent
@@ -4868,7 +4868,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4868
4868
  continue;
4869
4869
  }
4870
4870
  }
4871
- if (value !== attrs[key]) {
4871
+ if (!(key in attrs) || value !== attrs[key]) {
4872
4872
  attrs[key] = value;
4873
4873
  hasAttrsChanged = true;
4874
4874
  }
@@ -5449,7 +5449,7 @@ function createCompatVue(createApp, createSingletonApp) {
5449
5449
  return vm;
5450
5450
  }
5451
5451
  }
5452
- Vue.version = "3.2.22";
5452
+ Vue.version = "3.2.26";
5453
5453
  Vue.config = singletonApp.config;
5454
5454
  Vue.use = (p, ...options) => {
5455
5455
  if (p && isFunction(p.install)) {
@@ -5800,7 +5800,7 @@ const methodsToPatch = [
5800
5800
  ];
5801
5801
  const patched = new WeakSet();
5802
5802
  function defineReactive(obj, key, val) {
5803
- // it's possible for the orignial object to be mutated after being defined
5803
+ // it's possible for the original object to be mutated after being defined
5804
5804
  // and expecting reactivity... we are covering it here because this seems to
5805
5805
  // be a bit more common.
5806
5806
  if (isObject(val) && !isReactive(val) && !patched.has(val)) {
@@ -6020,6 +6020,102 @@ function createAppAPI(render, hydrate) {
6020
6020
  };
6021
6021
  }
6022
6022
 
6023
+ /**
6024
+ * Function for handling a template ref
6025
+ */
6026
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
6027
+ if (isArray(rawRef)) {
6028
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
6029
+ return;
6030
+ }
6031
+ if (isAsyncWrapper(vnode) && !isUnmount) {
6032
+ // when mounting async components, nothing needs to be done,
6033
+ // because the template ref is forwarded to inner component
6034
+ return;
6035
+ }
6036
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
6037
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
6038
+ : vnode.el;
6039
+ const value = isUnmount ? null : refValue;
6040
+ const { i: owner, r: ref } = rawRef;
6041
+ if (!owner) {
6042
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
6043
+ `A vnode with ref must be created inside the render function.`);
6044
+ return;
6045
+ }
6046
+ const oldRef = oldRawRef && oldRawRef.r;
6047
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
6048
+ const setupState = owner.setupState;
6049
+ // dynamic ref changed. unset old ref
6050
+ if (oldRef != null && oldRef !== ref) {
6051
+ if (isString(oldRef)) {
6052
+ refs[oldRef] = null;
6053
+ if (hasOwn(setupState, oldRef)) {
6054
+ setupState[oldRef] = null;
6055
+ }
6056
+ }
6057
+ else if (isRef(oldRef)) {
6058
+ oldRef.value = null;
6059
+ }
6060
+ }
6061
+ if (isFunction(ref)) {
6062
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
6063
+ }
6064
+ else {
6065
+ const _isString = isString(ref);
6066
+ const _isRef = isRef(ref);
6067
+ if (_isString || _isRef) {
6068
+ const doSet = () => {
6069
+ if (rawRef.f) {
6070
+ const existing = _isString ? refs[ref] : ref.value;
6071
+ if (isUnmount) {
6072
+ isArray(existing) && remove(existing, refValue);
6073
+ }
6074
+ else {
6075
+ if (!isArray(existing)) {
6076
+ if (_isString) {
6077
+ refs[ref] = [refValue];
6078
+ }
6079
+ else {
6080
+ ref.value = [refValue];
6081
+ if (rawRef.k)
6082
+ refs[rawRef.k] = ref.value;
6083
+ }
6084
+ }
6085
+ else if (!existing.includes(refValue)) {
6086
+ existing.push(refValue);
6087
+ }
6088
+ }
6089
+ }
6090
+ else if (_isString) {
6091
+ refs[ref] = value;
6092
+ if (hasOwn(setupState, ref)) {
6093
+ setupState[ref] = value;
6094
+ }
6095
+ }
6096
+ else if (isRef(ref)) {
6097
+ ref.value = value;
6098
+ if (rawRef.k)
6099
+ refs[rawRef.k] = value;
6100
+ }
6101
+ else {
6102
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
6103
+ }
6104
+ };
6105
+ if (value) {
6106
+ doSet.id = -1;
6107
+ queuePostRenderEffect(doSet, parentSuspense);
6108
+ }
6109
+ else {
6110
+ doSet();
6111
+ }
6112
+ }
6113
+ else {
6114
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
6115
+ }
6116
+ }
6117
+ }
6118
+
6023
6119
  let hasMismatch = false;
6024
6120
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
6025
6121
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -6381,44 +6477,6 @@ function isSupported() {
6381
6477
  return supported;
6382
6478
  }
6383
6479
 
6384
- function convertLegacyRefInFor(vnode) {
6385
- // refInFor
6386
- if (vnode.props && vnode.props.refInFor) {
6387
- delete vnode.props.refInFor;
6388
- if (vnode.ref) {
6389
- if (isArray(vnode.ref)) {
6390
- vnode.ref.forEach(r => (r.f = true));
6391
- }
6392
- else {
6393
- vnode.ref.f = true;
6394
- }
6395
- }
6396
- }
6397
- }
6398
- function registerLegacyRef(refs, key, value, owner, isInFor, isUnmount) {
6399
- const existing = refs[key];
6400
- if (isUnmount) {
6401
- if (isArray(existing)) {
6402
- remove(existing, value);
6403
- }
6404
- else {
6405
- refs[key] = null;
6406
- }
6407
- }
6408
- else if (isInFor) {
6409
- warnDeprecation("V_FOR_REF" /* V_FOR_REF */, owner);
6410
- if (!isArray(existing)) {
6411
- refs[key] = [value];
6412
- }
6413
- else if (!existing.includes(value)) {
6414
- existing.push(value);
6415
- }
6416
- }
6417
- else {
6418
- refs[key] = value;
6419
- }
6420
- }
6421
-
6422
6480
  const queuePostRenderEffect = queueEffectWithSuspense
6423
6481
  ;
6424
6482
  /**
@@ -6690,12 +6748,15 @@ function baseCreateRenderer(options, createHydrationFns) {
6690
6748
  const oldProps = n1.props || EMPTY_OBJ;
6691
6749
  const newProps = n2.props || EMPTY_OBJ;
6692
6750
  let vnodeHook;
6751
+ // disable recurse in beforeUpdate hooks
6752
+ parentComponent && toggleRecurse(parentComponent, false);
6693
6753
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
6694
6754
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6695
6755
  }
6696
6756
  if (dirs) {
6697
6757
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
6698
6758
  }
6759
+ parentComponent && toggleRecurse(parentComponent, true);
6699
6760
  if (isHmrUpdating) {
6700
6761
  // HMR updated, force full diff
6701
6762
  patchFlag = 0;
@@ -6979,7 +7040,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6979
7040
  const { el, props } = initialVNode;
6980
7041
  const { bm, m, parent } = instance;
6981
7042
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6982
- effect.allowRecurse = false;
7043
+ toggleRecurse(instance, false);
6983
7044
  // beforeMount hook
6984
7045
  if (bm) {
6985
7046
  invokeArrayFns(bm);
@@ -6992,7 +7053,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6992
7053
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
6993
7054
  instance.emit('hook:beforeMount');
6994
7055
  }
6995
- effect.allowRecurse = true;
7056
+ toggleRecurse(instance, true);
6996
7057
  if (el && hydrateNode) {
6997
7058
  // vnode has adopted host node - perform hydration instead of mount.
6998
7059
  const hydrateSubTree = () => {
@@ -7080,7 +7141,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7080
7141
  pushWarningContext(next || instance.vnode);
7081
7142
  }
7082
7143
  // Disallow component effect recursion during pre-lifecycle hooks.
7083
- effect.allowRecurse = false;
7144
+ toggleRecurse(instance, false);
7084
7145
  if (next) {
7085
7146
  next.el = vnode.el;
7086
7147
  updateComponentPreRender(instance, next, optimized);
@@ -7099,7 +7160,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7099
7160
  if (isCompatEnabled("INSTANCE_EVENT_HOOKS" /* INSTANCE_EVENT_HOOKS */, instance)) {
7100
7161
  instance.emit('hook:beforeUpdate');
7101
7162
  }
7102
- effect.allowRecurse = true;
7163
+ toggleRecurse(instance, true);
7103
7164
  // render
7104
7165
  {
7105
7166
  startMeasure(instance, `render`);
@@ -7148,13 +7209,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7148
7209
  }
7149
7210
  };
7150
7211
  // create reactive effect for rendering
7151
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7152
- );
7212
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
7213
+ ));
7153
7214
  const update = (instance.update = effect.run.bind(effect));
7154
7215
  update.id = instance.uid;
7155
7216
  // allowRecurse
7156
7217
  // #1801, #2043 component render effects should allow recursive updates
7157
- effect.allowRecurse = update.allowRecurse = true;
7218
+ toggleRecurse(instance, true);
7158
7219
  {
7159
7220
  effect.onTrack = instance.rtc
7160
7221
  ? e => invokeArrayFns(instance.rtc, e)
@@ -7684,88 +7745,8 @@ function baseCreateRenderer(options, createHydrationFns) {
7684
7745
  createApp: createAppAPI(render, hydrate)
7685
7746
  };
7686
7747
  }
7687
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
7688
- if (isArray(rawRef)) {
7689
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
7690
- return;
7691
- }
7692
- if (isAsyncWrapper(vnode) && !isUnmount) {
7693
- // when mounting async components, nothing needs to be done,
7694
- // because the template ref is forwarded to inner component
7695
- return;
7696
- }
7697
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
7698
- ? getExposeProxy(vnode.component) || vnode.component.proxy
7699
- : vnode.el;
7700
- const value = isUnmount ? null : refValue;
7701
- const { i: owner, r: ref } = rawRef;
7702
- if (!owner) {
7703
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
7704
- `A vnode with ref must be created inside the render function.`);
7705
- return;
7706
- }
7707
- const oldRef = oldRawRef && oldRawRef.r;
7708
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
7709
- const setupState = owner.setupState;
7710
- // dynamic ref changed. unset old ref
7711
- if (oldRef != null && oldRef !== ref) {
7712
- if (isString(oldRef)) {
7713
- refs[oldRef] = null;
7714
- if (hasOwn(setupState, oldRef)) {
7715
- setupState[oldRef] = null;
7716
- }
7717
- }
7718
- else if (isRef(oldRef)) {
7719
- oldRef.value = null;
7720
- }
7721
- }
7722
- if (isString(ref)) {
7723
- const doSet = () => {
7724
- if (isCompatEnabled("V_FOR_REF" /* V_FOR_REF */, owner)) {
7725
- registerLegacyRef(refs, ref, refValue, owner, rawRef.f, isUnmount);
7726
- }
7727
- else {
7728
- refs[ref] = value;
7729
- }
7730
- if (hasOwn(setupState, ref)) {
7731
- setupState[ref] = value;
7732
- }
7733
- };
7734
- // #1789: for non-null values, set them after render
7735
- // null values means this is unmount and it should not overwrite another
7736
- // ref with the same key
7737
- if (value) {
7738
- doSet.id = -1;
7739
- queuePostRenderEffect(doSet, parentSuspense);
7740
- }
7741
- else {
7742
- doSet();
7743
- }
7744
- }
7745
- else if (isRef(ref)) {
7746
- const doSet = () => {
7747
- ref.value = value;
7748
- };
7749
- if (value) {
7750
- doSet.id = -1;
7751
- queuePostRenderEffect(doSet, parentSuspense);
7752
- }
7753
- else {
7754
- doSet();
7755
- }
7756
- }
7757
- else if (isFunction(ref)) {
7758
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
7759
- }
7760
- else {
7761
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
7762
- }
7763
- }
7764
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7765
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7766
- vnode,
7767
- prevVNode
7768
- ]);
7748
+ function toggleRecurse({ effect, update }, allowed) {
7749
+ effect.allowRecurse = update.allowRecurse = allowed;
7769
7750
  }
7770
7751
  /**
7771
7752
  * #1156
@@ -8414,6 +8395,7 @@ function convertLegacyFunctionalComponent(comp) {
8414
8395
  };
8415
8396
  Func.props = comp.props;
8416
8397
  Func.displayName = comp.name;
8398
+ Func.compatConfig = comp.compatConfig;
8417
8399
  // v2 functional components do not inherit attrs
8418
8400
  Func.inheritAttrs = false;
8419
8401
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8559,10 +8541,10 @@ const createVNodeWithArgsTransform = (...args) => {
8559
8541
  };
8560
8542
  const InternalObjectKey = `__vInternal`;
8561
8543
  const normalizeKey = ({ key }) => key != null ? key : null;
8562
- const normalizeRef = ({ ref }) => {
8544
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
8563
8545
  return (ref != null
8564
8546
  ? isString(ref) || isRef(ref) || isFunction(ref)
8565
- ? { i: currentRenderingInstance, r: ref }
8547
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
8566
8548
  : ref
8567
8549
  : null);
8568
8550
  };
@@ -8630,7 +8612,6 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
8630
8612
  }
8631
8613
  {
8632
8614
  convertLegacyVModelProps(vnode);
8633
- convertLegacyRefInFor(vnode);
8634
8615
  defineLegacyVNodeProperties(vnode);
8635
8616
  }
8636
8617
  return vnode;
@@ -8916,6 +8897,12 @@ function mergeProps(...args) {
8916
8897
  }
8917
8898
  }
8918
8899
  return ret;
8900
+ }
8901
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
8902
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
8903
+ vnode,
8904
+ prevVNode
8905
+ ]);
8919
8906
  }
8920
8907
 
8921
8908
  function getCompatChildren(instance) {
@@ -9348,23 +9335,23 @@ const PublicInstanceProxyHandlers = {
9348
9335
  const n = accessCache[key];
9349
9336
  if (n !== undefined) {
9350
9337
  switch (n) {
9351
- case 0 /* SETUP */:
9338
+ case 1 /* SETUP */:
9352
9339
  return setupState[key];
9353
- case 1 /* DATA */:
9340
+ case 2 /* DATA */:
9354
9341
  return data[key];
9355
- case 3 /* CONTEXT */:
9342
+ case 4 /* CONTEXT */:
9356
9343
  return ctx[key];
9357
- case 2 /* PROPS */:
9344
+ case 3 /* PROPS */:
9358
9345
  return props[key];
9359
9346
  // default: just fallthrough
9360
9347
  }
9361
9348
  }
9362
9349
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9363
- accessCache[key] = 0 /* SETUP */;
9350
+ accessCache[key] = 1 /* SETUP */;
9364
9351
  return setupState[key];
9365
9352
  }
9366
9353
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9367
- accessCache[key] = 1 /* DATA */;
9354
+ accessCache[key] = 2 /* DATA */;
9368
9355
  return data[key];
9369
9356
  }
9370
9357
  else if (
@@ -9372,15 +9359,15 @@ const PublicInstanceProxyHandlers = {
9372
9359
  // props
9373
9360
  (normalizedProps = instance.propsOptions[0]) &&
9374
9361
  hasOwn(normalizedProps, key)) {
9375
- accessCache[key] = 2 /* PROPS */;
9362
+ accessCache[key] = 3 /* PROPS */;
9376
9363
  return props[key];
9377
9364
  }
9378
9365
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9379
- accessCache[key] = 3 /* CONTEXT */;
9366
+ accessCache[key] = 4 /* CONTEXT */;
9380
9367
  return ctx[key];
9381
9368
  }
9382
9369
  else if (shouldCacheAccess) {
9383
- accessCache[key] = 4 /* OTHER */;
9370
+ accessCache[key] = 0 /* OTHER */;
9384
9371
  }
9385
9372
  }
9386
9373
  const publicGetter = publicPropertiesMap[key];
@@ -9401,7 +9388,7 @@ const PublicInstanceProxyHandlers = {
9401
9388
  }
9402
9389
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9403
9390
  // user may set custom properties to `this` that start with `$`
9404
- accessCache[key] = 3 /* CONTEXT */;
9391
+ accessCache[key] = 4 /* CONTEXT */;
9405
9392
  return ctx[key];
9406
9393
  }
9407
9394
  else if (
@@ -9469,7 +9456,7 @@ const PublicInstanceProxyHandlers = {
9469
9456
  },
9470
9457
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9471
9458
  let normalizedProps;
9472
- return (accessCache[key] !== undefined ||
9459
+ return (!!accessCache[key] ||
9473
9460
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9474
9461
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9475
9462
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -9575,6 +9562,7 @@ function createComponentInstance(vnode, parent, suspense) {
9575
9562
  root: null,
9576
9563
  next: null,
9577
9564
  subTree: null,
9565
+ effect: null,
9578
9566
  update: null,
9579
9567
  scope: new EffectScope(true /* detached */),
9580
9568
  render: null,
@@ -11065,7 +11053,7 @@ function isMemoSame(cached, memo) {
11065
11053
  }
11066
11054
 
11067
11055
  // Core API ------------------------------------------------------------------
11068
- const version = "3.2.22";
11056
+ const version = "3.2.26";
11069
11057
  const _ssrUtils = {
11070
11058
  createComponentInstance,
11071
11059
  setupComponent,
@@ -11340,12 +11328,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11340
11328
  el[key] = value == null ? '' : value;
11341
11329
  return;
11342
11330
  }
11343
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11331
+ if (key === 'value' &&
11332
+ el.tagName !== 'PROGRESS' &&
11333
+ // custom elements may use _value internally
11334
+ !el.tagName.includes('-')) {
11344
11335
  // store value as _value as well since
11345
11336
  // non-string values will be stringified.
11346
11337
  el._value = value;
11347
11338
  const newValue = value == null ? '' : value;
11348
- if (el.value !== newValue) {
11339
+ if (el.value !== newValue ||
11340
+ // #4956: always set for OPTION elements because its value falls back to
11341
+ // textContent if no value attribute is present. And setting .value for
11342
+ // OPTION has no side effect
11343
+ el.tagName === 'OPTION') {
11349
11344
  el.value = newValue;
11350
11345
  }
11351
11346
  if (value == null) {
@@ -11741,7 +11736,7 @@ class VueElement extends BaseClass {
11741
11736
  // HMR
11742
11737
  {
11743
11738
  instance.ceReload = newStyles => {
11744
- // alawys reset styles
11739
+ // always reset styles
11745
11740
  if (this._styles) {
11746
11741
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11747
11742
  this._styles.length = 0;
@@ -13392,12 +13387,12 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
13392
13387
  }
13393
13388
  else if (p.name === 'bind' &&
13394
13389
  (p.exp || allowEmpty) &&
13395
- isBindKey(p.arg, name)) {
13390
+ isStaticArgOf(p.arg, name)) {
13396
13391
  return p;
13397
13392
  }
13398
13393
  }
13399
13394
  }
13400
- function isBindKey(arg, name) {
13395
+ function isStaticArgOf(arg, name) {
13401
13396
  return !!(arg && isStaticExp(arg) && arg.content === name);
13402
13397
  }
13403
13398
  function hasDynamicKeyVBind(node) {
@@ -13440,7 +13435,6 @@ function getUnnormalizedProps(props, callPath = []) {
13440
13435
  }
13441
13436
  function injectProp(node, prop, context) {
13442
13437
  let propsWithInjection;
13443
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13444
13438
  /**
13445
13439
  * 1. mergeProps(...)
13446
13440
  * 2. toHandlers(...)
@@ -13449,7 +13443,7 @@ function injectProp(node, prop, context) {
13449
13443
  *
13450
13444
  * we need to get the real props before normalization
13451
13445
  */
13452
- let props = originalProps;
13446
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13453
13447
  let callPath = [];
13454
13448
  let parentCall;
13455
13449
  if (props &&
@@ -13631,11 +13625,6 @@ const deprecationData$1 = {
13631
13625
  `data source.`,
13632
13626
  link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
13633
13627
  },
13634
- ["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
13635
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
13636
- `Consider using function refs or refactor to avoid ref usage altogether.`,
13637
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
13638
- },
13639
13628
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
13640
13629
  message: `<template> with no special directives will render as a native template ` +
13641
13630
  `element instead of its inner content in Vue 3.`
@@ -14153,7 +14142,7 @@ function isComponent(tag, props, context) {
14153
14142
  else if (
14154
14143
  // :is on plain element - only treat as component in compat mode
14155
14144
  p.name === 'bind' &&
14156
- isBindKey(p.arg, 'is') &&
14145
+ isStaticArgOf(p.arg, 'is') &&
14157
14146
  true &&
14158
14147
  checkCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
14159
14148
  return true;
@@ -14513,15 +14502,6 @@ function isSingleElementRoot(root, child) {
14513
14502
  !isSlotOutlet(child));
14514
14503
  }
14515
14504
  function walk$1(node, context, doNotHoistNode = false) {
14516
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14517
- // static bindings with expressions. These expressions are guaranteed to be
14518
- // constant so they are still eligible for hoisting, but they are only
14519
- // available at runtime and therefore cannot be evaluated ahead of time.
14520
- // This is only a concern for pre-stringification (via transformHoist by
14521
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14522
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14523
- // stringification threshold is met.
14524
- let canStringify = true;
14525
14505
  const { children } = node;
14526
14506
  const originalCount = children.length;
14527
14507
  let hoistedCount = 0;
@@ -14534,9 +14514,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14534
14514
  ? 0 /* NOT_CONSTANT */
14535
14515
  : getConstantType(child, context);
14536
14516
  if (constantType > 0 /* NOT_CONSTANT */) {
14537
- if (constantType < 3 /* CAN_STRINGIFY */) {
14538
- canStringify = false;
14539
- }
14540
14517
  if (constantType >= 2 /* CAN_HOIST */) {
14541
14518
  child.codegenNode.patchFlag =
14542
14519
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -14567,17 +14544,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14567
14544
  }
14568
14545
  }
14569
14546
  }
14570
- else if (child.type === 12 /* TEXT_CALL */) {
14571
- const contentType = getConstantType(child.content, context);
14572
- if (contentType > 0) {
14573
- if (contentType < 3 /* CAN_STRINGIFY */) {
14574
- canStringify = false;
14575
- }
14576
- if (contentType >= 2 /* CAN_HOIST */) {
14577
- child.codegenNode = context.hoist(child.codegenNode);
14578
- hoistedCount++;
14579
- }
14580
- }
14547
+ else if (child.type === 12 /* TEXT_CALL */ &&
14548
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14549
+ child.codegenNode = context.hoist(child.codegenNode);
14550
+ hoistedCount++;
14581
14551
  }
14582
14552
  // walk further
14583
14553
  if (child.type === 1 /* ELEMENT */) {
@@ -14601,7 +14571,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14601
14571
  }
14602
14572
  }
14603
14573
  }
14604
- if (canStringify && hoistedCount && context.transformHoist) {
14574
+ if (hoistedCount && context.transformHoist) {
14605
14575
  context.transformHoist(children, context, node);
14606
14576
  }
14607
14577
  // all children were hoisted - the entire children array is hoistable.
@@ -14630,6 +14600,11 @@ function getConstantType(node, context) {
14630
14600
  if (codegenNode.type !== 13 /* VNODE_CALL */) {
14631
14601
  return 0 /* NOT_CONSTANT */;
14632
14602
  }
14603
+ if (codegenNode.isBlock &&
14604
+ node.tag !== 'svg' &&
14605
+ node.tag !== 'foreignObject') {
14606
+ return 0 /* NOT_CONSTANT */;
14607
+ }
14633
14608
  const flag = getPatchFlag(codegenNode);
14634
14609
  if (!flag) {
14635
14610
  let returnType = 3 /* CAN_STRINGIFY */;
@@ -14766,7 +14741,7 @@ function getGeneratedPropsConstantType(node, context) {
14766
14741
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14767
14742
  // some helper calls can be hoisted,
14768
14743
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14769
- // in this case we need to respect the ConstantType of the helper's argments
14744
+ // in this case we need to respect the ConstantType of the helper's arguments
14770
14745
  valueType = getConstantTypeOfHelperCall(value, context);
14771
14746
  }
14772
14747
  else {
@@ -17220,10 +17195,7 @@ const transformElement = (node, context) => {
17220
17195
  // updates inside get proper isSVG flag at runtime. (#639, #643)
17221
17196
  // This is technically web-specific, but splitting the logic out of core
17222
17197
  // leads to too much unnecessary complexity.
17223
- (tag === 'svg' ||
17224
- tag === 'foreignObject' ||
17225
- // #938: elements with dynamic keys should be forced into blocks
17226
- findProp(node, 'key', true)));
17198
+ (tag === 'svg' || tag === 'foreignObject'));
17227
17199
  // props
17228
17200
  if (props.length > 0) {
17229
17201
  const propsBuildResult = buildProps(node, context);
@@ -17235,6 +17207,9 @@ const transformElement = (node, context) => {
17235
17207
  directives && directives.length
17236
17208
  ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
17237
17209
  : undefined;
17210
+ if (propsBuildResult.shouldUseBlock) {
17211
+ shouldUseBlock = true;
17212
+ }
17238
17213
  }
17239
17214
  // children
17240
17215
  if (node.children.length > 0) {
@@ -17424,11 +17399,13 @@ function resolveSetupReference(name, context) {
17424
17399
  }
17425
17400
  }
17426
17401
  function buildProps(node, context, props = node.props, ssr = false) {
17427
- const { tag, loc: elementLoc } = node;
17402
+ const { tag, loc: elementLoc, children } = node;
17428
17403
  const isComponent = node.tagType === 1 /* COMPONENT */;
17429
17404
  let properties = [];
17430
17405
  const mergeArgs = [];
17431
17406
  const runtimeDirectives = [];
17407
+ const hasChildren = children.length > 0;
17408
+ let shouldUseBlock = false;
17432
17409
  // patchFlag analysis
17433
17410
  let patchFlag = 0;
17434
17411
  let hasRef = false;
@@ -17491,15 +17468,20 @@ function buildProps(node, context, props = node.props, ssr = false) {
17491
17468
  const prop = props[i];
17492
17469
  if (prop.type === 6 /* ATTRIBUTE */) {
17493
17470
  const { loc, name, value } = prop;
17494
- let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
17471
+ let isStatic = true;
17495
17472
  if (name === 'ref') {
17496
17473
  hasRef = true;
17474
+ if (context.scopes.vFor > 0) {
17475
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
17476
+ }
17497
17477
  // in inline mode there is no setupState object, so we can't use string
17498
17478
  // keys to set the ref. Instead, we need to transform it to pass the
17499
17479
  // actual ref instead.
17500
- if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
17501
- valueNode = createFunctionExpression(['_value', '_refs']);
17502
- valueNode.body = createBlockStatement(processInlineRef(context, value.content));
17480
+ if (value &&
17481
+ context.inline &&
17482
+ context.bindingMetadata[value.content]) {
17483
+ isStatic = false;
17484
+ properties.push(createObjectProperty(createSimpleExpression('ref_key', true), createSimpleExpression(value.content, true, value.loc)));
17503
17485
  }
17504
17486
  }
17505
17487
  // skip is on <component>, or is="vue:xxx"
@@ -17509,7 +17491,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
17509
17491
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
17510
17492
  continue;
17511
17493
  }
17512
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
17494
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
17513
17495
  }
17514
17496
  else {
17515
17497
  // directives
@@ -17530,7 +17512,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
17530
17512
  // skip v-is and :is on <component>
17531
17513
  if (name === 'is' ||
17532
17514
  (isVBind &&
17533
- isBindKey(arg, 'is') &&
17515
+ isStaticArgOf(arg, 'is') &&
17534
17516
  (isComponentTag(tag) ||
17535
17517
  (isCompatEnabled$1("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
17536
17518
  continue;
@@ -17539,6 +17521,17 @@ function buildProps(node, context, props = node.props, ssr = false) {
17539
17521
  if (isVOn && ssr) {
17540
17522
  continue;
17541
17523
  }
17524
+ if (
17525
+ // #938: elements with dynamic keys should be forced into blocks
17526
+ (isVBind && isStaticArgOf(arg, 'key')) ||
17527
+ // inline before-update hooks need to force block so that it is invoked
17528
+ // before children
17529
+ (isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
17530
+ shouldUseBlock = true;
17531
+ }
17532
+ if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
17533
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
17534
+ }
17542
17535
  // special case for v-bind and v-on with no argument
17543
17536
  if (!arg && (isVBind || isVOn)) {
17544
17537
  hasDynamicKeys = true;
@@ -17612,14 +17605,13 @@ function buildProps(node, context, props = node.props, ssr = false) {
17612
17605
  else {
17613
17606
  // no built-in transform, this is a user custom directive.
17614
17607
  runtimeDirectives.push(prop);
17608
+ // custom dirs may use beforeUpdate so they need to force blocks
17609
+ // to ensure before-update gets called before children update
17610
+ if (hasChildren) {
17611
+ shouldUseBlock = true;
17612
+ }
17615
17613
  }
17616
17614
  }
17617
- if (prop.type === 6 /* ATTRIBUTE */ &&
17618
- prop.name === 'ref' &&
17619
- context.scopes.vFor > 0 &&
17620
- checkCompatEnabled$1("COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */, context, prop.loc)) {
17621
- properties.push(createObjectProperty(createSimpleExpression('refInFor', true), createSimpleExpression('true', false)));
17622
- }
17623
17615
  }
17624
17616
  let propsExpression = undefined;
17625
17617
  // has v-bind="object" or v-on="object", wrap with mergeProps
@@ -17656,7 +17648,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
17656
17648
  patchFlag |= 32 /* HYDRATE_EVENTS */;
17657
17649
  }
17658
17650
  }
17659
- if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
17651
+ if (!shouldUseBlock &&
17652
+ (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
17660
17653
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
17661
17654
  patchFlag |= 512 /* NEED_PATCH */;
17662
17655
  }
@@ -17723,7 +17716,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
17723
17716
  props: propsExpression,
17724
17717
  directives: runtimeDirectives,
17725
17718
  patchFlag,
17726
- dynamicPropNames
17719
+ dynamicPropNames,
17720
+ shouldUseBlock
17727
17721
  };
17728
17722
  }
17729
17723
  // Dedupe props in an object literal.
@@ -17818,21 +17812,6 @@ function stringifyDynamicPropNames(props) {
17818
17812
  }
17819
17813
  function isComponentTag(tag) {
17820
17814
  return tag === 'component' || tag === 'Component';
17821
- }
17822
- function processInlineRef(context, raw) {
17823
- const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
17824
- const { bindingMetadata, helperString } = context;
17825
- const type = bindingMetadata[raw];
17826
- if (type === "setup-ref" /* SETUP_REF */) {
17827
- body.push(createSimpleExpression(`${raw}.value = _value`));
17828
- }
17829
- else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
17830
- body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) && (${raw}.value = _value)`));
17831
- }
17832
- else if (type === "setup-let" /* SETUP_LET */) {
17833
- body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) ? ${raw}.value = _value : ${raw} = _value`));
17834
- }
17835
- return body;
17836
17815
  }
17837
17816
 
17838
17817
  const transformSlotOutlet = (node, context) => {
@@ -17880,7 +17859,7 @@ function processSlotOutlet(node, context) {
17880
17859
  }
17881
17860
  }
17882
17861
  else {
17883
- if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
17862
+ if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
17884
17863
  if (p.exp)
17885
17864
  slotName = p.exp;
17886
17865
  }
@@ -17914,7 +17893,11 @@ const transformOn = (dir, node, context, augmentor) => {
17914
17893
  let eventName;
17915
17894
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
17916
17895
  if (arg.isStatic) {
17917
- const rawName = arg.content;
17896
+ let rawName = arg.content;
17897
+ // TODO deprecate @vnodeXXX usage
17898
+ if (rawName.startsWith('vue:')) {
17899
+ rawName = `vnode-${rawName.slice(4)}`;
17900
+ }
17918
17901
  // for all event listeners, auto convert it to camelCase. See issue #2249
17919
17902
  eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
17920
17903
  }
@@ -21290,6 +21273,11 @@ function hasMultipleChildren(node) {
21290
21273
  /**
21291
21274
  * This module is Node-only.
21292
21275
  */
21276
+ /**
21277
+ * Regex for replacing placeholders for embedded constant variables
21278
+ * (e.g. import URL string constants generated by compiler-sfc)
21279
+ */
21280
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
21293
21281
  /**
21294
21282
  * Turn eligible hoisted static trees into stringified static nodes, e.g.
21295
21283
  *
@@ -21326,7 +21314,7 @@ const stringifyStatic = (children, context, parent) => {
21326
21314
  ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
21327
21315
  // combine all currently eligible nodes into a single static vnode call
21328
21316
  const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
21329
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
21317
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
21330
21318
  // the 2nd argument indicates the number of DOM nodes this static vnode
21331
21319
  // will insert / hydrate
21332
21320
  String(currentChunk.length)
@@ -21394,7 +21382,7 @@ const replaceHoist = (node, replacement, context) => {
21394
21382
  const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
21395
21383
  /**
21396
21384
  * for a hoisted node, analyze it and return:
21397
- * - false: bailed (contains runtime constant)
21385
+ * - false: bailed (contains non-stringifiable props or runtime constant)
21398
21386
  * - [nc, ec] where
21399
21387
  * - nc is the number of nodes inside
21400
21388
  * - ec is the number of element with bindings inside
@@ -21432,6 +21420,11 @@ function analyzeNode(node) {
21432
21420
  (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
21433
21421
  return bail();
21434
21422
  }
21423
+ if (p.exp &&
21424
+ (p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
21425
+ p.exp.constType < 3 /* CAN_STRINGIFY */)) {
21426
+ return bail();
21427
+ }
21435
21428
  }
21436
21429
  }
21437
21430
  for (let i = 0; i < node.children.length; i++) {
@@ -21487,8 +21480,15 @@ function stringifyElement(node, context) {
21487
21480
  }
21488
21481
  }
21489
21482
  else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
21483
+ const exp = p.exp;
21484
+ if (exp.content[0] === '_') {
21485
+ // internally generated string constant references
21486
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
21487
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
21488
+ continue;
21489
+ }
21490
21490
  // constant v-bind, e.g. :foo="1"
21491
- let evaluated = evaluateConstant(p.exp);
21491
+ let evaluated = evaluateConstant(exp);
21492
21492
  if (evaluated != null) {
21493
21493
  const arg = p.arg && p.arg.content;
21494
21494
  if (arg === 'class') {