@vue/compiler-core 3.2.16 → 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.
|
@@ -452,24 +452,24 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
452
452
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
453
453
|
};
|
|
454
454
|
const isMemberExpressionNode = (path, context) => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
455
|
+
try {
|
|
456
|
+
let ret = parser.parseExpression(path, {
|
|
457
|
+
plugins: context.expressionPlugins
|
|
458
|
+
});
|
|
459
|
+
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
460
|
+
ret = ret.expression;
|
|
461
|
+
}
|
|
462
|
+
return (ret.type === 'MemberExpression' ||
|
|
463
|
+
ret.type === 'OptionalMemberExpression' ||
|
|
464
|
+
ret.type === 'Identifier');
|
|
461
465
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
catch (e) {
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
466
|
+
catch (e) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
470
|
const isMemberExpression = isMemberExpressionNode;
|
|
471
471
|
function getInnerRange(loc, offset, length) {
|
|
472
|
-
const source = loc.source.
|
|
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.
|
|
1386
|
+
content = content.slice(1);
|
|
1387
1387
|
}
|
|
1388
1388
|
else {
|
|
1389
|
-
content = content.
|
|
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].
|
|
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.
|
|
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:
|
|
3493
|
+
plugins: context.expressionPlugins
|
|
3487
3494
|
}).program;
|
|
3488
3495
|
}
|
|
3489
3496
|
catch (e) {
|
|
@@ -3818,7 +3825,9 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3818
3825
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3819
3826
|
: keyProp.exp);
|
|
3820
3827
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3821
|
-
if (context.prefixIdentifiers &&
|
|
3828
|
+
if (context.prefixIdentifiers &&
|
|
3829
|
+
keyProperty &&
|
|
3830
|
+
keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
3822
3831
|
// #2085 process :key expression needs to be processed in order for it
|
|
3823
3832
|
// to behave consistently for <template v-for> and <div v-for>.
|
|
3824
3833
|
// In the case of `<template v-for>`, the node is discarded and never
|
|
@@ -451,24 +451,24 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
451
451
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
452
452
|
};
|
|
453
453
|
const isMemberExpressionNode = (path, context) => {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
try {
|
|
455
|
+
let ret = parser.parseExpression(path, {
|
|
456
|
+
plugins: context.expressionPlugins
|
|
457
|
+
});
|
|
458
|
+
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
459
|
+
ret = ret.expression;
|
|
460
|
+
}
|
|
461
|
+
return (ret.type === 'MemberExpression' ||
|
|
462
|
+
ret.type === 'OptionalMemberExpression' ||
|
|
463
|
+
ret.type === 'Identifier');
|
|
460
464
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
catch (e) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
};
|
|
465
|
+
catch (e) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
469
|
const isMemberExpression = isMemberExpressionNode;
|
|
470
470
|
function getInnerRange(loc, offset, length) {
|
|
471
|
-
const source = loc.source.
|
|
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.
|
|
1362
|
+
content = content.slice(1);
|
|
1363
1363
|
}
|
|
1364
1364
|
else {
|
|
1365
|
-
content = content.
|
|
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].
|
|
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.
|
|
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:
|
|
3431
|
+
plugins: context.expressionPlugins
|
|
3425
3432
|
}).program;
|
|
3426
3433
|
}
|
|
3427
3434
|
catch (e) {
|
|
@@ -3737,7 +3744,9 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3737
3744
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3738
3745
|
: keyProp.exp);
|
|
3739
3746
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3740
|
-
if (context.prefixIdentifiers &&
|
|
3747
|
+
if (context.prefixIdentifiers &&
|
|
3748
|
+
keyProperty &&
|
|
3749
|
+
keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
3741
3750
|
// #2085 process :key expression needs to be processed in order for it
|
|
3742
3751
|
// to behave consistently for <template v-for> and <div v-for>.
|
|
3743
3752
|
// In the case of `<template v-for>`, the node is discarded and never
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isString, hyphenate,
|
|
1
|
+
import { isString, hyphenate, NOOP, extend, isObject, NO, isArray, makeMap, isSymbol, EMPTY_OBJ, capitalize, camelize as camelize$1, PatchFlagNames, slotFlagsText, isOn, isReservedProp, toHandlerKey } from '@vue/shared';
|
|
2
2
|
export { generateCodeFrame } from '@vue/shared';
|
|
3
|
-
import { parseExpression } from '@babel/parser';
|
|
4
3
|
|
|
5
4
|
function defaultOnError(error) {
|
|
6
5
|
throw error;
|
|
@@ -447,26 +446,12 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
447
446
|
}
|
|
448
447
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
449
448
|
};
|
|
450
|
-
const isMemberExpressionNode =
|
|
451
|
-
|
|
452
|
-
let ret = parseExpression(path, {
|
|
453
|
-
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
|
|
454
|
-
});
|
|
455
|
-
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
456
|
-
ret = ret.expression;
|
|
457
|
-
}
|
|
458
|
-
return (ret.type === 'MemberExpression' ||
|
|
459
|
-
ret.type === 'OptionalMemberExpression' ||
|
|
460
|
-
ret.type === 'Identifier');
|
|
461
|
-
}
|
|
462
|
-
catch (e) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
};
|
|
449
|
+
const isMemberExpressionNode = NOOP
|
|
450
|
+
;
|
|
466
451
|
const isMemberExpression = isMemberExpressionBrowser
|
|
467
452
|
;
|
|
468
453
|
function getInnerRange(loc, offset, length) {
|
|
469
|
-
const source = loc.source.
|
|
454
|
+
const source = loc.source.slice(offset, offset + length);
|
|
470
455
|
const newLoc = {
|
|
471
456
|
source,
|
|
472
457
|
start: advancePositionWithClone(loc.start, loc.source, offset),
|
|
@@ -1383,10 +1368,10 @@ function parseAttribute(context, nameSet) {
|
|
|
1383
1368
|
isStatic = false;
|
|
1384
1369
|
if (!content.endsWith(']')) {
|
|
1385
1370
|
emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
|
|
1386
|
-
content = content.
|
|
1371
|
+
content = content.slice(1);
|
|
1387
1372
|
}
|
|
1388
1373
|
else {
|
|
1389
|
-
content = content.
|
|
1374
|
+
content = content.slice(1, content.length - 1);
|
|
1390
1375
|
}
|
|
1391
1376
|
}
|
|
1392
1377
|
else if (isSlot) {
|
|
@@ -1412,7 +1397,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1412
1397
|
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1413
1398
|
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1414
1399
|
}
|
|
1415
|
-
const modifiers = match[3] ? match[3].
|
|
1400
|
+
const modifiers = match[3] ? match[3].slice(1).split('.') : [];
|
|
1416
1401
|
if (isPropShorthand)
|
|
1417
1402
|
modifiers.push('prop');
|
|
1418
1403
|
// 2.x compat v-bind:foo.sync -> v-model:foo
|
|
@@ -1633,7 +1618,7 @@ function isEnd(context, mode, ancestors) {
|
|
|
1633
1618
|
}
|
|
1634
1619
|
function startsWithEndTagOpen(source, tag) {
|
|
1635
1620
|
return (startsWith(source, '</') &&
|
|
1636
|
-
source.
|
|
1621
|
+
source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
|
|
1637
1622
|
/[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
|
|
1638
1623
|
}
|
|
1639
1624
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.2.
|
|
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.
|
|
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"
|