vue 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.
@@ -110,7 +110,7 @@ var Vue = (function (exports) {
110
110
  const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
111
111
  /**
112
112
  * Boolean attributes should be included if the value is truthy or ''.
113
- * e.g. <select multiple> compiles to { multiple: '' }
113
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
114
114
  */
115
115
  function includeBooleanAttr(value) {
116
116
  return !!value || value === '';
@@ -344,7 +344,7 @@ var Vue = (function (exports) {
344
344
  '' + parseInt(key, 10) === key;
345
345
  const isReservedProp = /*#__PURE__*/ makeMap(
346
346
  // the leading comma is intentional so empty string "" is also included
347
- ',key,ref,' +
347
+ ',key,ref,ref_for,ref_key,' +
348
348
  'onVnodeBeforeMount,onVnodeMounted,' +
349
349
  'onVnodeBeforeUpdate,onVnodeUpdated,' +
350
350
  'onVnodeBeforeUnmount,onVnodeUnmounted');
@@ -533,7 +533,7 @@ var Vue = (function (exports) {
533
533
  let effectTrackDepth = 0;
534
534
  let trackOpBit = 1;
535
535
  /**
536
- * The bitwise track markers support at most 30 levels op recursion.
536
+ * The bitwise track markers support at most 30 levels of recursion.
537
537
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
538
538
  * When recursion depth is greater, fall back to using a full cleanup.
539
539
  */
@@ -854,7 +854,7 @@ var Vue = (function (exports) {
854
854
  function createSetter(shallow = false) {
855
855
  return function set(target, key, value, receiver) {
856
856
  let oldValue = target[key];
857
- if (!shallow) {
857
+ if (!shallow && !isReadonly(value)) {
858
858
  value = toRaw(value);
859
859
  oldValue = toRaw(oldValue);
860
860
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1439,21 +1439,25 @@ var Vue = (function (exports) {
1439
1439
  return ret;
1440
1440
  }
1441
1441
  class ObjectRefImpl {
1442
- constructor(_object, _key) {
1442
+ constructor(_object, _key, _defaultValue) {
1443
1443
  this._object = _object;
1444
1444
  this._key = _key;
1445
+ this._defaultValue = _defaultValue;
1445
1446
  this.__v_isRef = true;
1446
1447
  }
1447
1448
  get value() {
1448
- return this._object[this._key];
1449
+ const val = this._object[this._key];
1450
+ return val === undefined ? this._defaultValue : val;
1449
1451
  }
1450
1452
  set value(newVal) {
1451
1453
  this._object[this._key] = newVal;
1452
1454
  }
1453
1455
  }
1454
- function toRef(object, key) {
1456
+ function toRef(object, key, defaultValue) {
1455
1457
  const val = object[key];
1456
- return isRef(val) ? val : new ObjectRefImpl(object, key);
1458
+ return isRef(val)
1459
+ ? val
1460
+ : new ObjectRefImpl(object, key, defaultValue);
1457
1461
  }
1458
1462
 
1459
1463
  class ComputedRefImpl {
@@ -1659,6 +1663,7 @@ var Vue = (function (exports) {
1659
1663
  }
1660
1664
  }
1661
1665
  function setDevtoolsHook(hook, target) {
1666
+ var _a, _b;
1662
1667
  exports.devtools = hook;
1663
1668
  if (exports.devtools) {
1664
1669
  exports.devtools.enabled = true;
@@ -1671,7 +1676,10 @@ var Vue = (function (exports) {
1671
1676
  // (#4815)
1672
1677
  // eslint-disable-next-line no-restricted-globals
1673
1678
  typeof window !== 'undefined' &&
1674
- !navigator.userAgent.includes('jsdom')) {
1679
+ // some envs mock window but not fully
1680
+ window.HTMLElement &&
1681
+ // also exclude jsdom
1682
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1675
1683
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1676
1684
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1677
1685
  replay.push((newHook) => {
@@ -2765,7 +2773,8 @@ var Vue = (function (exports) {
2765
2773
  const rawProps = toRaw(props);
2766
2774
  const { mode } = rawProps;
2767
2775
  // check mode
2768
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2776
+ if (mode &&
2777
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2769
2778
  warn$1(`invalid <transition> mode: ${mode}`);
2770
2779
  }
2771
2780
  // at this point children has a guaranteed length of 1.
@@ -3405,7 +3414,7 @@ var Vue = (function (exports) {
3405
3414
  }
3406
3415
  current = current.parent;
3407
3416
  }
3408
- hook();
3417
+ return hook();
3409
3418
  });
3410
3419
  injectHook(type, wrappedHook, target);
3411
3420
  // In addition to registering it on the target instance, we walk up the parent
@@ -4067,7 +4076,7 @@ var Vue = (function (exports) {
4067
4076
  }
4068
4077
  }
4069
4078
  else if (!isEmitListener(instance.emitsOptions, key)) {
4070
- if (value !== attrs[key]) {
4079
+ if (!(key in attrs) || value !== attrs[key]) {
4071
4080
  attrs[key] = value;
4072
4081
  hasAttrsChanged = true;
4073
4082
  }
@@ -4707,6 +4716,102 @@ var Vue = (function (exports) {
4707
4716
  };
4708
4717
  }
4709
4718
 
4719
+ /**
4720
+ * Function for handling a template ref
4721
+ */
4722
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
4723
+ if (isArray(rawRef)) {
4724
+ rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
4725
+ return;
4726
+ }
4727
+ if (isAsyncWrapper(vnode) && !isUnmount) {
4728
+ // when mounting async components, nothing needs to be done,
4729
+ // because the template ref is forwarded to inner component
4730
+ return;
4731
+ }
4732
+ const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
4733
+ ? getExposeProxy(vnode.component) || vnode.component.proxy
4734
+ : vnode.el;
4735
+ const value = isUnmount ? null : refValue;
4736
+ const { i: owner, r: ref } = rawRef;
4737
+ if (!owner) {
4738
+ warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
4739
+ `A vnode with ref must be created inside the render function.`);
4740
+ return;
4741
+ }
4742
+ const oldRef = oldRawRef && oldRawRef.r;
4743
+ const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
4744
+ const setupState = owner.setupState;
4745
+ // dynamic ref changed. unset old ref
4746
+ if (oldRef != null && oldRef !== ref) {
4747
+ if (isString(oldRef)) {
4748
+ refs[oldRef] = null;
4749
+ if (hasOwn(setupState, oldRef)) {
4750
+ setupState[oldRef] = null;
4751
+ }
4752
+ }
4753
+ else if (isRef(oldRef)) {
4754
+ oldRef.value = null;
4755
+ }
4756
+ }
4757
+ if (isFunction(ref)) {
4758
+ callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
4759
+ }
4760
+ else {
4761
+ const _isString = isString(ref);
4762
+ const _isRef = isRef(ref);
4763
+ if (_isString || _isRef) {
4764
+ const doSet = () => {
4765
+ if (rawRef.f) {
4766
+ const existing = _isString ? refs[ref] : ref.value;
4767
+ if (isUnmount) {
4768
+ isArray(existing) && remove(existing, refValue);
4769
+ }
4770
+ else {
4771
+ if (!isArray(existing)) {
4772
+ if (_isString) {
4773
+ refs[ref] = [refValue];
4774
+ }
4775
+ else {
4776
+ ref.value = [refValue];
4777
+ if (rawRef.k)
4778
+ refs[rawRef.k] = ref.value;
4779
+ }
4780
+ }
4781
+ else if (!existing.includes(refValue)) {
4782
+ existing.push(refValue);
4783
+ }
4784
+ }
4785
+ }
4786
+ else if (_isString) {
4787
+ refs[ref] = value;
4788
+ if (hasOwn(setupState, ref)) {
4789
+ setupState[ref] = value;
4790
+ }
4791
+ }
4792
+ else if (isRef(ref)) {
4793
+ ref.value = value;
4794
+ if (rawRef.k)
4795
+ refs[rawRef.k] = value;
4796
+ }
4797
+ else {
4798
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
4799
+ }
4800
+ };
4801
+ if (value) {
4802
+ doSet.id = -1;
4803
+ queuePostRenderEffect(doSet, parentSuspense);
4804
+ }
4805
+ else {
4806
+ doSet();
4807
+ }
4808
+ }
4809
+ else {
4810
+ warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
4811
+ }
4812
+ }
4813
+ }
4814
+
4710
4815
  let hasMismatch = false;
4711
4816
  const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
4712
4817
  const isComment = (node) => node.nodeType === 8 /* COMMENT */;
@@ -5339,12 +5444,15 @@ var Vue = (function (exports) {
5339
5444
  const oldProps = n1.props || EMPTY_OBJ;
5340
5445
  const newProps = n2.props || EMPTY_OBJ;
5341
5446
  let vnodeHook;
5447
+ // disable recurse in beforeUpdate hooks
5448
+ parentComponent && toggleRecurse(parentComponent, false);
5342
5449
  if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
5343
5450
  invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
5344
5451
  }
5345
5452
  if (dirs) {
5346
5453
  invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
5347
5454
  }
5455
+ parentComponent && toggleRecurse(parentComponent, true);
5348
5456
  if (isHmrUpdating) {
5349
5457
  // HMR updated, force full diff
5350
5458
  patchFlag = 0;
@@ -5624,7 +5732,7 @@ var Vue = (function (exports) {
5624
5732
  const { el, props } = initialVNode;
5625
5733
  const { bm, m, parent } = instance;
5626
5734
  const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
5627
- effect.allowRecurse = false;
5735
+ toggleRecurse(instance, false);
5628
5736
  // beforeMount hook
5629
5737
  if (bm) {
5630
5738
  invokeArrayFns(bm);
@@ -5634,7 +5742,7 @@ var Vue = (function (exports) {
5634
5742
  (vnodeHook = props && props.onVnodeBeforeMount)) {
5635
5743
  invokeVNodeHook(vnodeHook, parent, initialVNode);
5636
5744
  }
5637
- effect.allowRecurse = true;
5745
+ toggleRecurse(instance, true);
5638
5746
  if (el && hydrateNode) {
5639
5747
  // vnode has adopted host node - perform hydration instead of mount.
5640
5748
  const hydrateSubTree = () => {
@@ -5716,7 +5824,7 @@ var Vue = (function (exports) {
5716
5824
  pushWarningContext(next || instance.vnode);
5717
5825
  }
5718
5826
  // Disallow component effect recursion during pre-lifecycle hooks.
5719
- effect.allowRecurse = false;
5827
+ toggleRecurse(instance, false);
5720
5828
  if (next) {
5721
5829
  next.el = vnode.el;
5722
5830
  updateComponentPreRender(instance, next, optimized);
@@ -5732,7 +5840,7 @@ var Vue = (function (exports) {
5732
5840
  if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
5733
5841
  invokeVNodeHook(vnodeHook, parent, next, vnode);
5734
5842
  }
5735
- effect.allowRecurse = true;
5843
+ toggleRecurse(instance, true);
5736
5844
  // render
5737
5845
  {
5738
5846
  startMeasure(instance, `render`);
@@ -5778,13 +5886,13 @@ var Vue = (function (exports) {
5778
5886
  }
5779
5887
  };
5780
5888
  // create reactive effect for rendering
5781
- const effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
5782
- );
5889
+ const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
5890
+ ));
5783
5891
  const update = (instance.update = effect.run.bind(effect));
5784
5892
  update.id = instance.uid;
5785
5893
  // allowRecurse
5786
5894
  // #1801, #2043 component render effects should allow recursive updates
5787
- effect.allowRecurse = update.allowRecurse = true;
5895
+ toggleRecurse(instance, true);
5788
5896
  {
5789
5897
  effect.onTrack = instance.rtc
5790
5898
  ? e => invokeArrayFns(instance.rtc, e)
@@ -6308,85 +6416,8 @@ var Vue = (function (exports) {
6308
6416
  createApp: createAppAPI(render, hydrate)
6309
6417
  };
6310
6418
  }
6311
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
6312
- if (isArray(rawRef)) {
6313
- rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
6314
- return;
6315
- }
6316
- if (isAsyncWrapper(vnode) && !isUnmount) {
6317
- // when mounting async components, nothing needs to be done,
6318
- // because the template ref is forwarded to inner component
6319
- return;
6320
- }
6321
- const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
6322
- ? getExposeProxy(vnode.component) || vnode.component.proxy
6323
- : vnode.el;
6324
- const value = isUnmount ? null : refValue;
6325
- const { i: owner, r: ref } = rawRef;
6326
- if (!owner) {
6327
- warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
6328
- `A vnode with ref must be created inside the render function.`);
6329
- return;
6330
- }
6331
- const oldRef = oldRawRef && oldRawRef.r;
6332
- const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
6333
- const setupState = owner.setupState;
6334
- // dynamic ref changed. unset old ref
6335
- if (oldRef != null && oldRef !== ref) {
6336
- if (isString(oldRef)) {
6337
- refs[oldRef] = null;
6338
- if (hasOwn(setupState, oldRef)) {
6339
- setupState[oldRef] = null;
6340
- }
6341
- }
6342
- else if (isRef(oldRef)) {
6343
- oldRef.value = null;
6344
- }
6345
- }
6346
- if (isString(ref)) {
6347
- const doSet = () => {
6348
- {
6349
- refs[ref] = value;
6350
- }
6351
- if (hasOwn(setupState, ref)) {
6352
- setupState[ref] = value;
6353
- }
6354
- };
6355
- // #1789: for non-null values, set them after render
6356
- // null values means this is unmount and it should not overwrite another
6357
- // ref with the same key
6358
- if (value) {
6359
- doSet.id = -1;
6360
- queuePostRenderEffect(doSet, parentSuspense);
6361
- }
6362
- else {
6363
- doSet();
6364
- }
6365
- }
6366
- else if (isRef(ref)) {
6367
- const doSet = () => {
6368
- ref.value = value;
6369
- };
6370
- if (value) {
6371
- doSet.id = -1;
6372
- queuePostRenderEffect(doSet, parentSuspense);
6373
- }
6374
- else {
6375
- doSet();
6376
- }
6377
- }
6378
- else if (isFunction(ref)) {
6379
- callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
6380
- }
6381
- else {
6382
- warn$1('Invalid template ref type:', value, `(${typeof value})`);
6383
- }
6384
- }
6385
- function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6386
- callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
6387
- vnode,
6388
- prevVNode
6389
- ]);
6419
+ function toggleRecurse({ effect, update }, allowed) {
6420
+ effect.allowRecurse = update.allowRecurse = allowed;
6390
6421
  }
6391
6422
  /**
6392
6423
  * #1156
@@ -6396,8 +6427,8 @@ var Vue = (function (exports) {
6396
6427
  *
6397
6428
  * #2080
6398
6429
  * Inside keyed `template` fragment static children, if a fragment is moved,
6399
- * the children will always moved so that need inherit el form previous nodes
6400
- * to ensure correct moved position.
6430
+ * the children will always be moved. Therefore, in order to ensure correct move
6431
+ * position, el should be inherited from previous nodes.
6401
6432
  */
6402
6433
  function traverseStaticChildren(n1, n2, shallow = false) {
6403
6434
  const ch1 = n1.children;
@@ -6845,10 +6876,10 @@ var Vue = (function (exports) {
6845
6876
  };
6846
6877
  const InternalObjectKey = `__vInternal`;
6847
6878
  const normalizeKey = ({ key }) => key != null ? key : null;
6848
- const normalizeRef = ({ ref }) => {
6879
+ const normalizeRef = ({ ref, ref_key, ref_for }) => {
6849
6880
  return (ref != null
6850
6881
  ? isString(ref) || isRef(ref) || isFunction(ref)
6851
- ? { i: currentRenderingInstance, r: ref }
6882
+ ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
6852
6883
  : ref
6853
6884
  : null);
6854
6885
  };
@@ -7177,7 +7208,8 @@ var Vue = (function (exports) {
7177
7208
  else if (isOn(key)) {
7178
7209
  const existing = ret[key];
7179
7210
  const incoming = toMerge[key];
7180
- if (existing !== incoming) {
7211
+ if (existing !== incoming &&
7212
+ !(isArray(existing) && existing.includes(incoming))) {
7181
7213
  ret[key] = existing
7182
7214
  ? [].concat(existing, incoming)
7183
7215
  : incoming;
@@ -7189,6 +7221,12 @@ var Vue = (function (exports) {
7189
7221
  }
7190
7222
  }
7191
7223
  return ret;
7224
+ }
7225
+ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7226
+ callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7227
+ vnode,
7228
+ prevVNode
7229
+ ]);
7192
7230
  }
7193
7231
 
7194
7232
  /**
@@ -7380,23 +7418,23 @@ var Vue = (function (exports) {
7380
7418
  const n = accessCache[key];
7381
7419
  if (n !== undefined) {
7382
7420
  switch (n) {
7383
- case 0 /* SETUP */:
7421
+ case 1 /* SETUP */:
7384
7422
  return setupState[key];
7385
- case 1 /* DATA */:
7423
+ case 2 /* DATA */:
7386
7424
  return data[key];
7387
- case 3 /* CONTEXT */:
7425
+ case 4 /* CONTEXT */:
7388
7426
  return ctx[key];
7389
- case 2 /* PROPS */:
7427
+ case 3 /* PROPS */:
7390
7428
  return props[key];
7391
7429
  // default: just fallthrough
7392
7430
  }
7393
7431
  }
7394
7432
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7395
- accessCache[key] = 0 /* SETUP */;
7433
+ accessCache[key] = 1 /* SETUP */;
7396
7434
  return setupState[key];
7397
7435
  }
7398
7436
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7399
- accessCache[key] = 1 /* DATA */;
7437
+ accessCache[key] = 2 /* DATA */;
7400
7438
  return data[key];
7401
7439
  }
7402
7440
  else if (
@@ -7404,15 +7442,15 @@ var Vue = (function (exports) {
7404
7442
  // props
7405
7443
  (normalizedProps = instance.propsOptions[0]) &&
7406
7444
  hasOwn(normalizedProps, key)) {
7407
- accessCache[key] = 2 /* PROPS */;
7445
+ accessCache[key] = 3 /* PROPS */;
7408
7446
  return props[key];
7409
7447
  }
7410
7448
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7411
- accessCache[key] = 3 /* CONTEXT */;
7449
+ accessCache[key] = 4 /* CONTEXT */;
7412
7450
  return ctx[key];
7413
7451
  }
7414
7452
  else if (shouldCacheAccess) {
7415
- accessCache[key] = 4 /* OTHER */;
7453
+ accessCache[key] = 0 /* OTHER */;
7416
7454
  }
7417
7455
  }
7418
7456
  const publicGetter = publicPropertiesMap[key];
@@ -7433,7 +7471,7 @@ var Vue = (function (exports) {
7433
7471
  }
7434
7472
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7435
7473
  // user may set custom properties to `this` that start with `$`
7436
- accessCache[key] = 3 /* CONTEXT */;
7474
+ accessCache[key] = 4 /* CONTEXT */;
7437
7475
  return ctx[key];
7438
7476
  }
7439
7477
  else if (
@@ -7494,7 +7532,7 @@ var Vue = (function (exports) {
7494
7532
  },
7495
7533
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7496
7534
  let normalizedProps;
7497
- return (accessCache[key] !== undefined ||
7535
+ return (!!accessCache[key] ||
7498
7536
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7499
7537
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7500
7538
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -7600,6 +7638,7 @@ var Vue = (function (exports) {
7600
7638
  root: null,
7601
7639
  next: null,
7602
7640
  subTree: null,
7641
+ effect: null,
7603
7642
  update: null,
7604
7643
  scope: new EffectScope(true /* detached */),
7605
7644
  render: null,
@@ -9036,7 +9075,7 @@ var Vue = (function (exports) {
9036
9075
  }
9037
9076
 
9038
9077
  // Core API ------------------------------------------------------------------
9039
- const version = "3.2.21";
9078
+ const version = "3.2.25";
9040
9079
  /**
9041
9080
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9042
9081
  * @internal
@@ -9269,12 +9308,19 @@ var Vue = (function (exports) {
9269
9308
  el[key] = value == null ? '' : value;
9270
9309
  return;
9271
9310
  }
9272
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9311
+ if (key === 'value' &&
9312
+ el.tagName !== 'PROGRESS' &&
9313
+ // custom elements may use _value internally
9314
+ !el.tagName.includes('-')) {
9273
9315
  // store value as _value as well since
9274
9316
  // non-string values will be stringified.
9275
9317
  el._value = value;
9276
9318
  const newValue = value == null ? '' : value;
9277
- if (el.value !== newValue) {
9319
+ if (el.value !== newValue ||
9320
+ // #4956: always set for OPTION elements because its value falls back to
9321
+ // textContent if no value attribute is present. And setting .value for
9322
+ // OPTION has no side effect
9323
+ el.tagName === 'OPTION') {
9278
9324
  el.value = newValue;
9279
9325
  }
9280
9326
  if (value == null) {
@@ -9660,7 +9706,7 @@ var Vue = (function (exports) {
9660
9706
  // HMR
9661
9707
  {
9662
9708
  instance.ceReload = newStyles => {
9663
- // alawys reset styles
9709
+ // always reset styles
9664
9710
  if (this._styles) {
9665
9711
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
9666
9712
  this._styles.length = 0;
@@ -11125,12 +11171,12 @@ var Vue = (function (exports) {
11125
11171
  }
11126
11172
  else if (p.name === 'bind' &&
11127
11173
  (p.exp || allowEmpty) &&
11128
- isBindKey(p.arg, name)) {
11174
+ isStaticArgOf(p.arg, name)) {
11129
11175
  return p;
11130
11176
  }
11131
11177
  }
11132
11178
  }
11133
- function isBindKey(arg, name) {
11179
+ function isStaticArgOf(arg, name) {
11134
11180
  return !!(arg && isStaticExp(arg) && arg.content === name);
11135
11181
  }
11136
11182
  function hasDynamicKeyVBind(node) {
@@ -11173,7 +11219,6 @@ var Vue = (function (exports) {
11173
11219
  }
11174
11220
  function injectProp(node, prop, context) {
11175
11221
  let propsWithInjection;
11176
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11177
11222
  /**
11178
11223
  * 1. mergeProps(...)
11179
11224
  * 2. toHandlers(...)
@@ -11182,7 +11227,7 @@ var Vue = (function (exports) {
11182
11227
  *
11183
11228
  * we need to get the real props before normalization
11184
11229
  */
11185
- let props = originalProps;
11230
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11186
11231
  let callPath = [];
11187
11232
  let parentCall;
11188
11233
  if (props &&
@@ -11321,11 +11366,6 @@ var Vue = (function (exports) {
11321
11366
  `data source.`,
11322
11367
  link: `https://v3.vuejs.org/guide/migration/v-if-v-for.html`
11323
11368
  },
11324
- ["COMPILER_V_FOR_REF" /* COMPILER_V_FOR_REF */]: {
11325
- message: `Ref usage on v-for no longer creates array ref values in Vue 3. ` +
11326
- `Consider using function refs or refactor to avoid ref usage altogether.`,
11327
- link: `https://v3.vuejs.org/guide/migration/array-refs.html`
11328
- },
11329
11369
  ["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
11330
11370
  message: `<template> with no special directives will render as a native template ` +
11331
11371
  `element instead of its inner content in Vue 3.`
@@ -11798,7 +11838,7 @@ var Vue = (function (exports) {
11798
11838
  else if (
11799
11839
  // :is on plain element - only treat as component in compat mode
11800
11840
  p.name === 'bind' &&
11801
- isBindKey(p.arg, 'is') &&
11841
+ isStaticArgOf(p.arg, 'is') &&
11802
11842
  false &&
11803
11843
  checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
11804
11844
  return true;
@@ -12147,15 +12187,6 @@ var Vue = (function (exports) {
12147
12187
  !isSlotOutlet(child));
12148
12188
  }
12149
12189
  function walk(node, context, doNotHoistNode = false) {
12150
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
12151
- // static bindings with expressions. These expressions are guaranteed to be
12152
- // constant so they are still eligible for hoisting, but they are only
12153
- // available at runtime and therefore cannot be evaluated ahead of time.
12154
- // This is only a concern for pre-stringification (via transformHoist by
12155
- // @vue/compiler-dom), but doing it here allows us to perform only one full
12156
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
12157
- // stringification threshold is met.
12158
- let canStringify = true;
12159
12190
  const { children } = node;
12160
12191
  const originalCount = children.length;
12161
12192
  let hoistedCount = 0;
@@ -12168,9 +12199,6 @@ var Vue = (function (exports) {
12168
12199
  ? 0 /* NOT_CONSTANT */
12169
12200
  : getConstantType(child, context);
12170
12201
  if (constantType > 0 /* NOT_CONSTANT */) {
12171
- if (constantType < 3 /* CAN_STRINGIFY */) {
12172
- canStringify = false;
12173
- }
12174
12202
  if (constantType >= 2 /* CAN_HOIST */) {
12175
12203
  child.codegenNode.patchFlag =
12176
12204
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -12201,17 +12229,10 @@ var Vue = (function (exports) {
12201
12229
  }
12202
12230
  }
12203
12231
  }
12204
- else if (child.type === 12 /* TEXT_CALL */) {
12205
- const contentType = getConstantType(child.content, context);
12206
- if (contentType > 0) {
12207
- if (contentType < 3 /* CAN_STRINGIFY */) {
12208
- canStringify = false;
12209
- }
12210
- if (contentType >= 2 /* CAN_HOIST */) {
12211
- child.codegenNode = context.hoist(child.codegenNode);
12212
- hoistedCount++;
12213
- }
12214
- }
12232
+ else if (child.type === 12 /* TEXT_CALL */ &&
12233
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
12234
+ child.codegenNode = context.hoist(child.codegenNode);
12235
+ hoistedCount++;
12215
12236
  }
12216
12237
  // walk further
12217
12238
  if (child.type === 1 /* ELEMENT */) {
@@ -12235,7 +12256,7 @@ var Vue = (function (exports) {
12235
12256
  }
12236
12257
  }
12237
12258
  }
12238
- if (canStringify && hoistedCount && context.transformHoist) {
12259
+ if (hoistedCount && context.transformHoist) {
12239
12260
  context.transformHoist(children, context, node);
12240
12261
  }
12241
12262
  // all children were hoisted - the entire children array is hoistable.
@@ -12264,6 +12285,11 @@ var Vue = (function (exports) {
12264
12285
  if (codegenNode.type !== 13 /* VNODE_CALL */) {
12265
12286
  return 0 /* NOT_CONSTANT */;
12266
12287
  }
12288
+ if (codegenNode.isBlock &&
12289
+ node.tag !== 'svg' &&
12290
+ node.tag !== 'foreignObject') {
12291
+ return 0 /* NOT_CONSTANT */;
12292
+ }
12267
12293
  const flag = getPatchFlag(codegenNode);
12268
12294
  if (!flag) {
12269
12295
  let returnType = 3 /* CAN_STRINGIFY */;
@@ -12400,7 +12426,7 @@ var Vue = (function (exports) {
12400
12426
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
12401
12427
  // some helper calls can be hoisted,
12402
12428
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
12403
- // in this case we need to respect the ConstantType of the helper's argments
12429
+ // in this case we need to respect the ConstantType of the helper's arguments
12404
12430
  valueType = getConstantTypeOfHelperCall(value, context);
12405
12431
  }
12406
12432
  else {
@@ -14048,10 +14074,7 @@ var Vue = (function (exports) {
14048
14074
  // updates inside get proper isSVG flag at runtime. (#639, #643)
14049
14075
  // This is technically web-specific, but splitting the logic out of core
14050
14076
  // leads to too much unnecessary complexity.
14051
- (tag === 'svg' ||
14052
- tag === 'foreignObject' ||
14053
- // #938: elements with dynamic keys should be forced into blocks
14054
- findProp(node, 'key', true)));
14077
+ (tag === 'svg' || tag === 'foreignObject'));
14055
14078
  // props
14056
14079
  if (props.length > 0) {
14057
14080
  const propsBuildResult = buildProps(node, context);
@@ -14063,6 +14086,9 @@ var Vue = (function (exports) {
14063
14086
  directives && directives.length
14064
14087
  ? createArrayExpression(directives.map(dir => buildDirectiveArgs(dir, context)))
14065
14088
  : undefined;
14089
+ if (propsBuildResult.shouldUseBlock) {
14090
+ shouldUseBlock = true;
14091
+ }
14066
14092
  }
14067
14093
  // children
14068
14094
  if (node.children.length > 0) {
@@ -14191,11 +14217,13 @@ var Vue = (function (exports) {
14191
14217
  return toValidAssetId(tag, `component`);
14192
14218
  }
14193
14219
  function buildProps(node, context, props = node.props, ssr = false) {
14194
- const { tag, loc: elementLoc } = node;
14220
+ const { tag, loc: elementLoc, children } = node;
14195
14221
  const isComponent = node.tagType === 1 /* COMPONENT */;
14196
14222
  let properties = [];
14197
14223
  const mergeArgs = [];
14198
14224
  const runtimeDirectives = [];
14225
+ const hasChildren = children.length > 0;
14226
+ let shouldUseBlock = false;
14199
14227
  // patchFlag analysis
14200
14228
  let patchFlag = 0;
14201
14229
  let hasRef = false;
@@ -14258,9 +14286,12 @@ var Vue = (function (exports) {
14258
14286
  const prop = props[i];
14259
14287
  if (prop.type === 6 /* ATTRIBUTE */) {
14260
14288
  const { loc, name, value } = prop;
14261
- let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
14289
+ let isStatic = true;
14262
14290
  if (name === 'ref') {
14263
14291
  hasRef = true;
14292
+ if (context.scopes.vFor > 0) {
14293
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
14294
+ }
14264
14295
  }
14265
14296
  // skip is on <component>, or is="vue:xxx"
14266
14297
  if (name === 'is' &&
@@ -14269,7 +14300,7 @@ var Vue = (function (exports) {
14269
14300
  (false ))) {
14270
14301
  continue;
14271
14302
  }
14272
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
14303
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
14273
14304
  }
14274
14305
  else {
14275
14306
  // directives
@@ -14290,7 +14321,7 @@ var Vue = (function (exports) {
14290
14321
  // skip v-is and :is on <component>
14291
14322
  if (name === 'is' ||
14292
14323
  (isVBind &&
14293
- isBindKey(arg, 'is') &&
14324
+ isStaticArgOf(arg, 'is') &&
14294
14325
  (isComponentTag(tag) ||
14295
14326
  (false )))) {
14296
14327
  continue;
@@ -14299,6 +14330,17 @@ var Vue = (function (exports) {
14299
14330
  if (isVOn && ssr) {
14300
14331
  continue;
14301
14332
  }
14333
+ if (
14334
+ // #938: elements with dynamic keys should be forced into blocks
14335
+ (isVBind && isStaticArgOf(arg, 'key')) ||
14336
+ // inline before-update hooks need to force block so that it is invoked
14337
+ // before children
14338
+ (isVOn && hasChildren && isStaticArgOf(arg, 'vue:before-update'))) {
14339
+ shouldUseBlock = true;
14340
+ }
14341
+ if (isVBind && isStaticArgOf(arg, 'ref') && context.scopes.vFor > 0) {
14342
+ properties.push(createObjectProperty(createSimpleExpression('ref_for', true), createSimpleExpression('true')));
14343
+ }
14302
14344
  // special case for v-bind and v-on with no argument
14303
14345
  if (!arg && (isVBind || isVOn)) {
14304
14346
  hasDynamicKeys = true;
@@ -14343,6 +14385,11 @@ var Vue = (function (exports) {
14343
14385
  else {
14344
14386
  // no built-in transform, this is a user custom directive.
14345
14387
  runtimeDirectives.push(prop);
14388
+ // custom dirs may use beforeUpdate so they need to force blocks
14389
+ // to ensure before-update gets called before children update
14390
+ if (hasChildren) {
14391
+ shouldUseBlock = true;
14392
+ }
14346
14393
  }
14347
14394
  }
14348
14395
  }
@@ -14381,7 +14428,8 @@ var Vue = (function (exports) {
14381
14428
  patchFlag |= 32 /* HYDRATE_EVENTS */;
14382
14429
  }
14383
14430
  }
14384
- if ((patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
14431
+ if (!shouldUseBlock &&
14432
+ (patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
14385
14433
  (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
14386
14434
  patchFlag |= 512 /* NEED_PATCH */;
14387
14435
  }
@@ -14448,7 +14496,8 @@ var Vue = (function (exports) {
14448
14496
  props: propsExpression,
14449
14497
  directives: runtimeDirectives,
14450
14498
  patchFlag,
14451
- dynamicPropNames
14499
+ dynamicPropNames,
14500
+ shouldUseBlock
14452
14501
  };
14453
14502
  }
14454
14503
  // Dedupe props in an object literal.
@@ -14536,7 +14585,7 @@ var Vue = (function (exports) {
14536
14585
  return propsNamesString + `]`;
14537
14586
  }
14538
14587
  function isComponentTag(tag) {
14539
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
14588
+ return tag === 'component' || tag === 'Component';
14540
14589
  }
14541
14590
 
14542
14591
  const transformSlotOutlet = (node, context) => {
@@ -14584,7 +14633,7 @@ var Vue = (function (exports) {
14584
14633
  }
14585
14634
  }
14586
14635
  else {
14587
- if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
14636
+ if (p.name === 'bind' && isStaticArgOf(p.arg, 'name')) {
14588
14637
  if (p.exp)
14589
14638
  slotName = p.exp;
14590
14639
  }
@@ -14618,7 +14667,11 @@ var Vue = (function (exports) {
14618
14667
  let eventName;
14619
14668
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
14620
14669
  if (arg.isStatic) {
14621
- const rawName = arg.content;
14670
+ let rawName = arg.content;
14671
+ // TODO deprecate @vnodeXXX usage
14672
+ if (rawName.startsWith('vue:')) {
14673
+ rawName = `vnode-${rawName.slice(4)}`;
14674
+ }
14622
14675
  // for all event listeners, auto convert it to camelCase. See issue #2249
14623
14676
  eventName = createSimpleExpression(toHandlerKey(camelize(rawName)), true, arg.loc);
14624
14677
  }