@vue/compat 3.2.12 → 3.2.13

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.
@@ -1501,7 +1501,8 @@ class ComputedRefImpl {
1501
1501
  function computed(getterOrOptions, debugOptions) {
1502
1502
  let getter;
1503
1503
  let setter;
1504
- if (isFunction(getterOrOptions)) {
1504
+ const onlyGetter = isFunction(getterOrOptions);
1505
+ if (onlyGetter) {
1505
1506
  getter = getterOrOptions;
1506
1507
  setter = (process.env.NODE_ENV !== 'production')
1507
1508
  ? () => {
@@ -1513,7 +1514,7 @@ function computed(getterOrOptions, debugOptions) {
1513
1514
  getter = getterOrOptions.get;
1514
1515
  setter = getterOrOptions.set;
1515
1516
  }
1516
- const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
1517
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
1517
1518
  if ((process.env.NODE_ENV !== 'production') && debugOptions) {
1518
1519
  cRef.effect.onTrack = debugOptions.onTrack;
1519
1520
  cRef.effect.onTrigger = debugOptions.onTrigger;
@@ -1968,7 +1969,7 @@ const deprecationData = {
1968
1969
  ["PRIVATE_APIS" /* PRIVATE_APIS */]: {
1969
1970
  message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
1970
1971
  `If you are seeing this warning only due to a dependency, you can ` +
1971
- `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
1972
+ `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
1972
1973
  }
1973
1974
  };
1974
1975
  const instanceWarned = Object.create(null);
@@ -5302,7 +5303,7 @@ function createCompatVue(createApp, createSingletonApp) {
5302
5303
  return vm;
5303
5304
  }
5304
5305
  }
5305
- Vue.version = "3.2.12";
5306
+ Vue.version = "3.2.13";
5306
5307
  Vue.config = singletonApp.config;
5307
5308
  Vue.use = (p, ...options) => {
5308
5309
  if (p && isFunction(p.install)) {
@@ -5838,7 +5839,7 @@ function createAppAPI(render, hydrate) {
5838
5839
  app._instance = vnode.component;
5839
5840
  devtoolsInitApp(app, version);
5840
5841
  }
5841
- return vnode.component.proxy;
5842
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5842
5843
  }
5843
5844
  else if ((process.env.NODE_ENV !== 'production')) {
5844
5845
  warn$1(`App has already been mounted.\n` +
@@ -6049,14 +6050,14 @@ function createHydrationFunctions(rendererInternals) {
6049
6050
  for (const key in props) {
6050
6051
  if ((forcePatchValue && key.endsWith('value')) ||
6051
6052
  (isOn(key) && !isReservedProp(key))) {
6052
- patchProp(el, key, null, props[key]);
6053
+ patchProp(el, key, null, props[key], false, undefined, parentComponent);
6053
6054
  }
6054
6055
  }
6055
6056
  }
6056
6057
  else if (props.onClick) {
6057
6058
  // Fast path for click listeners (which is most often) to avoid
6058
6059
  // iterating through props.
6059
- patchProp(el, 'onClick', null, props.onClick);
6060
+ patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
6060
6061
  }
6061
6062
  }
6062
6063
  // vnode / directive hooks
@@ -10541,7 +10542,7 @@ function createPathGetter(ctx, path) {
10541
10542
  return cur;
10542
10543
  };
10543
10544
  }
10544
- function traverse(value, seen = new Set()) {
10545
+ function traverse(value, seen) {
10545
10546
  if (!isObject(value) || value["__v_skip" /* SKIP */]) {
10546
10547
  return value;
10547
10548
  }
@@ -10957,7 +10958,7 @@ function isMemoSame(cached, memo) {
10957
10958
  }
10958
10959
 
10959
10960
  // Core API ------------------------------------------------------------------
10960
- const version = "3.2.12";
10961
+ const version = "3.2.13";
10961
10962
  const _ssrUtils = {
10962
10963
  createComponentInstance,
10963
10964
  setupComponent,
@@ -12952,7 +12953,7 @@ const errorMessages = {
12952
12953
  // transform errors
12953
12954
  [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
12954
12955
  [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
12955
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
12956
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
12956
12957
  [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
12957
12958
  [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
12958
12959
  [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
@@ -13230,7 +13231,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
13230
13231
  * inside square brackets), but it's ok since these are only used on template
13231
13232
  * expressions and false positives are invalid expressions in the first place.
13232
13233
  */
13233
- const isMemberExpression = (path) => {
13234
+ const isMemberExpressionBrowser = (path) => {
13234
13235
  // remove whitespaces around . or [ first
13235
13236
  path = path.trim().replace(whitespaceRE, s => s.trim());
13236
13237
  let state = 0 /* inMemberExp */;
@@ -13300,6 +13301,8 @@ const isMemberExpression = (path) => {
13300
13301
  }
13301
13302
  return !currentOpenBracketCount && !currentOpenParensCount;
13302
13303
  };
13304
+ const isMemberExpression = isMemberExpressionBrowser
13305
+ ;
13303
13306
  function getInnerRange(loc, offset, length) {
13304
13307
  const source = loc.source.substr(offset, length);
13305
13308
  const newLoc = {
@@ -14448,7 +14451,7 @@ function walk$1(node, context, doNotHoistNode = false) {
14448
14451
  // This is only a concern for pre-stringification (via transformHoist by
14449
14452
  // @vue/compiler-dom), but doing it here allows us to perform only one full
14450
14453
  // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14451
- // stringficiation threshold is met.
14454
+ // stringification threshold is met.
14452
14455
  let canStringify = true;
14453
14456
  const { children } = node;
14454
14457
  const originalCount = children.length;
@@ -14695,7 +14698,7 @@ function getGeneratedPropsConstantType(node, context) {
14695
14698
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14696
14699
  // some helper calls can be hoisted,
14697
14700
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14698
- // in this case we need to respect the ConstanType of the helper's argments
14701
+ // in this case we need to respect the ConstantType of the helper's argments
14699
14702
  valueType = getConstantTypeOfHelperCall(value, context);
14700
14703
  }
14701
14704
  else {
@@ -15209,13 +15212,14 @@ function genHoists(hoists, context) {
15209
15212
  context.pure = true;
15210
15213
  const { push, newline, helper, scopeId, mode } = context;
15211
15214
  newline();
15212
- hoists.forEach((exp, i) => {
15215
+ for (let i = 0; i < hoists.length; i++) {
15216
+ const exp = hoists[i];
15213
15217
  if (exp) {
15214
- push(`const _hoisted_${i + 1} = `);
15218
+ push(`const _hoisted_${i + 1} = ${``}`);
15215
15219
  genNode(exp, context);
15216
15220
  newline();
15217
15221
  }
15218
- });
15222
+ }
15219
15223
  context.pure = false;
15220
15224
  }
15221
15225
  function isText$1(n) {
@@ -15724,6 +15728,11 @@ function processIf(node, dir, context, processCodegen) {
15724
15728
  continue;
15725
15729
  }
15726
15730
  if (sibling && sibling.type === 9 /* IF */) {
15731
+ // Check if v-else was followed by v-else-if
15732
+ if (dir.name === 'else-if' &&
15733
+ sibling.branches[sibling.branches.length - 1].condition === undefined) {
15734
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
15735
+ }
15727
15736
  // move the node to the if node's branches
15728
15737
  context.removeNode();
15729
15738
  const branch = createIfBranch(node, dir);
@@ -16821,7 +16830,7 @@ function dedupeProperties(properties) {
16821
16830
  const name = prop.key.content;
16822
16831
  const existing = knownProps.get(name);
16823
16832
  if (existing) {
16824
- if (name === 'style' || name === 'class' || name.startsWith('on')) {
16833
+ if (name === 'style' || name === 'class' || isOn(name)) {
16825
16834
  mergeAsArray$1(existing, prop);
16826
16835
  }
16827
16836
  // unexpected duplicate, should have emitted error during parse
@@ -16896,26 +16905,24 @@ const transformSlotOutlet = (node, context) => {
16896
16905
  const { slotName, slotProps } = processSlotOutlet(node, context);
16897
16906
  const slotArgs = [
16898
16907
  context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
16899
- slotName
16908
+ slotName,
16909
+ '{}',
16910
+ 'undefined',
16911
+ 'true'
16900
16912
  ];
16913
+ let expectedLen = 2;
16901
16914
  if (slotProps) {
16902
- slotArgs.push(slotProps);
16915
+ slotArgs[2] = slotProps;
16916
+ expectedLen = 3;
16903
16917
  }
16904
16918
  if (children.length) {
16905
- if (!slotProps) {
16906
- slotArgs.push(`{}`);
16907
- }
16908
- slotArgs.push(createFunctionExpression([], children, false, false, loc));
16919
+ slotArgs[3] = createFunctionExpression([], children, false, false, loc);
16920
+ expectedLen = 4;
16909
16921
  }
16910
16922
  if (context.scopeId && !context.slotted) {
16911
- if (!slotProps) {
16912
- slotArgs.push(`{}`);
16913
- }
16914
- if (!children.length) {
16915
- slotArgs.push(`undefined`);
16916
- }
16917
- slotArgs.push(`true`);
16923
+ expectedLen = 5;
16918
16924
  }
16925
+ slotArgs.splice(expectedLen); // remove unused arguments
16919
16926
  node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
16920
16927
  }
16921
16928
  };
@@ -17217,7 +17224,8 @@ const transformModel = (dir, node, context) => {
17217
17224
  // _unref(exp)
17218
17225
  context.bindingMetadata[rawExp];
17219
17226
  const maybeRef = !true /* SETUP_CONST */;
17220
- if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
17227
+ if (!expString.trim() ||
17228
+ (!isMemberExpression(expString) && !maybeRef)) {
17221
17229
  context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
17222
17230
  return createTransformProps();
17223
17231
  }
@@ -17925,7 +17933,8 @@ const warnTransitionChildren = (node, context) => {
17925
17933
  };
17926
17934
  function hasMultipleChildren(node) {
17927
17935
  // #1352 filter out potential comment nodes.
17928
- const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */));
17936
+ const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
17937
+ !(c.type === 2 /* TEXT */ && !c.content.trim())));
17929
17938
  const child = children[0];
17930
17939
  return (children.length !== 1 ||
17931
17940
  child.type === 11 /* FOR */ ||
@@ -1488,7 +1488,8 @@ var Vue = (function () {
1488
1488
  function computed(getterOrOptions, debugOptions) {
1489
1489
  let getter;
1490
1490
  let setter;
1491
- if (isFunction(getterOrOptions)) {
1491
+ const onlyGetter = isFunction(getterOrOptions);
1492
+ if (onlyGetter) {
1492
1493
  getter = getterOrOptions;
1493
1494
  setter = () => {
1494
1495
  console.warn('Write operation failed: computed value is readonly');
@@ -1499,7 +1500,7 @@ var Vue = (function () {
1499
1500
  getter = getterOrOptions.get;
1500
1501
  setter = getterOrOptions.set;
1501
1502
  }
1502
- const cRef = new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set);
1503
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter);
1503
1504
  if (debugOptions) {
1504
1505
  cRef.effect.onTrack = debugOptions.onTrack;
1505
1506
  cRef.effect.onTrigger = debugOptions.onTrigger;
@@ -1954,7 +1955,7 @@ var Vue = (function () {
1954
1955
  ["PRIVATE_APIS" /* PRIVATE_APIS */]: {
1955
1956
  message: name => `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
1956
1957
  `If you are seeing this warning only due to a dependency, you can ` +
1957
- `suppress this warning via { PRIVATE_APIS: 'supress-warning' }.`
1958
+ `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
1958
1959
  }
1959
1960
  };
1960
1961
  const instanceWarned = Object.create(null);
@@ -5275,7 +5276,7 @@ var Vue = (function () {
5275
5276
  return vm;
5276
5277
  }
5277
5278
  }
5278
- Vue.version = "3.2.12";
5279
+ Vue.version = "3.2.13";
5279
5280
  Vue.config = singletonApp.config;
5280
5281
  Vue.use = (p, ...options) => {
5281
5282
  if (p && isFunction(p.install)) {
@@ -5806,7 +5807,7 @@ var Vue = (function () {
5806
5807
  app._instance = vnode.component;
5807
5808
  devtoolsInitApp(app, version);
5808
5809
  }
5809
- return vnode.component.proxy;
5810
+ return getExposeProxy(vnode.component) || vnode.component.proxy;
5810
5811
  }
5811
5812
  else {
5812
5813
  warn$1(`App has already been mounted.\n` +
@@ -6015,14 +6016,14 @@ var Vue = (function () {
6015
6016
  for (const key in props) {
6016
6017
  if ((forcePatchValue && key.endsWith('value')) ||
6017
6018
  (isOn(key) && !isReservedProp(key))) {
6018
- patchProp(el, key, null, props[key]);
6019
+ patchProp(el, key, null, props[key], false, undefined, parentComponent);
6019
6020
  }
6020
6021
  }
6021
6022
  }
6022
6023
  else if (props.onClick) {
6023
6024
  // Fast path for click listeners (which is most often) to avoid
6024
6025
  // iterating through props.
6025
- patchProp(el, 'onClick', null, props.onClick);
6026
+ patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
6026
6027
  }
6027
6028
  }
6028
6029
  // vnode / directive hooks
@@ -10428,7 +10429,7 @@ var Vue = (function () {
10428
10429
  return cur;
10429
10430
  };
10430
10431
  }
10431
- function traverse(value, seen = new Set()) {
10432
+ function traverse(value, seen) {
10432
10433
  if (!isObject(value) || value["__v_skip" /* SKIP */]) {
10433
10434
  return value;
10434
10435
  }
@@ -10839,7 +10840,7 @@ var Vue = (function () {
10839
10840
  }
10840
10841
 
10841
10842
  // Core API ------------------------------------------------------------------
10842
- const version = "3.2.12";
10843
+ const version = "3.2.13";
10843
10844
  /**
10844
10845
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10845
10846
  * @internal
@@ -12811,7 +12812,7 @@ var Vue = (function () {
12811
12812
  // transform errors
12812
12813
  [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
12813
12814
  [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
12814
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
12815
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
12815
12816
  [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
12816
12817
  [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
12817
12818
  [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
@@ -13089,7 +13090,7 @@ var Vue = (function () {
13089
13090
  * inside square brackets), but it's ok since these are only used on template
13090
13091
  * expressions and false positives are invalid expressions in the first place.
13091
13092
  */
13092
- const isMemberExpression = (path) => {
13093
+ const isMemberExpressionBrowser = (path) => {
13093
13094
  // remove whitespaces around . or [ first
13094
13095
  path = path.trim().replace(whitespaceRE, s => s.trim());
13095
13096
  let state = 0 /* inMemberExp */;
@@ -13159,6 +13160,8 @@ var Vue = (function () {
13159
13160
  }
13160
13161
  return !currentOpenBracketCount && !currentOpenParensCount;
13161
13162
  };
13163
+ const isMemberExpression = isMemberExpressionBrowser
13164
+ ;
13162
13165
  function getInnerRange(loc, offset, length) {
13163
13166
  const source = loc.source.substr(offset, length);
13164
13167
  const newLoc = {
@@ -14305,7 +14308,7 @@ var Vue = (function () {
14305
14308
  // This is only a concern for pre-stringification (via transformHoist by
14306
14309
  // @vue/compiler-dom), but doing it here allows us to perform only one full
14307
14310
  // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
14308
- // stringficiation threshold is met.
14311
+ // stringification threshold is met.
14309
14312
  let canStringify = true;
14310
14313
  const { children } = node;
14311
14314
  const originalCount = children.length;
@@ -14551,7 +14554,7 @@ var Vue = (function () {
14551
14554
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
14552
14555
  // some helper calls can be hoisted,
14553
14556
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
14554
- // in this case we need to respect the ConstanType of the helper's argments
14557
+ // in this case we need to respect the ConstantType of the helper's argments
14555
14558
  valueType = getConstantTypeOfHelperCall(value, context);
14556
14559
  }
14557
14560
  else {
@@ -15064,13 +15067,14 @@ var Vue = (function () {
15064
15067
  context.pure = true;
15065
15068
  const { push, newline, helper, scopeId, mode } = context;
15066
15069
  newline();
15067
- hoists.forEach((exp, i) => {
15070
+ for (let i = 0; i < hoists.length; i++) {
15071
+ const exp = hoists[i];
15068
15072
  if (exp) {
15069
- push(`const _hoisted_${i + 1} = `);
15073
+ push(`const _hoisted_${i + 1} = ${``}`);
15070
15074
  genNode(exp, context);
15071
15075
  newline();
15072
15076
  }
15073
- });
15077
+ }
15074
15078
  context.pure = false;
15075
15079
  }
15076
15080
  function isText$1(n) {
@@ -15577,6 +15581,11 @@ var Vue = (function () {
15577
15581
  continue;
15578
15582
  }
15579
15583
  if (sibling && sibling.type === 9 /* IF */) {
15584
+ // Check if v-else was followed by v-else-if
15585
+ if (dir.name === 'else-if' &&
15586
+ sibling.branches[sibling.branches.length - 1].condition === undefined) {
15587
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
15588
+ }
15580
15589
  // move the node to the if node's branches
15581
15590
  context.removeNode();
15582
15591
  const branch = createIfBranch(node, dir);
@@ -16668,7 +16677,7 @@ var Vue = (function () {
16668
16677
  const name = prop.key.content;
16669
16678
  const existing = knownProps.get(name);
16670
16679
  if (existing) {
16671
- if (name === 'style' || name === 'class' || name.startsWith('on')) {
16680
+ if (name === 'style' || name === 'class' || isOn(name)) {
16672
16681
  mergeAsArray$1(existing, prop);
16673
16682
  }
16674
16683
  // unexpected duplicate, should have emitted error during parse
@@ -16743,26 +16752,24 @@ var Vue = (function () {
16743
16752
  const { slotName, slotProps } = processSlotOutlet(node, context);
16744
16753
  const slotArgs = [
16745
16754
  context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
16746
- slotName
16755
+ slotName,
16756
+ '{}',
16757
+ 'undefined',
16758
+ 'true'
16747
16759
  ];
16760
+ let expectedLen = 2;
16748
16761
  if (slotProps) {
16749
- slotArgs.push(slotProps);
16762
+ slotArgs[2] = slotProps;
16763
+ expectedLen = 3;
16750
16764
  }
16751
16765
  if (children.length) {
16752
- if (!slotProps) {
16753
- slotArgs.push(`{}`);
16754
- }
16755
- slotArgs.push(createFunctionExpression([], children, false, false, loc));
16766
+ slotArgs[3] = createFunctionExpression([], children, false, false, loc);
16767
+ expectedLen = 4;
16756
16768
  }
16757
16769
  if (context.scopeId && !context.slotted) {
16758
- if (!slotProps) {
16759
- slotArgs.push(`{}`);
16760
- }
16761
- if (!children.length) {
16762
- slotArgs.push(`undefined`);
16763
- }
16764
- slotArgs.push(`true`);
16770
+ expectedLen = 5;
16765
16771
  }
16772
+ slotArgs.splice(expectedLen); // remove unused arguments
16766
16773
  node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
16767
16774
  }
16768
16775
  };
@@ -17064,7 +17071,8 @@ var Vue = (function () {
17064
17071
  // _unref(exp)
17065
17072
  context.bindingMetadata[rawExp];
17066
17073
  const maybeRef = !true /* SETUP_CONST */;
17067
- if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
17074
+ if (!expString.trim() ||
17075
+ (!isMemberExpression(expString) && !maybeRef)) {
17068
17076
  context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
17069
17077
  return createTransformProps();
17070
17078
  }
@@ -17770,7 +17778,8 @@ var Vue = (function () {
17770
17778
  };
17771
17779
  function hasMultipleChildren(node) {
17772
17780
  // #1352 filter out potential comment nodes.
17773
- const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */));
17781
+ const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
17782
+ !(c.type === 2 /* TEXT */ && !c.content.trim())));
17774
17783
  const child = children[0];
17775
17784
  return (children.length !== 1 ||
17776
17785
  child.type === 11 /* FOR */ ||