@vue/compat 3.2.20 → 3.2.24

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.
@@ -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)) {
@@ -1664,22 +1664,33 @@ function tryWrap(fn) {
1664
1664
 
1665
1665
  let devtools;
1666
1666
  let buffer = [];
1667
+ let devtoolsNotInstalled = false;
1667
1668
  function emit(event, ...args) {
1668
1669
  if (devtools) {
1669
1670
  devtools.emit(event, ...args);
1670
1671
  }
1671
- else {
1672
+ else if (!devtoolsNotInstalled) {
1672
1673
  buffer.push({ event, args });
1673
1674
  }
1674
1675
  }
1675
1676
  function setDevtoolsHook(hook, target) {
1677
+ var _a, _b;
1676
1678
  devtools = hook;
1677
1679
  if (devtools) {
1678
1680
  devtools.enabled = true;
1679
1681
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1680
1682
  buffer = [];
1681
1683
  }
1682
- else {
1684
+ else if (
1685
+ // handle late devtools injection - only do this if we are in an actual
1686
+ // browser environment to avoid the timer handle stalling test runner exit
1687
+ // (#4815)
1688
+ // eslint-disable-next-line no-restricted-globals
1689
+ typeof window !== 'undefined' &&
1690
+ // some envs mock window but not fully
1691
+ window.HTMLElement &&
1692
+ // also exclude jsdom
1693
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1683
1694
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1684
1695
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1685
1696
  replay.push((newHook) => {
@@ -1688,9 +1699,18 @@ function setDevtoolsHook(hook, target) {
1688
1699
  // clear buffer after 3s - the user probably doesn't have devtools installed
1689
1700
  // at all, and keeping the buffer will cause memory leaks (#4738)
1690
1701
  setTimeout(() => {
1691
- buffer = [];
1702
+ if (!devtools) {
1703
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1704
+ devtoolsNotInstalled = true;
1705
+ buffer = [];
1706
+ }
1692
1707
  }, 3000);
1693
1708
  }
1709
+ else {
1710
+ // non-browser env, assume not installed
1711
+ devtoolsNotInstalled = true;
1712
+ buffer = [];
1713
+ }
1694
1714
  }
1695
1715
  function devtoolsInitApp(app, version) {
1696
1716
  emit("app:init" /* APP_INIT */, app, version, {
@@ -3308,7 +3328,9 @@ const BaseTransitionImpl = {
3308
3328
  const rawProps = toRaw(props);
3309
3329
  const { mode } = rawProps;
3310
3330
  // check mode
3311
- if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3331
+ if ((process.env.NODE_ENV !== 'production') &&
3332
+ mode &&
3333
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3312
3334
  warn$1(`invalid <transition> mode: ${mode}`);
3313
3335
  }
3314
3336
  // at this point children has a guaranteed length of 1.
@@ -3954,7 +3976,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3954
3976
  }
3955
3977
  current = current.parent;
3956
3978
  }
3957
- hook();
3979
+ return hook();
3958
3980
  });
3959
3981
  injectHook(type, wrappedHook, target);
3960
3982
  // In addition to registering it on the target instance, we walk up the parent
@@ -4739,7 +4761,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4739
4761
  continue;
4740
4762
  }
4741
4763
  }
4742
- if (value !== attrs[key]) {
4764
+ if (!(key in attrs) || value !== attrs[key]) {
4743
4765
  attrs[key] = value;
4744
4766
  hasAttrsChanged = true;
4745
4767
  }
@@ -5187,7 +5209,7 @@ return withDirectives(h(comp), [
5187
5209
  [bar, this.y]
5188
5210
  ])
5189
5211
  */
5190
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
5212
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5191
5213
  function validateDirectiveName(name) {
5192
5214
  if (isBuiltInDirective(name)) {
5193
5215
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5322,7 +5344,7 @@ function createCompatVue(createApp, createSingletonApp) {
5322
5344
  return vm;
5323
5345
  }
5324
5346
  }
5325
- Vue.version = "3.2.20";
5347
+ Vue.version = "3.2.24";
5326
5348
  Vue.config = singletonApp.config;
5327
5349
  Vue.use = (p, ...options) => {
5328
5350
  if (p && isFunction(p.install)) {
@@ -6819,7 +6841,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6819
6841
  }
6820
6842
  };
6821
6843
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6822
- // 2.x compat may pre-creaate the component instance before actually
6844
+ // 2.x compat may pre-create the component instance before actually
6823
6845
  // mounting
6824
6846
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
6825
6847
  const instance = compatMountInstance ||
@@ -7699,8 +7721,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7699
7721
  *
7700
7722
  * #2080
7701
7723
  * Inside keyed `template` fragment static children, if a fragment is moved,
7702
- * the children will always moved so that need inherit el form previous nodes
7703
- * to ensure correct moved position.
7724
+ * the children will always be moved. Therefore, in order to ensure correct move
7725
+ * position, el should be inherited from previous nodes.
7704
7726
  */
7705
7727
  function traverseStaticChildren(n1, n2, shallow = false) {
7706
7728
  const ch1 = n1.children;
@@ -8342,6 +8364,7 @@ function convertLegacyFunctionalComponent(comp) {
8342
8364
  };
8343
8365
  Func.props = comp.props;
8344
8366
  Func.displayName = comp.name;
8367
+ Func.compatConfig = comp.compatConfig;
8345
8368
  // v2 functional components do not inherit attrs
8346
8369
  Func.inheritAttrs = false;
8347
8370
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8832,7 +8855,8 @@ function mergeProps(...args) {
8832
8855
  else if (isOn(key)) {
8833
8856
  const existing = ret[key];
8834
8857
  const incoming = toMerge[key];
8835
- if (existing !== incoming) {
8858
+ if (existing !== incoming &&
8859
+ !(isArray(existing) && existing.includes(incoming))) {
8836
8860
  ret[key] = existing
8837
8861
  ? [].concat(existing, incoming)
8838
8862
  : incoming;
@@ -9277,23 +9301,23 @@ const PublicInstanceProxyHandlers = {
9277
9301
  const n = accessCache[key];
9278
9302
  if (n !== undefined) {
9279
9303
  switch (n) {
9280
- case 0 /* SETUP */:
9304
+ case 1 /* SETUP */:
9281
9305
  return setupState[key];
9282
- case 1 /* DATA */:
9306
+ case 2 /* DATA */:
9283
9307
  return data[key];
9284
- case 3 /* CONTEXT */:
9308
+ case 4 /* CONTEXT */:
9285
9309
  return ctx[key];
9286
- case 2 /* PROPS */:
9310
+ case 3 /* PROPS */:
9287
9311
  return props[key];
9288
9312
  // default: just fallthrough
9289
9313
  }
9290
9314
  }
9291
9315
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9292
- accessCache[key] = 0 /* SETUP */;
9316
+ accessCache[key] = 1 /* SETUP */;
9293
9317
  return setupState[key];
9294
9318
  }
9295
9319
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9296
- accessCache[key] = 1 /* DATA */;
9320
+ accessCache[key] = 2 /* DATA */;
9297
9321
  return data[key];
9298
9322
  }
9299
9323
  else if (
@@ -9301,15 +9325,15 @@ const PublicInstanceProxyHandlers = {
9301
9325
  // props
9302
9326
  (normalizedProps = instance.propsOptions[0]) &&
9303
9327
  hasOwn(normalizedProps, key)) {
9304
- accessCache[key] = 2 /* PROPS */;
9328
+ accessCache[key] = 3 /* PROPS */;
9305
9329
  return props[key];
9306
9330
  }
9307
9331
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9308
- accessCache[key] = 3 /* CONTEXT */;
9332
+ accessCache[key] = 4 /* CONTEXT */;
9309
9333
  return ctx[key];
9310
9334
  }
9311
9335
  else if (!__VUE_OPTIONS_API__ || shouldCacheAccess) {
9312
- accessCache[key] = 4 /* OTHER */;
9336
+ accessCache[key] = 0 /* OTHER */;
9313
9337
  }
9314
9338
  }
9315
9339
  const publicGetter = publicPropertiesMap[key];
@@ -9330,7 +9354,7 @@ const PublicInstanceProxyHandlers = {
9330
9354
  }
9331
9355
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9332
9356
  // user may set custom properties to `this` that start with `$`
9333
- accessCache[key] = 3 /* CONTEXT */;
9357
+ accessCache[key] = 4 /* CONTEXT */;
9334
9358
  return ctx[key];
9335
9359
  }
9336
9360
  else if (
@@ -9401,7 +9425,7 @@ const PublicInstanceProxyHandlers = {
9401
9425
  },
9402
9426
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9403
9427
  let normalizedProps;
9404
- return (accessCache[key] !== undefined ||
9428
+ return (!!accessCache[key] ||
9405
9429
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9406
9430
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9407
9431
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -11026,7 +11050,7 @@ function isMemoSame(cached, memo) {
11026
11050
  }
11027
11051
 
11028
11052
  // Core API ------------------------------------------------------------------
11029
- const version = "3.2.20";
11053
+ const version = "3.2.24";
11030
11054
  const _ssrUtils = {
11031
11055
  createComponentInstance,
11032
11056
  setupComponent,
@@ -11163,16 +11187,8 @@ function patchClass(el, value, isSVG) {
11163
11187
 
11164
11188
  function patchStyle(el, prev, next) {
11165
11189
  const style = el.style;
11166
- const currentDisplay = style.display;
11167
- if (!next) {
11168
- el.removeAttribute('style');
11169
- }
11170
- else if (isString(next)) {
11171
- if (prev !== next) {
11172
- style.cssText = next;
11173
- }
11174
- }
11175
- else {
11190
+ const isCssString = isString(next);
11191
+ if (next && !isCssString) {
11176
11192
  for (const key in next) {
11177
11193
  setStyle(style, key, next[key]);
11178
11194
  }
@@ -11184,11 +11200,22 @@ function patchStyle(el, prev, next) {
11184
11200
  }
11185
11201
  }
11186
11202
  }
11187
- // indicates that the `display` of the element is controlled by `v-show`,
11188
- // so we always keep the current `display` value regardless of the `style` value,
11189
- // thus handing over control to `v-show`.
11190
- if ('_vod' in el) {
11191
- style.display = currentDisplay;
11203
+ else {
11204
+ const currentDisplay = style.display;
11205
+ if (isCssString) {
11206
+ if (prev !== next) {
11207
+ style.cssText = next;
11208
+ }
11209
+ }
11210
+ else if (prev) {
11211
+ el.removeAttribute('style');
11212
+ }
11213
+ // indicates that the `display` of the element is controlled by `v-show`,
11214
+ // so we always keep the current `display` value regardless of the `style`
11215
+ // value, thus handing over control to `v-show`.
11216
+ if ('_vod' in el) {
11217
+ style.display = currentDisplay;
11218
+ }
11192
11219
  }
11193
11220
  }
11194
11221
  const importantRE = /\s*!important$/;
@@ -11298,12 +11325,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11298
11325
  el[key] = value == null ? '' : value;
11299
11326
  return;
11300
11327
  }
11301
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11328
+ if (key === 'value' &&
11329
+ el.tagName !== 'PROGRESS' &&
11330
+ // custom elements may use _value internally
11331
+ !el.tagName.includes('-')) {
11302
11332
  // store value as _value as well since
11303
11333
  // non-string values will be stringified.
11304
11334
  el._value = value;
11305
11335
  const newValue = value == null ? '' : value;
11306
- if (el.value !== newValue) {
11336
+ if (el.value !== newValue ||
11337
+ // #4956: always set for OPTION elements because its value falls back to
11338
+ // textContent if no value attribute is present. And setting .value for
11339
+ // OPTION has no side effect
11340
+ el.tagName === 'OPTION') {
11307
11341
  el.value = newValue;
11308
11342
  }
11309
11343
  if (value == null) {
@@ -11572,22 +11606,11 @@ class VueElement extends BaseClass {
11572
11606
  }
11573
11607
  this.attachShadow({ mode: 'open' });
11574
11608
  }
11575
- // set initial attrs
11576
- for (let i = 0; i < this.attributes.length; i++) {
11577
- this._setAttr(this.attributes[i].name);
11578
- }
11579
- // watch future attr changes
11580
- new MutationObserver(mutations => {
11581
- for (const m of mutations) {
11582
- this._setAttr(m.attributeName);
11583
- }
11584
- }).observe(this, { attributes: true });
11585
11609
  }
11586
11610
  connectedCallback() {
11587
11611
  this._connected = true;
11588
11612
  if (!this._instance) {
11589
11613
  this._resolveDef();
11590
- this._update();
11591
11614
  }
11592
11615
  }
11593
11616
  disconnectedCallback() {
@@ -11606,8 +11629,18 @@ class VueElement extends BaseClass {
11606
11629
  if (this._resolved) {
11607
11630
  return;
11608
11631
  }
11632
+ this._resolved = true;
11633
+ // set initial attrs
11634
+ for (let i = 0; i < this.attributes.length; i++) {
11635
+ this._setAttr(this.attributes[i].name);
11636
+ }
11637
+ // watch future attr changes
11638
+ new MutationObserver(mutations => {
11639
+ for (const m of mutations) {
11640
+ this._setAttr(m.attributeName);
11641
+ }
11642
+ }).observe(this, { attributes: true });
11609
11643
  const resolve = (def) => {
11610
- this._resolved = true;
11611
11644
  const { props, styles } = def;
11612
11645
  const hasOptions = !isArray(props);
11613
11646
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -11622,14 +11655,11 @@ class VueElement extends BaseClass {
11622
11655
  }
11623
11656
  }
11624
11657
  }
11625
- if (numberProps) {
11626
- this._numberProps = numberProps;
11627
- this._update();
11628
- }
11658
+ this._numberProps = numberProps;
11629
11659
  // check if there are props set pre-upgrade or connect
11630
11660
  for (const key of Object.keys(this)) {
11631
11661
  if (key[0] !== '_') {
11632
- this._setProp(key, this[key]);
11662
+ this._setProp(key, this[key], true, false);
11633
11663
  }
11634
11664
  }
11635
11665
  // defining getter/setters on prototype
@@ -11643,7 +11673,10 @@ class VueElement extends BaseClass {
11643
11673
  }
11644
11674
  });
11645
11675
  }
11676
+ // apply CSS
11646
11677
  this._applyStyles(styles);
11678
+ // initial render
11679
+ this._update();
11647
11680
  };
11648
11681
  const asyncDef = this._def.__asyncLoader;
11649
11682
  if (asyncDef) {
@@ -11669,10 +11702,10 @@ class VueElement extends BaseClass {
11669
11702
  /**
11670
11703
  * @internal
11671
11704
  */
11672
- _setProp(key, val, shouldReflect = true) {
11705
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11673
11706
  if (val !== this._props[key]) {
11674
11707
  this._props[key] = val;
11675
- if (this._instance) {
11708
+ if (shouldUpdate && this._instance) {
11676
11709
  this._update();
11677
11710
  }
11678
11711
  // reflect
@@ -11701,7 +11734,7 @@ class VueElement extends BaseClass {
11701
11734
  // HMR
11702
11735
  if ((process.env.NODE_ENV !== 'production')) {
11703
11736
  instance.ceReload = newStyles => {
11704
- // alawys reset styles
11737
+ // always reset styles
11705
11738
  if (this._styles) {
11706
11739
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11707
11740
  this._styles.length = 0;
@@ -13529,7 +13562,6 @@ function getUnnormalizedProps(props, callPath = []) {
13529
13562
  }
13530
13563
  function injectProp(node, prop, context) {
13531
13564
  let propsWithInjection;
13532
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13533
13565
  /**
13534
13566
  * 1. mergeProps(...)
13535
13567
  * 2. toHandlers(...)
@@ -13538,7 +13570,7 @@ function injectProp(node, prop, context) {
13538
13570
  *
13539
13571
  * we need to get the real props before normalization
13540
13572
  */
13541
- let props = originalProps;
13573
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13542
13574
  let callPath = [];
13543
13575
  let parentCall;
13544
13576
  if (props &&
@@ -14136,6 +14168,7 @@ function parseTag(context, type, parent) {
14136
14168
  }
14137
14169
  if (hasIf && hasFor) {
14138
14170
  warnDeprecation$1("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
14171
+ break;
14139
14172
  }
14140
14173
  }
14141
14174
  }
@@ -14560,15 +14593,6 @@ function isSingleElementRoot(root, child) {
14560
14593
  !isSlotOutlet(child));
14561
14594
  }
14562
14595
  function walk$1(node, context, doNotHoistNode = false) {
14563
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14564
- // static bindings with expressions. These expressions are guaranteed to be
14565
- // constant so they are still eligible for hoisting, but they are only
14566
- // available at runtime and therefore cannot be evaluated ahead of time.
14567
- // This is only a concern for pre-stringification (via transformHoist by
14568
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14569
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14570
- // stringification threshold is met.
14571
- let canStringify = true;
14572
14596
  const { children } = node;
14573
14597
  const originalCount = children.length;
14574
14598
  let hoistedCount = 0;
@@ -14581,9 +14605,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14581
14605
  ? 0 /* NOT_CONSTANT */
14582
14606
  : getConstantType(child, context);
14583
14607
  if (constantType > 0 /* NOT_CONSTANT */) {
14584
- if (constantType < 3 /* CAN_STRINGIFY */) {
14585
- canStringify = false;
14586
- }
14587
14608
  if (constantType >= 2 /* CAN_HOIST */) {
14588
14609
  child.codegenNode.patchFlag =
14589
14610
  -1 /* HOISTED */ + ((process.env.NODE_ENV !== 'production') ? ` /* HOISTED */` : ``);
@@ -14614,17 +14635,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14614
14635
  }
14615
14636
  }
14616
14637
  }
14617
- else if (child.type === 12 /* TEXT_CALL */) {
14618
- const contentType = getConstantType(child.content, context);
14619
- if (contentType > 0) {
14620
- if (contentType < 3 /* CAN_STRINGIFY */) {
14621
- canStringify = false;
14622
- }
14623
- if (contentType >= 2 /* CAN_HOIST */) {
14624
- child.codegenNode = context.hoist(child.codegenNode);
14625
- hoistedCount++;
14626
- }
14627
- }
14638
+ else if (child.type === 12 /* TEXT_CALL */ &&
14639
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14640
+ child.codegenNode = context.hoist(child.codegenNode);
14641
+ hoistedCount++;
14628
14642
  }
14629
14643
  // walk further
14630
14644
  if (child.type === 1 /* ELEMENT */) {
@@ -14648,7 +14662,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14648
14662
  }
14649
14663
  }
14650
14664
  }
14651
- if (canStringify && hoistedCount && context.transformHoist) {
14665
+ if (hoistedCount && context.transformHoist) {
14652
14666
  context.transformHoist(children, context, node);
14653
14667
  }
14654
14668
  // all children were hoisted - the entire children array is hoistable.
@@ -17013,7 +17027,7 @@ function stringifyDynamicPropNames(props) {
17013
17027
  return propsNamesString + `]`;
17014
17028
  }
17015
17029
  function isComponentTag(tag) {
17016
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
17030
+ return tag === 'component' || tag === 'Component';
17017
17031
  }
17018
17032
 
17019
17033
  const transformSlotOutlet = (node, context) => {