@vue/compiler-core 3.2.19 → 3.2.20

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),
@@ -1383,10 +1383,10 @@ function parseAttribute(context, nameSet) {
1383
1383
  isStatic = false;
1384
1384
  if (!content.endsWith(']')) {
1385
1385
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1386
- content = content.substr(1);
1386
+ content = content.slice(1);
1387
1387
  }
1388
1388
  else {
1389
- content = content.substr(1, content.length - 2);
1389
+ content = content.slice(1, content.length - 1);
1390
1390
  }
1391
1391
  }
1392
1392
  else if (isSlot) {
@@ -1412,7 +1412,7 @@ function parseAttribute(context, nameSet) {
1412
1412
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1413
1413
  valueLoc.source = valueLoc.source.slice(1, -1);
1414
1414
  }
1415
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
1415
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
1416
1416
  if (isPropShorthand)
1417
1417
  modifiers.push('prop');
1418
1418
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1633,7 +1633,7 @@ function isEnd(context, mode, ancestors) {
1633
1633
  }
1634
1634
  function startsWithEndTagOpen(source, tag) {
1635
1635
  return (startsWith(source, '</') &&
1636
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
1636
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
1637
1637
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
1638
1638
  }
1639
1639
 
@@ -3433,12 +3433,19 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3433
3433
  // it gets correct type
3434
3434
  return `__props.${raw}`;
3435
3435
  }
3436
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3437
+ // prop with a different local alias (from defineProps() destructure)
3438
+ return `__props.${bindingMetadata.__propsAliases[raw]}`;
3439
+ }
3436
3440
  }
3437
3441
  else {
3438
3442
  if (type && type.startsWith('setup')) {
3439
3443
  // setup bindings in non-inline mode
3440
3444
  return `$setup.${raw}`;
3441
3445
  }
3446
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
3447
+ return `$props.${bindingMetadata.__propsAliases[raw]}`;
3448
+ }
3442
3449
  else if (type) {
3443
3450
  return `$${type}.${raw}`;
3444
3451
  }
@@ -3483,7 +3490,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3483
3490
  : `(${rawExp})${asParams ? `=>{}` : ``}`;
3484
3491
  try {
3485
3492
  ast = parser.parse(source, {
3486
- plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
3493
+ plugins: context.expressionPlugins
3487
3494
  }).program;
3488
3495
  }
3489
3496
  catch (e) {
@@ -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) {
@@ -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),
@@ -1368,10 +1368,10 @@ function parseAttribute(context, nameSet) {
1368
1368
  isStatic = false;
1369
1369
  if (!content.endsWith(']')) {
1370
1370
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1371
- content = content.substr(1);
1371
+ content = content.slice(1);
1372
1372
  }
1373
1373
  else {
1374
- content = content.substr(1, content.length - 2);
1374
+ content = content.slice(1, content.length - 1);
1375
1375
  }
1376
1376
  }
1377
1377
  else if (isSlot) {
@@ -1397,7 +1397,7 @@ function parseAttribute(context, nameSet) {
1397
1397
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1398
1398
  valueLoc.source = valueLoc.source.slice(1, -1);
1399
1399
  }
1400
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
1400
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
1401
1401
  if (isPropShorthand)
1402
1402
  modifiers.push('prop');
1403
1403
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1618,7 +1618,7 @@ function isEnd(context, mode, ancestors) {
1618
1618
  }
1619
1619
  function startsWithEndTagOpen(source, tag) {
1620
1620
  return (startsWith(source, '</') &&
1621
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
1621
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
1622
1622
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
1623
1623
  }
1624
1624
 
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.20",
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.20",
36
36
  "@babel/parser": "^7.15.0",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"