@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.
@@ -530,7 +530,7 @@ const targetMap = new WeakMap();
530
530
  let effectTrackDepth = 0;
531
531
  let trackOpBit = 1;
532
532
  /**
533
- * The bitwise track markers support at most 30 levels op recursion.
533
+ * The bitwise track markers support at most 30 levels of recursion.
534
534
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
535
535
  * When recursion depth is greater, fall back to using a full cleanup.
536
536
  */
@@ -851,7 +851,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
851
851
  function createSetter(shallow = false) {
852
852
  return function set(target, key, value, receiver) {
853
853
  let oldValue = target[key];
854
- if (!shallow) {
854
+ if (!shallow && !isReadonly(value)) {
855
855
  value = toRaw(value);
856
856
  oldValue = toRaw(oldValue);
857
857
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1647,22 +1647,33 @@ function tryWrap(fn) {
1647
1647
 
1648
1648
  let devtools;
1649
1649
  let buffer = [];
1650
+ let devtoolsNotInstalled = false;
1650
1651
  function emit(event, ...args) {
1651
1652
  if (devtools) {
1652
1653
  devtools.emit(event, ...args);
1653
1654
  }
1654
- else {
1655
+ else if (!devtoolsNotInstalled) {
1655
1656
  buffer.push({ event, args });
1656
1657
  }
1657
1658
  }
1658
1659
  function setDevtoolsHook(hook, target) {
1660
+ var _a, _b;
1659
1661
  devtools = hook;
1660
1662
  if (devtools) {
1661
1663
  devtools.enabled = true;
1662
1664
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1663
1665
  buffer = [];
1664
1666
  }
1665
- else {
1667
+ else if (
1668
+ // handle late devtools injection - only do this if we are in an actual
1669
+ // browser environment to avoid the timer handle stalling test runner exit
1670
+ // (#4815)
1671
+ // eslint-disable-next-line no-restricted-globals
1672
+ typeof window !== 'undefined' &&
1673
+ // some envs mock window but not fully
1674
+ window.HTMLElement &&
1675
+ // also exclude jsdom
1676
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1666
1677
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1667
1678
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1668
1679
  replay.push((newHook) => {
@@ -1671,9 +1682,18 @@ function setDevtoolsHook(hook, target) {
1671
1682
  // clear buffer after 3s - the user probably doesn't have devtools installed
1672
1683
  // at all, and keeping the buffer will cause memory leaks (#4738)
1673
1684
  setTimeout(() => {
1674
- buffer = [];
1685
+ if (!devtools) {
1686
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1687
+ devtoolsNotInstalled = true;
1688
+ buffer = [];
1689
+ }
1675
1690
  }, 3000);
1676
1691
  }
1692
+ else {
1693
+ // non-browser env, assume not installed
1694
+ devtoolsNotInstalled = true;
1695
+ buffer = [];
1696
+ }
1677
1697
  }
1678
1698
  function devtoolsInitApp(app, version) {
1679
1699
  emit("app:init" /* APP_INIT */, app, version, {
@@ -3287,7 +3307,8 @@ const BaseTransitionImpl = {
3287
3307
  const rawProps = toRaw(props);
3288
3308
  const { mode } = rawProps;
3289
3309
  // check mode
3290
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3310
+ if (mode &&
3311
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3291
3312
  warn$1(`invalid <transition> mode: ${mode}`);
3292
3313
  }
3293
3314
  // at this point children has a guaranteed length of 1.
@@ -3933,7 +3954,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3933
3954
  }
3934
3955
  current = current.parent;
3935
3956
  }
3936
- hook();
3957
+ return hook();
3937
3958
  });
3938
3959
  injectHook(type, wrappedHook, target);
3939
3960
  // In addition to registering it on the target instance, we walk up the parent
@@ -4711,7 +4732,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4711
4732
  continue;
4712
4733
  }
4713
4734
  }
4714
- if (value !== attrs[key]) {
4735
+ if (!(key in attrs) || value !== attrs[key]) {
4715
4736
  attrs[key] = value;
4716
4737
  hasAttrsChanged = true;
4717
4738
  }
@@ -5157,7 +5178,7 @@ return withDirectives(h(comp), [
5157
5178
  [bar, this.y]
5158
5179
  ])
5159
5180
  */
5160
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
5181
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5161
5182
  function validateDirectiveName(name) {
5162
5183
  if (isBuiltInDirective(name)) {
5163
5184
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5292,7 +5313,7 @@ function createCompatVue(createApp, createSingletonApp) {
5292
5313
  return vm;
5293
5314
  }
5294
5315
  }
5295
- Vue.version = "3.2.20";
5316
+ Vue.version = "3.2.24";
5296
5317
  Vue.config = singletonApp.config;
5297
5318
  Vue.use = (p, ...options) => {
5298
5319
  if (p && isFunction(p.install)) {
@@ -6738,7 +6759,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6738
6759
  }
6739
6760
  };
6740
6761
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6741
- // 2.x compat may pre-creaate the component instance before actually
6762
+ // 2.x compat may pre-create the component instance before actually
6742
6763
  // mounting
6743
6764
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
6744
6765
  const instance = compatMountInstance ||
@@ -7618,8 +7639,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7618
7639
  *
7619
7640
  * #2080
7620
7641
  * Inside keyed `template` fragment static children, if a fragment is moved,
7621
- * the children will always moved so that need inherit el form previous nodes
7622
- * to ensure correct moved position.
7642
+ * the children will always be moved. Therefore, in order to ensure correct move
7643
+ * position, el should be inherited from previous nodes.
7623
7644
  */
7624
7645
  function traverseStaticChildren(n1, n2, shallow = false) {
7625
7646
  const ch1 = n1.children;
@@ -8257,6 +8278,7 @@ function convertLegacyFunctionalComponent(comp) {
8257
8278
  };
8258
8279
  Func.props = comp.props;
8259
8280
  Func.displayName = comp.name;
8281
+ Func.compatConfig = comp.compatConfig;
8260
8282
  // v2 functional components do not inherit attrs
8261
8283
  Func.inheritAttrs = false;
8262
8284
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8746,7 +8768,8 @@ function mergeProps(...args) {
8746
8768
  else if (isOn(key)) {
8747
8769
  const existing = ret[key];
8748
8770
  const incoming = toMerge[key];
8749
- if (existing !== incoming) {
8771
+ if (existing !== incoming &&
8772
+ !(isArray(existing) && existing.includes(incoming))) {
8750
8773
  ret[key] = existing
8751
8774
  ? [].concat(existing, incoming)
8752
8775
  : incoming;
@@ -9190,23 +9213,23 @@ const PublicInstanceProxyHandlers = {
9190
9213
  const n = accessCache[key];
9191
9214
  if (n !== undefined) {
9192
9215
  switch (n) {
9193
- case 0 /* SETUP */:
9216
+ case 1 /* SETUP */:
9194
9217
  return setupState[key];
9195
- case 1 /* DATA */:
9218
+ case 2 /* DATA */:
9196
9219
  return data[key];
9197
- case 3 /* CONTEXT */:
9220
+ case 4 /* CONTEXT */:
9198
9221
  return ctx[key];
9199
- case 2 /* PROPS */:
9222
+ case 3 /* PROPS */:
9200
9223
  return props[key];
9201
9224
  // default: just fallthrough
9202
9225
  }
9203
9226
  }
9204
9227
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9205
- accessCache[key] = 0 /* SETUP */;
9228
+ accessCache[key] = 1 /* SETUP */;
9206
9229
  return setupState[key];
9207
9230
  }
9208
9231
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9209
- accessCache[key] = 1 /* DATA */;
9232
+ accessCache[key] = 2 /* DATA */;
9210
9233
  return data[key];
9211
9234
  }
9212
9235
  else if (
@@ -9214,15 +9237,15 @@ const PublicInstanceProxyHandlers = {
9214
9237
  // props
9215
9238
  (normalizedProps = instance.propsOptions[0]) &&
9216
9239
  hasOwn(normalizedProps, key)) {
9217
- accessCache[key] = 2 /* PROPS */;
9240
+ accessCache[key] = 3 /* PROPS */;
9218
9241
  return props[key];
9219
9242
  }
9220
9243
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9221
- accessCache[key] = 3 /* CONTEXT */;
9244
+ accessCache[key] = 4 /* CONTEXT */;
9222
9245
  return ctx[key];
9223
9246
  }
9224
9247
  else if (shouldCacheAccess) {
9225
- accessCache[key] = 4 /* OTHER */;
9248
+ accessCache[key] = 0 /* OTHER */;
9226
9249
  }
9227
9250
  }
9228
9251
  const publicGetter = publicPropertiesMap[key];
@@ -9243,7 +9266,7 @@ const PublicInstanceProxyHandlers = {
9243
9266
  }
9244
9267
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9245
9268
  // user may set custom properties to `this` that start with `$`
9246
- accessCache[key] = 3 /* CONTEXT */;
9269
+ accessCache[key] = 4 /* CONTEXT */;
9247
9270
  return ctx[key];
9248
9271
  }
9249
9272
  else if (
@@ -9311,7 +9334,7 @@ const PublicInstanceProxyHandlers = {
9311
9334
  },
9312
9335
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9313
9336
  let normalizedProps;
9314
- return (accessCache[key] !== undefined ||
9337
+ return (!!accessCache[key] ||
9315
9338
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9316
9339
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9317
9340
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -10886,7 +10909,7 @@ function isMemoSame(cached, memo) {
10886
10909
  }
10887
10910
 
10888
10911
  // Core API ------------------------------------------------------------------
10889
- const version = "3.2.20";
10912
+ const version = "3.2.24";
10890
10913
  /**
10891
10914
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10892
10915
  * @internal
@@ -11015,16 +11038,8 @@ function patchClass(el, value, isSVG) {
11015
11038
 
11016
11039
  function patchStyle(el, prev, next) {
11017
11040
  const style = el.style;
11018
- const currentDisplay = style.display;
11019
- if (!next) {
11020
- el.removeAttribute('style');
11021
- }
11022
- else if (isString(next)) {
11023
- if (prev !== next) {
11024
- style.cssText = next;
11025
- }
11026
- }
11027
- else {
11041
+ const isCssString = isString(next);
11042
+ if (next && !isCssString) {
11028
11043
  for (const key in next) {
11029
11044
  setStyle(style, key, next[key]);
11030
11045
  }
@@ -11036,11 +11051,22 @@ function patchStyle(el, prev, next) {
11036
11051
  }
11037
11052
  }
11038
11053
  }
11039
- // indicates that the `display` of the element is controlled by `v-show`,
11040
- // so we always keep the current `display` value regardless of the `style` value,
11041
- // thus handing over control to `v-show`.
11042
- if ('_vod' in el) {
11043
- style.display = currentDisplay;
11054
+ else {
11055
+ const currentDisplay = style.display;
11056
+ if (isCssString) {
11057
+ if (prev !== next) {
11058
+ style.cssText = next;
11059
+ }
11060
+ }
11061
+ else if (prev) {
11062
+ el.removeAttribute('style');
11063
+ }
11064
+ // indicates that the `display` of the element is controlled by `v-show`,
11065
+ // so we always keep the current `display` value regardless of the `style`
11066
+ // value, thus handing over control to `v-show`.
11067
+ if ('_vod' in el) {
11068
+ style.display = currentDisplay;
11069
+ }
11044
11070
  }
11045
11071
  }
11046
11072
  const importantRE = /\s*!important$/;
@@ -11150,12 +11176,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11150
11176
  el[key] = value == null ? '' : value;
11151
11177
  return;
11152
11178
  }
11153
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11179
+ if (key === 'value' &&
11180
+ el.tagName !== 'PROGRESS' &&
11181
+ // custom elements may use _value internally
11182
+ !el.tagName.includes('-')) {
11154
11183
  // store value as _value as well since
11155
11184
  // non-string values will be stringified.
11156
11185
  el._value = value;
11157
11186
  const newValue = value == null ? '' : value;
11158
- if (el.value !== newValue) {
11187
+ if (el.value !== newValue ||
11188
+ // #4956: always set for OPTION elements because its value falls back to
11189
+ // textContent if no value attribute is present. And setting .value for
11190
+ // OPTION has no side effect
11191
+ el.tagName === 'OPTION') {
11159
11192
  el.value = newValue;
11160
11193
  }
11161
11194
  if (value == null) {
@@ -11423,22 +11456,11 @@ class VueElement extends BaseClass {
11423
11456
  }
11424
11457
  this.attachShadow({ mode: 'open' });
11425
11458
  }
11426
- // set initial attrs
11427
- for (let i = 0; i < this.attributes.length; i++) {
11428
- this._setAttr(this.attributes[i].name);
11429
- }
11430
- // watch future attr changes
11431
- new MutationObserver(mutations => {
11432
- for (const m of mutations) {
11433
- this._setAttr(m.attributeName);
11434
- }
11435
- }).observe(this, { attributes: true });
11436
11459
  }
11437
11460
  connectedCallback() {
11438
11461
  this._connected = true;
11439
11462
  if (!this._instance) {
11440
11463
  this._resolveDef();
11441
- this._update();
11442
11464
  }
11443
11465
  }
11444
11466
  disconnectedCallback() {
@@ -11457,8 +11479,18 @@ class VueElement extends BaseClass {
11457
11479
  if (this._resolved) {
11458
11480
  return;
11459
11481
  }
11482
+ this._resolved = true;
11483
+ // set initial attrs
11484
+ for (let i = 0; i < this.attributes.length; i++) {
11485
+ this._setAttr(this.attributes[i].name);
11486
+ }
11487
+ // watch future attr changes
11488
+ new MutationObserver(mutations => {
11489
+ for (const m of mutations) {
11490
+ this._setAttr(m.attributeName);
11491
+ }
11492
+ }).observe(this, { attributes: true });
11460
11493
  const resolve = (def) => {
11461
- this._resolved = true;
11462
11494
  const { props, styles } = def;
11463
11495
  const hasOptions = !isArray(props);
11464
11496
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -11473,14 +11505,11 @@ class VueElement extends BaseClass {
11473
11505
  }
11474
11506
  }
11475
11507
  }
11476
- if (numberProps) {
11477
- this._numberProps = numberProps;
11478
- this._update();
11479
- }
11508
+ this._numberProps = numberProps;
11480
11509
  // check if there are props set pre-upgrade or connect
11481
11510
  for (const key of Object.keys(this)) {
11482
11511
  if (key[0] !== '_') {
11483
- this._setProp(key, this[key]);
11512
+ this._setProp(key, this[key], true, false);
11484
11513
  }
11485
11514
  }
11486
11515
  // defining getter/setters on prototype
@@ -11494,7 +11523,10 @@ class VueElement extends BaseClass {
11494
11523
  }
11495
11524
  });
11496
11525
  }
11526
+ // apply CSS
11497
11527
  this._applyStyles(styles);
11528
+ // initial render
11529
+ this._update();
11498
11530
  };
11499
11531
  const asyncDef = this._def.__asyncLoader;
11500
11532
  if (asyncDef) {
@@ -11520,10 +11552,10 @@ class VueElement extends BaseClass {
11520
11552
  /**
11521
11553
  * @internal
11522
11554
  */
11523
- _setProp(key, val, shouldReflect = true) {
11555
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11524
11556
  if (val !== this._props[key]) {
11525
11557
  this._props[key] = val;
11526
- if (this._instance) {
11558
+ if (shouldUpdate && this._instance) {
11527
11559
  this._update();
11528
11560
  }
11529
11561
  // reflect
@@ -11552,7 +11584,7 @@ class VueElement extends BaseClass {
11552
11584
  // HMR
11553
11585
  {
11554
11586
  instance.ceReload = newStyles => {
11555
- // alawys reset styles
11587
+ // always reset styles
11556
11588
  if (this._styles) {
11557
11589
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11558
11590
  this._styles.length = 0;
@@ -13336,7 +13368,6 @@ function getUnnormalizedProps(props, callPath = []) {
13336
13368
  }
13337
13369
  function injectProp(node, prop, context) {
13338
13370
  let propsWithInjection;
13339
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13340
13371
  /**
13341
13372
  * 1. mergeProps(...)
13342
13373
  * 2. toHandlers(...)
@@ -13345,7 +13376,7 @@ function injectProp(node, prop, context) {
13345
13376
  *
13346
13377
  * we need to get the real props before normalization
13347
13378
  */
13348
- let props = originalProps;
13379
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
13349
13380
  let callPath = [];
13350
13381
  let parentCall;
13351
13382
  if (props &&
@@ -13941,6 +13972,7 @@ function parseTag(context, type, parent) {
13941
13972
  }
13942
13973
  if (hasIf && hasFor) {
13943
13974
  warnDeprecation$1("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
13975
+ break;
13944
13976
  }
13945
13977
  }
13946
13978
  }
@@ -14365,15 +14397,6 @@ function isSingleElementRoot(root, child) {
14365
14397
  !isSlotOutlet(child));
14366
14398
  }
14367
14399
  function walk$1(node, context, doNotHoistNode = false) {
14368
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
14369
- // static bindings with expressions. These expressions are guaranteed to be
14370
- // constant so they are still eligible for hoisting, but they are only
14371
- // available at runtime and therefore cannot be evaluated ahead of time.
14372
- // This is only a concern for pre-stringification (via transformHoist by
14373
- // @vue/compiler-dom), but doing it here allows us to perform only one full
14374
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14375
- // stringification threshold is met.
14376
- let canStringify = true;
14377
14400
  const { children } = node;
14378
14401
  const originalCount = children.length;
14379
14402
  let hoistedCount = 0;
@@ -14386,9 +14409,6 @@ function walk$1(node, context, doNotHoistNode = false) {
14386
14409
  ? 0 /* NOT_CONSTANT */
14387
14410
  : getConstantType(child, context);
14388
14411
  if (constantType > 0 /* NOT_CONSTANT */) {
14389
- if (constantType < 3 /* CAN_STRINGIFY */) {
14390
- canStringify = false;
14391
- }
14392
14412
  if (constantType >= 2 /* CAN_HOIST */) {
14393
14413
  child.codegenNode.patchFlag =
14394
14414
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -14419,17 +14439,10 @@ function walk$1(node, context, doNotHoistNode = false) {
14419
14439
  }
14420
14440
  }
14421
14441
  }
14422
- else if (child.type === 12 /* TEXT_CALL */) {
14423
- const contentType = getConstantType(child.content, context);
14424
- if (contentType > 0) {
14425
- if (contentType < 3 /* CAN_STRINGIFY */) {
14426
- canStringify = false;
14427
- }
14428
- if (contentType >= 2 /* CAN_HOIST */) {
14429
- child.codegenNode = context.hoist(child.codegenNode);
14430
- hoistedCount++;
14431
- }
14432
- }
14442
+ else if (child.type === 12 /* TEXT_CALL */ &&
14443
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
14444
+ child.codegenNode = context.hoist(child.codegenNode);
14445
+ hoistedCount++;
14433
14446
  }
14434
14447
  // walk further
14435
14448
  if (child.type === 1 /* ELEMENT */) {
@@ -14453,7 +14466,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14453
14466
  }
14454
14467
  }
14455
14468
  }
14456
- if (canStringify && hoistedCount && context.transformHoist) {
14469
+ if (hoistedCount && context.transformHoist) {
14457
14470
  context.transformHoist(children, context, node);
14458
14471
  }
14459
14472
  // all children were hoisted - the entire children array is hoistable.
@@ -16808,7 +16821,7 @@ function stringifyDynamicPropNames(props) {
16808
16821
  return propsNamesString + `]`;
16809
16822
  }
16810
16823
  function isComponentTag(tag) {
16811
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
16824
+ return tag === 'component' || tag === 'Component';
16812
16825
  }
16813
16826
 
16814
16827
  const transformSlotOutlet = (node, context) => {