@vue/compiler-core 3.2.19 → 3.2.23

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.
@@ -454,7 +454,7 @@ const isMemberExpressionBrowser = (path) => {
454
454
  const isMemberExpressionNode = (path, context) => {
455
455
  try {
456
456
  let ret = parser.parseExpression(path, {
457
- plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
457
+ plugins: context.expressionPlugins
458
458
  });
459
459
  if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
460
460
  ret = ret.expression;
@@ -469,7 +469,7 @@ const isMemberExpressionNode = (path, context) => {
469
469
  };
470
470
  const isMemberExpression = isMemberExpressionNode;
471
471
  function getInnerRange(loc, offset, length) {
472
- const source = loc.source.substr(offset, length);
472
+ const source = loc.source.slice(offset, offset + length);
473
473
  const newLoc = {
474
474
  source,
475
475
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -1226,6 +1226,7 @@ function parseTag(context, type, parent) {
1226
1226
  }
1227
1227
  if (hasIf && hasFor) {
1228
1228
  warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
1229
+ break;
1229
1230
  }
1230
1231
  }
1231
1232
  }
@@ -1383,10 +1384,10 @@ function parseAttribute(context, nameSet) {
1383
1384
  isStatic = false;
1384
1385
  if (!content.endsWith(']')) {
1385
1386
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1386
- content = content.substr(1);
1387
+ content = content.slice(1);
1387
1388
  }
1388
1389
  else {
1389
- content = content.substr(1, content.length - 2);
1390
+ content = content.slice(1, content.length - 1);
1390
1391
  }
1391
1392
  }
1392
1393
  else if (isSlot) {
@@ -1412,7 +1413,7 @@ function parseAttribute(context, nameSet) {
1412
1413
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1413
1414
  valueLoc.source = valueLoc.source.slice(1, -1);
1414
1415
  }
1415
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
1416
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
1416
1417
  if (isPropShorthand)
1417
1418
  modifiers.push('prop');
1418
1419
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1633,7 +1634,7 @@ function isEnd(context, mode, ancestors) {
1633
1634
  }
1634
1635
  function startsWithEndTagOpen(source, tag) {
1635
1636
  return (startsWith(source, '</') &&
1636
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
1637
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
1637
1638
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
1638
1639
  }
1639
1640
 
@@ -3433,12 +3434,19 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3433
3434
  // it gets correct type
3434
3435
  return `__props.${raw}`;
3435
3436
  }
3437
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3438
+ // prop with a different local alias (from defineProps() destructure)
3439
+ return `__props.${bindingMetadata.__propsAliases[raw]}`;
3440
+ }
3436
3441
  }
3437
3442
  else {
3438
3443
  if (type && type.startsWith('setup')) {
3439
3444
  // setup bindings in non-inline mode
3440
3445
  return `$setup.${raw}`;
3441
3446
  }
3447
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3448
+ return `$props.${bindingMetadata.__propsAliases[raw]}`;
3449
+ }
3442
3450
  else if (type) {
3443
3451
  return `$${type}.${raw}`;
3444
3452
  }
@@ -3483,7 +3491,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3483
3491
  : `(${rawExp})${asParams ? `=>{}` : ``}`;
3484
3492
  try {
3485
3493
  ast = parser.parse(source, {
3486
- plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
3494
+ plugins: context.expressionPlugins
3487
3495
  }).program;
3488
3496
  }
3489
3497
  catch (e) {
@@ -4947,7 +4955,7 @@ function stringifyDynamicPropNames(props) {
4947
4955
  return propsNamesString + `]`;
4948
4956
  }
4949
4957
  function isComponentTag(tag) {
4950
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
4958
+ return tag === 'component' || tag === 'Component';
4951
4959
  }
4952
4960
  function processInlineRef(context, raw) {
4953
4961
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
@@ -453,7 +453,7 @@ const isMemberExpressionBrowser = (path) => {
453
453
  const isMemberExpressionNode = (path, context) => {
454
454
  try {
455
455
  let ret = parser.parseExpression(path, {
456
- plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
456
+ plugins: context.expressionPlugins
457
457
  });
458
458
  if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
459
459
  ret = ret.expression;
@@ -468,7 +468,7 @@ const isMemberExpressionNode = (path, context) => {
468
468
  };
469
469
  const isMemberExpression = isMemberExpressionNode;
470
470
  function getInnerRange(loc, offset, length) {
471
- const source = loc.source.substr(offset, length);
471
+ const source = loc.source.slice(offset, offset + length);
472
472
  const newLoc = {
473
473
  source,
474
474
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -1359,10 +1359,10 @@ function parseAttribute(context, nameSet) {
1359
1359
  isStatic = false;
1360
1360
  if (!content.endsWith(']')) {
1361
1361
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1362
- content = content.substr(1);
1362
+ content = content.slice(1);
1363
1363
  }
1364
1364
  else {
1365
- content = content.substr(1, content.length - 2);
1365
+ content = content.slice(1, content.length - 1);
1366
1366
  }
1367
1367
  }
1368
1368
  else if (isSlot) {
@@ -1388,7 +1388,7 @@ function parseAttribute(context, nameSet) {
1388
1388
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1389
1389
  valueLoc.source = valueLoc.source.slice(1, -1);
1390
1390
  }
1391
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
1391
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
1392
1392
  if (isPropShorthand)
1393
1393
  modifiers.push('prop');
1394
1394
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1606,7 +1606,7 @@ function isEnd(context, mode, ancestors) {
1606
1606
  }
1607
1607
  function startsWithEndTagOpen(source, tag) {
1608
1608
  return (startsWith(source, '</') &&
1609
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
1609
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
1610
1610
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
1611
1611
  }
1612
1612
 
@@ -3371,12 +3371,19 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3371
3371
  // it gets correct type
3372
3372
  return `__props.${raw}`;
3373
3373
  }
3374
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3375
+ // prop with a different local alias (from defineProps() destructure)
3376
+ return `__props.${bindingMetadata.__propsAliases[raw]}`;
3377
+ }
3374
3378
  }
3375
3379
  else {
3376
3380
  if (type && type.startsWith('setup')) {
3377
3381
  // setup bindings in non-inline mode
3378
3382
  return `$setup.${raw}`;
3379
3383
  }
3384
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3385
+ return `$props.${bindingMetadata.__propsAliases[raw]}`;
3386
+ }
3380
3387
  else if (type) {
3381
3388
  return `$${type}.${raw}`;
3382
3389
  }
@@ -3421,7 +3428,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3421
3428
  : `(${rawExp})${asParams ? `=>{}` : ``}`;
3422
3429
  try {
3423
3430
  ast = parser.parse(source, {
3424
- plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
3431
+ plugins: context.expressionPlugins
3425
3432
  }).program;
3426
3433
  }
3427
3434
  catch (e) {
@@ -4823,7 +4830,7 @@ function stringifyDynamicPropNames(props) {
4823
4830
  return propsNamesString + `]`;
4824
4831
  }
4825
4832
  function isComponentTag(tag) {
4826
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
4833
+ return tag === 'component' || tag === 'Component';
4827
4834
  }
4828
4835
  function processInlineRef(context, raw) {
4829
4836
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
@@ -52,6 +52,7 @@ export declare type BindingMetadata = {
52
52
  [key: string]: BindingTypes | undefined;
53
53
  } & {
54
54
  __isScriptSetup?: boolean;
55
+ __propsAliases?: Record<string, string>;
55
56
  };
56
57
 
57
58
  export declare const enum BindingTypes {
@@ -63,6 +64,11 @@ export declare const enum BindingTypes {
63
64
  * declared as a prop
64
65
  */
65
66
  PROPS = "props",
67
+ /**
68
+ * a local alias of a `<script setup>` destructured prop.
69
+ * the original is stored in __propsAliases of the bindingMetadata object.
70
+ */
71
+ PROPS_ALIASED = "props-aliased",
66
72
  /**
67
73
  * a let binding (may or may not be a ref)
68
74
  */
@@ -520,7 +526,7 @@ export { generateCodeFrame }
520
526
 
521
527
  export declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
522
528
 
523
- export declare function getInnerRange(loc: SourceLocation, offset: number, length?: number): SourceLocation;
529
+ export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
524
530
 
525
531
  export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
526
532
 
@@ -451,7 +451,7 @@ const isMemberExpressionNode = NOOP
451
451
  const isMemberExpression = isMemberExpressionBrowser
452
452
  ;
453
453
  function getInnerRange(loc, offset, length) {
454
- const source = loc.source.substr(offset, length);
454
+ const source = loc.source.slice(offset, offset + length);
455
455
  const newLoc = {
456
456
  source,
457
457
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -1211,6 +1211,7 @@ function parseTag(context, type, parent) {
1211
1211
  }
1212
1212
  if (hasIf && hasFor) {
1213
1213
  warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
1214
+ break;
1214
1215
  }
1215
1216
  }
1216
1217
  }
@@ -1368,10 +1369,10 @@ function parseAttribute(context, nameSet) {
1368
1369
  isStatic = false;
1369
1370
  if (!content.endsWith(']')) {
1370
1371
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1371
- content = content.substr(1);
1372
+ content = content.slice(1);
1372
1373
  }
1373
1374
  else {
1374
- content = content.substr(1, content.length - 2);
1375
+ content = content.slice(1, content.length - 1);
1375
1376
  }
1376
1377
  }
1377
1378
  else if (isSlot) {
@@ -1397,7 +1398,7 @@ function parseAttribute(context, nameSet) {
1397
1398
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1398
1399
  valueLoc.source = valueLoc.source.slice(1, -1);
1399
1400
  }
1400
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
1401
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
1401
1402
  if (isPropShorthand)
1402
1403
  modifiers.push('prop');
1403
1404
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1618,7 +1619,7 @@ function isEnd(context, mode, ancestors) {
1618
1619
  }
1619
1620
  function startsWithEndTagOpen(source, tag) {
1620
1621
  return (startsWith(source, '</') &&
1621
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
1622
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
1622
1623
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
1623
1624
  }
1624
1625
 
@@ -4207,7 +4208,7 @@ function stringifyDynamicPropNames(props) {
4207
4208
  return propsNamesString + `]`;
4208
4209
  }
4209
4210
  function isComponentTag(tag) {
4210
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
4211
+ return tag === 'component' || tag === 'Component';
4211
4212
  }
4212
4213
 
4213
4214
  (process.env.NODE_ENV !== 'production')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.2.19",
3
+ "version": "3.2.23",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.19",
35
+ "@vue/shared": "3.2.23",
36
36
  "@babel/parser": "^7.15.0",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"