@vue/compiler-core 3.5.20 → 3.5.22
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.
- package/dist/compiler-core.cjs.js +138 -101
- package/dist/compiler-core.cjs.prod.js +138 -101
- package/dist/compiler-core.d.ts +5 -2
- package/dist/compiler-core.esm-bundler.js +103 -85
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.22
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1574,16 +1574,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
|
|
|
1574
1574
|
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1575
1575
|
);
|
|
1576
1576
|
}
|
|
1577
|
+
} else if (node.type === "SwitchStatement") {
|
|
1578
|
+
if (node.scopeIds) {
|
|
1579
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1580
|
+
} else {
|
|
1581
|
+
walkSwitchStatement(
|
|
1582
|
+
node,
|
|
1583
|
+
false,
|
|
1584
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1577
1587
|
} else if (node.type === "CatchClause" && node.param) {
|
|
1578
|
-
|
|
1579
|
-
|
|
1588
|
+
if (node.scopeIds) {
|
|
1589
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1590
|
+
} else {
|
|
1591
|
+
for (const id of extractIdentifiers(node.param)) {
|
|
1592
|
+
markScopeIdentifier(node, id, knownIds);
|
|
1593
|
+
}
|
|
1580
1594
|
}
|
|
1581
1595
|
} else if (isForStatement(node)) {
|
|
1582
|
-
|
|
1583
|
-
node,
|
|
1584
|
-
|
|
1585
|
-
(
|
|
1586
|
-
|
|
1596
|
+
if (node.scopeIds) {
|
|
1597
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1598
|
+
} else {
|
|
1599
|
+
walkForStatement(
|
|
1600
|
+
node,
|
|
1601
|
+
false,
|
|
1602
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1587
1605
|
}
|
|
1588
1606
|
},
|
|
1589
1607
|
leave(node, parent) {
|
|
@@ -1654,7 +1672,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1654
1672
|
}
|
|
1655
1673
|
}
|
|
1656
1674
|
function walkBlockDeclarations(block, onIdent) {
|
|
1657
|
-
|
|
1675
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1676
|
+
for (const stmt of body) {
|
|
1658
1677
|
if (stmt.type === "VariableDeclaration") {
|
|
1659
1678
|
if (stmt.declare) continue;
|
|
1660
1679
|
for (const decl of stmt.declarations) {
|
|
@@ -1667,6 +1686,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1667
1686
|
onIdent(stmt.id);
|
|
1668
1687
|
} else if (isForStatement(stmt)) {
|
|
1669
1688
|
walkForStatement(stmt, true, onIdent);
|
|
1689
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1690
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1670
1691
|
}
|
|
1671
1692
|
}
|
|
1672
1693
|
}
|
|
@@ -1683,6 +1704,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1683
1704
|
}
|
|
1684
1705
|
}
|
|
1685
1706
|
}
|
|
1707
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1708
|
+
for (const cs of stmt.cases) {
|
|
1709
|
+
for (const stmt2 of cs.consequent) {
|
|
1710
|
+
if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
|
|
1711
|
+
for (const decl of stmt2.declarations) {
|
|
1712
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
1713
|
+
onIdent(id);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1686
1721
|
function extractIdentifiers(param, nodes = []) {
|
|
1687
1722
|
switch (param.type) {
|
|
1688
1723
|
case "Identifier":
|
|
@@ -1996,7 +2031,7 @@ const isMemberExpressionNode = (exp, context) => {
|
|
|
1996
2031
|
}
|
|
1997
2032
|
};
|
|
1998
2033
|
const isMemberExpression = isMemberExpressionNode;
|
|
1999
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
2034
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
2000
2035
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
2001
2036
|
const isFnExpressionNode = (exp, context) => {
|
|
2002
2037
|
try {
|
|
@@ -4620,7 +4655,7 @@ function isConst(type) {
|
|
|
4620
4655
|
}
|
|
4621
4656
|
|
|
4622
4657
|
const transformIf = createStructuralDirectiveTransform(
|
|
4623
|
-
/^(if|else|else-if)$/,
|
|
4658
|
+
/^(?:if|else|else-if)$/,
|
|
4624
4659
|
(node, dir, context) => {
|
|
4625
4660
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
4626
4661
|
const siblings = context.parent.children;
|
|
@@ -4838,90 +4873,6 @@ function getParentCondition(node) {
|
|
|
4838
4873
|
}
|
|
4839
4874
|
}
|
|
4840
4875
|
|
|
4841
|
-
const transformBind = (dir, _node, context) => {
|
|
4842
|
-
const { modifiers, loc } = dir;
|
|
4843
|
-
const arg = dir.arg;
|
|
4844
|
-
let { exp } = dir;
|
|
4845
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4846
|
-
{
|
|
4847
|
-
context.onError(
|
|
4848
|
-
createCompilerError(34, loc)
|
|
4849
|
-
);
|
|
4850
|
-
return {
|
|
4851
|
-
props: [
|
|
4852
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4853
|
-
]
|
|
4854
|
-
};
|
|
4855
|
-
}
|
|
4856
|
-
}
|
|
4857
|
-
if (!exp) {
|
|
4858
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
4859
|
-
context.onError(
|
|
4860
|
-
createCompilerError(
|
|
4861
|
-
52,
|
|
4862
|
-
arg.loc
|
|
4863
|
-
)
|
|
4864
|
-
);
|
|
4865
|
-
return {
|
|
4866
|
-
props: [
|
|
4867
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4868
|
-
]
|
|
4869
|
-
};
|
|
4870
|
-
}
|
|
4871
|
-
transformBindShorthand(dir, context);
|
|
4872
|
-
exp = dir.exp;
|
|
4873
|
-
}
|
|
4874
|
-
if (arg.type !== 4) {
|
|
4875
|
-
arg.children.unshift(`(`);
|
|
4876
|
-
arg.children.push(`) || ""`);
|
|
4877
|
-
} else if (!arg.isStatic) {
|
|
4878
|
-
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
4879
|
-
}
|
|
4880
|
-
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4881
|
-
if (arg.type === 4) {
|
|
4882
|
-
if (arg.isStatic) {
|
|
4883
|
-
arg.content = shared.camelize(arg.content);
|
|
4884
|
-
} else {
|
|
4885
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4886
|
-
}
|
|
4887
|
-
} else {
|
|
4888
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4889
|
-
arg.children.push(`)`);
|
|
4890
|
-
}
|
|
4891
|
-
}
|
|
4892
|
-
if (!context.inSSR) {
|
|
4893
|
-
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
4894
|
-
injectPrefix(arg, ".");
|
|
4895
|
-
}
|
|
4896
|
-
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
4897
|
-
injectPrefix(arg, "^");
|
|
4898
|
-
}
|
|
4899
|
-
}
|
|
4900
|
-
return {
|
|
4901
|
-
props: [createObjectProperty(arg, exp)]
|
|
4902
|
-
};
|
|
4903
|
-
};
|
|
4904
|
-
const transformBindShorthand = (dir, context) => {
|
|
4905
|
-
const arg = dir.arg;
|
|
4906
|
-
const propName = shared.camelize(arg.content);
|
|
4907
|
-
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4908
|
-
{
|
|
4909
|
-
dir.exp = processExpression(dir.exp, context);
|
|
4910
|
-
}
|
|
4911
|
-
};
|
|
4912
|
-
const injectPrefix = (arg, prefix) => {
|
|
4913
|
-
if (arg.type === 4) {
|
|
4914
|
-
if (arg.isStatic) {
|
|
4915
|
-
arg.content = prefix + arg.content;
|
|
4916
|
-
} else {
|
|
4917
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4918
|
-
}
|
|
4919
|
-
} else {
|
|
4920
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
4921
|
-
arg.children.push(`)`);
|
|
4922
|
-
}
|
|
4923
|
-
};
|
|
4924
|
-
|
|
4925
4876
|
const transformFor = createStructuralDirectiveTransform(
|
|
4926
4877
|
"for",
|
|
4927
4878
|
(node, dir, context) => {
|
|
@@ -4934,9 +4885,6 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4934
4885
|
const memo = findDir(node, "memo");
|
|
4935
4886
|
const keyProp = findProp(node, `key`, false, true);
|
|
4936
4887
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
4937
|
-
if (isDirKey && !keyProp.exp) {
|
|
4938
|
-
transformBindShorthand(keyProp, context);
|
|
4939
|
-
}
|
|
4940
4888
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4941
4889
|
if (memo && keyExp && isDirKey) {
|
|
4942
4890
|
{
|
|
@@ -5217,7 +5165,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5217
5165
|
const dynamicSlots = [];
|
|
5218
5166
|
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
|
5219
5167
|
if (!context.ssr && context.prefixIdentifiers) {
|
|
5220
|
-
hasDynamicSlots =
|
|
5168
|
+
hasDynamicSlots = node.props.some(
|
|
5169
|
+
(prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
|
|
5170
|
+
) || children.some((child) => hasScopeRef(child, context.identifiers));
|
|
5221
5171
|
}
|
|
5222
5172
|
const onComponentSlot = findDir(node, "slot", true);
|
|
5223
5173
|
if (onComponentSlot) {
|
|
@@ -5280,7 +5230,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5280
5230
|
);
|
|
5281
5231
|
} else if (vElse = findDir(
|
|
5282
5232
|
slotElement,
|
|
5283
|
-
/^else(
|
|
5233
|
+
/^else(?:-if)?$/,
|
|
5284
5234
|
true
|
|
5285
5235
|
/* allowEmpty */
|
|
5286
5236
|
)) {
|
|
@@ -5292,7 +5242,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5292
5242
|
break;
|
|
5293
5243
|
}
|
|
5294
5244
|
}
|
|
5295
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
5245
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
5296
5246
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
5297
5247
|
while (conditional.alternate.type === 19) {
|
|
5298
5248
|
conditional = conditional.alternate;
|
|
@@ -6250,6 +6200,65 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
6250
6200
|
return ret;
|
|
6251
6201
|
};
|
|
6252
6202
|
|
|
6203
|
+
const transformBind = (dir, _node, context) => {
|
|
6204
|
+
const { modifiers, loc } = dir;
|
|
6205
|
+
const arg = dir.arg;
|
|
6206
|
+
let { exp } = dir;
|
|
6207
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
6208
|
+
{
|
|
6209
|
+
context.onError(
|
|
6210
|
+
createCompilerError(34, loc)
|
|
6211
|
+
);
|
|
6212
|
+
return {
|
|
6213
|
+
props: [
|
|
6214
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
6215
|
+
]
|
|
6216
|
+
};
|
|
6217
|
+
}
|
|
6218
|
+
}
|
|
6219
|
+
if (arg.type !== 4) {
|
|
6220
|
+
arg.children.unshift(`(`);
|
|
6221
|
+
arg.children.push(`) || ""`);
|
|
6222
|
+
} else if (!arg.isStatic) {
|
|
6223
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
6224
|
+
}
|
|
6225
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
6226
|
+
if (arg.type === 4) {
|
|
6227
|
+
if (arg.isStatic) {
|
|
6228
|
+
arg.content = shared.camelize(arg.content);
|
|
6229
|
+
} else {
|
|
6230
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
6231
|
+
}
|
|
6232
|
+
} else {
|
|
6233
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
6234
|
+
arg.children.push(`)`);
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
if (!context.inSSR) {
|
|
6238
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
6239
|
+
injectPrefix(arg, ".");
|
|
6240
|
+
}
|
|
6241
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
6242
|
+
injectPrefix(arg, "^");
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
return {
|
|
6246
|
+
props: [createObjectProperty(arg, exp)]
|
|
6247
|
+
};
|
|
6248
|
+
};
|
|
6249
|
+
const injectPrefix = (arg, prefix) => {
|
|
6250
|
+
if (arg.type === 4) {
|
|
6251
|
+
if (arg.isStatic) {
|
|
6252
|
+
arg.content = prefix + arg.content;
|
|
6253
|
+
} else {
|
|
6254
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
6255
|
+
}
|
|
6256
|
+
} else {
|
|
6257
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
6258
|
+
arg.children.push(`)`);
|
|
6259
|
+
}
|
|
6260
|
+
};
|
|
6261
|
+
|
|
6253
6262
|
const transformText = (node, context) => {
|
|
6254
6263
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
6255
6264
|
return () => {
|
|
@@ -6605,9 +6614,35 @@ const transformMemo = (node, context) => {
|
|
|
6605
6614
|
}
|
|
6606
6615
|
};
|
|
6607
6616
|
|
|
6617
|
+
const transformVBindShorthand = (node, context) => {
|
|
6618
|
+
if (node.type === 1) {
|
|
6619
|
+
for (const prop of node.props) {
|
|
6620
|
+
if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
|
|
6621
|
+
const arg = prop.arg;
|
|
6622
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
6623
|
+
context.onError(
|
|
6624
|
+
createCompilerError(
|
|
6625
|
+
52,
|
|
6626
|
+
arg.loc
|
|
6627
|
+
)
|
|
6628
|
+
);
|
|
6629
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
6630
|
+
} else {
|
|
6631
|
+
const propName = shared.camelize(arg.content);
|
|
6632
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
6633
|
+
propName[0] === "-") {
|
|
6634
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
}
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
};
|
|
6641
|
+
|
|
6608
6642
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
6609
6643
|
return [
|
|
6610
6644
|
[
|
|
6645
|
+
transformVBindShorthand,
|
|
6611
6646
|
transformOnce,
|
|
6612
6647
|
transformIf,
|
|
6613
6648
|
transformMemo,
|
|
@@ -6819,8 +6854,10 @@ exports.transformElement = transformElement;
|
|
|
6819
6854
|
exports.transformExpression = transformExpression;
|
|
6820
6855
|
exports.transformModel = transformModel;
|
|
6821
6856
|
exports.transformOn = transformOn;
|
|
6857
|
+
exports.transformVBindShorthand = transformVBindShorthand;
|
|
6822
6858
|
exports.traverseNode = traverseNode;
|
|
6823
6859
|
exports.unwrapTSNode = unwrapTSNode;
|
|
6860
|
+
exports.validFirstIdentCharRE = validFirstIdentCharRE;
|
|
6824
6861
|
exports.walkBlockDeclarations = walkBlockDeclarations;
|
|
6825
6862
|
exports.walkFunctionParams = walkFunctionParams;
|
|
6826
6863
|
exports.walkIdentifiers = walkIdentifiers;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.22
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1570,16 +1570,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
|
|
|
1570
1570
|
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1571
1571
|
);
|
|
1572
1572
|
}
|
|
1573
|
+
} else if (node.type === "SwitchStatement") {
|
|
1574
|
+
if (node.scopeIds) {
|
|
1575
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1576
|
+
} else {
|
|
1577
|
+
walkSwitchStatement(
|
|
1578
|
+
node,
|
|
1579
|
+
false,
|
|
1580
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1573
1583
|
} else if (node.type === "CatchClause" && node.param) {
|
|
1574
|
-
|
|
1575
|
-
|
|
1584
|
+
if (node.scopeIds) {
|
|
1585
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1586
|
+
} else {
|
|
1587
|
+
for (const id of extractIdentifiers(node.param)) {
|
|
1588
|
+
markScopeIdentifier(node, id, knownIds);
|
|
1589
|
+
}
|
|
1576
1590
|
}
|
|
1577
1591
|
} else if (isForStatement(node)) {
|
|
1578
|
-
|
|
1579
|
-
node,
|
|
1580
|
-
|
|
1581
|
-
(
|
|
1582
|
-
|
|
1592
|
+
if (node.scopeIds) {
|
|
1593
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1594
|
+
} else {
|
|
1595
|
+
walkForStatement(
|
|
1596
|
+
node,
|
|
1597
|
+
false,
|
|
1598
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1583
1601
|
}
|
|
1584
1602
|
},
|
|
1585
1603
|
leave(node, parent) {
|
|
@@ -1650,7 +1668,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1650
1668
|
}
|
|
1651
1669
|
}
|
|
1652
1670
|
function walkBlockDeclarations(block, onIdent) {
|
|
1653
|
-
|
|
1671
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1672
|
+
for (const stmt of body) {
|
|
1654
1673
|
if (stmt.type === "VariableDeclaration") {
|
|
1655
1674
|
if (stmt.declare) continue;
|
|
1656
1675
|
for (const decl of stmt.declarations) {
|
|
@@ -1663,6 +1682,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1663
1682
|
onIdent(stmt.id);
|
|
1664
1683
|
} else if (isForStatement(stmt)) {
|
|
1665
1684
|
walkForStatement(stmt, true, onIdent);
|
|
1685
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1686
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1666
1687
|
}
|
|
1667
1688
|
}
|
|
1668
1689
|
}
|
|
@@ -1679,6 +1700,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1679
1700
|
}
|
|
1680
1701
|
}
|
|
1681
1702
|
}
|
|
1703
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1704
|
+
for (const cs of stmt.cases) {
|
|
1705
|
+
for (const stmt2 of cs.consequent) {
|
|
1706
|
+
if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
|
|
1707
|
+
for (const decl of stmt2.declarations) {
|
|
1708
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
1709
|
+
onIdent(id);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1682
1717
|
function extractIdentifiers(param, nodes = []) {
|
|
1683
1718
|
switch (param.type) {
|
|
1684
1719
|
case "Identifier":
|
|
@@ -1992,7 +2027,7 @@ const isMemberExpressionNode = (exp, context) => {
|
|
|
1992
2027
|
}
|
|
1993
2028
|
};
|
|
1994
2029
|
const isMemberExpression = isMemberExpressionNode;
|
|
1995
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
2030
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
1996
2031
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
1997
2032
|
const isFnExpressionNode = (exp, context) => {
|
|
1998
2033
|
try {
|
|
@@ -4544,7 +4579,7 @@ function isConst(type) {
|
|
|
4544
4579
|
}
|
|
4545
4580
|
|
|
4546
4581
|
const transformIf = createStructuralDirectiveTransform(
|
|
4547
|
-
/^(if|else|else-if)$/,
|
|
4582
|
+
/^(?:if|else|else-if)$/,
|
|
4548
4583
|
(node, dir, context) => {
|
|
4549
4584
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
4550
4585
|
const siblings = context.parent.children;
|
|
@@ -4753,90 +4788,6 @@ function getParentCondition(node) {
|
|
|
4753
4788
|
}
|
|
4754
4789
|
}
|
|
4755
4790
|
|
|
4756
|
-
const transformBind = (dir, _node, context) => {
|
|
4757
|
-
const { modifiers, loc } = dir;
|
|
4758
|
-
const arg = dir.arg;
|
|
4759
|
-
let { exp } = dir;
|
|
4760
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4761
|
-
{
|
|
4762
|
-
context.onError(
|
|
4763
|
-
createCompilerError(34, loc)
|
|
4764
|
-
);
|
|
4765
|
-
return {
|
|
4766
|
-
props: [
|
|
4767
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4768
|
-
]
|
|
4769
|
-
};
|
|
4770
|
-
}
|
|
4771
|
-
}
|
|
4772
|
-
if (!exp) {
|
|
4773
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
4774
|
-
context.onError(
|
|
4775
|
-
createCompilerError(
|
|
4776
|
-
52,
|
|
4777
|
-
arg.loc
|
|
4778
|
-
)
|
|
4779
|
-
);
|
|
4780
|
-
return {
|
|
4781
|
-
props: [
|
|
4782
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4783
|
-
]
|
|
4784
|
-
};
|
|
4785
|
-
}
|
|
4786
|
-
transformBindShorthand(dir, context);
|
|
4787
|
-
exp = dir.exp;
|
|
4788
|
-
}
|
|
4789
|
-
if (arg.type !== 4) {
|
|
4790
|
-
arg.children.unshift(`(`);
|
|
4791
|
-
arg.children.push(`) || ""`);
|
|
4792
|
-
} else if (!arg.isStatic) {
|
|
4793
|
-
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
4794
|
-
}
|
|
4795
|
-
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4796
|
-
if (arg.type === 4) {
|
|
4797
|
-
if (arg.isStatic) {
|
|
4798
|
-
arg.content = shared.camelize(arg.content);
|
|
4799
|
-
} else {
|
|
4800
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4801
|
-
}
|
|
4802
|
-
} else {
|
|
4803
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4804
|
-
arg.children.push(`)`);
|
|
4805
|
-
}
|
|
4806
|
-
}
|
|
4807
|
-
if (!context.inSSR) {
|
|
4808
|
-
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
4809
|
-
injectPrefix(arg, ".");
|
|
4810
|
-
}
|
|
4811
|
-
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
4812
|
-
injectPrefix(arg, "^");
|
|
4813
|
-
}
|
|
4814
|
-
}
|
|
4815
|
-
return {
|
|
4816
|
-
props: [createObjectProperty(arg, exp)]
|
|
4817
|
-
};
|
|
4818
|
-
};
|
|
4819
|
-
const transformBindShorthand = (dir, context) => {
|
|
4820
|
-
const arg = dir.arg;
|
|
4821
|
-
const propName = shared.camelize(arg.content);
|
|
4822
|
-
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4823
|
-
{
|
|
4824
|
-
dir.exp = processExpression(dir.exp, context);
|
|
4825
|
-
}
|
|
4826
|
-
};
|
|
4827
|
-
const injectPrefix = (arg, prefix) => {
|
|
4828
|
-
if (arg.type === 4) {
|
|
4829
|
-
if (arg.isStatic) {
|
|
4830
|
-
arg.content = prefix + arg.content;
|
|
4831
|
-
} else {
|
|
4832
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4833
|
-
}
|
|
4834
|
-
} else {
|
|
4835
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
4836
|
-
arg.children.push(`)`);
|
|
4837
|
-
}
|
|
4838
|
-
};
|
|
4839
|
-
|
|
4840
4791
|
const transformFor = createStructuralDirectiveTransform(
|
|
4841
4792
|
"for",
|
|
4842
4793
|
(node, dir, context) => {
|
|
@@ -4849,9 +4800,6 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4849
4800
|
const memo = findDir(node, "memo");
|
|
4850
4801
|
const keyProp = findProp(node, `key`, false, true);
|
|
4851
4802
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
4852
|
-
if (isDirKey && !keyProp.exp) {
|
|
4853
|
-
transformBindShorthand(keyProp, context);
|
|
4854
|
-
}
|
|
4855
4803
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4856
4804
|
if (memo && keyExp && isDirKey) {
|
|
4857
4805
|
{
|
|
@@ -5132,7 +5080,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5132
5080
|
const dynamicSlots = [];
|
|
5133
5081
|
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
|
5134
5082
|
if (!context.ssr && context.prefixIdentifiers) {
|
|
5135
|
-
hasDynamicSlots =
|
|
5083
|
+
hasDynamicSlots = node.props.some(
|
|
5084
|
+
(prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
|
|
5085
|
+
) || children.some((child) => hasScopeRef(child, context.identifiers));
|
|
5136
5086
|
}
|
|
5137
5087
|
const onComponentSlot = findDir(node, "slot", true);
|
|
5138
5088
|
if (onComponentSlot) {
|
|
@@ -5195,7 +5145,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5195
5145
|
);
|
|
5196
5146
|
} else if (vElse = findDir(
|
|
5197
5147
|
slotElement,
|
|
5198
|
-
/^else(
|
|
5148
|
+
/^else(?:-if)?$/,
|
|
5199
5149
|
true
|
|
5200
5150
|
/* allowEmpty */
|
|
5201
5151
|
)) {
|
|
@@ -5207,7 +5157,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5207
5157
|
break;
|
|
5208
5158
|
}
|
|
5209
5159
|
}
|
|
5210
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
5160
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
5211
5161
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
5212
5162
|
while (conditional.alternate.type === 19) {
|
|
5213
5163
|
conditional = conditional.alternate;
|
|
@@ -6132,6 +6082,65 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
6132
6082
|
return ret;
|
|
6133
6083
|
};
|
|
6134
6084
|
|
|
6085
|
+
const transformBind = (dir, _node, context) => {
|
|
6086
|
+
const { modifiers, loc } = dir;
|
|
6087
|
+
const arg = dir.arg;
|
|
6088
|
+
let { exp } = dir;
|
|
6089
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
6090
|
+
{
|
|
6091
|
+
context.onError(
|
|
6092
|
+
createCompilerError(34, loc)
|
|
6093
|
+
);
|
|
6094
|
+
return {
|
|
6095
|
+
props: [
|
|
6096
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
6097
|
+
]
|
|
6098
|
+
};
|
|
6099
|
+
}
|
|
6100
|
+
}
|
|
6101
|
+
if (arg.type !== 4) {
|
|
6102
|
+
arg.children.unshift(`(`);
|
|
6103
|
+
arg.children.push(`) || ""`);
|
|
6104
|
+
} else if (!arg.isStatic) {
|
|
6105
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
6106
|
+
}
|
|
6107
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
6108
|
+
if (arg.type === 4) {
|
|
6109
|
+
if (arg.isStatic) {
|
|
6110
|
+
arg.content = shared.camelize(arg.content);
|
|
6111
|
+
} else {
|
|
6112
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
6113
|
+
}
|
|
6114
|
+
} else {
|
|
6115
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
6116
|
+
arg.children.push(`)`);
|
|
6117
|
+
}
|
|
6118
|
+
}
|
|
6119
|
+
if (!context.inSSR) {
|
|
6120
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
6121
|
+
injectPrefix(arg, ".");
|
|
6122
|
+
}
|
|
6123
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
6124
|
+
injectPrefix(arg, "^");
|
|
6125
|
+
}
|
|
6126
|
+
}
|
|
6127
|
+
return {
|
|
6128
|
+
props: [createObjectProperty(arg, exp)]
|
|
6129
|
+
};
|
|
6130
|
+
};
|
|
6131
|
+
const injectPrefix = (arg, prefix) => {
|
|
6132
|
+
if (arg.type === 4) {
|
|
6133
|
+
if (arg.isStatic) {
|
|
6134
|
+
arg.content = prefix + arg.content;
|
|
6135
|
+
} else {
|
|
6136
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
6137
|
+
}
|
|
6138
|
+
} else {
|
|
6139
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
6140
|
+
arg.children.push(`)`);
|
|
6141
|
+
}
|
|
6142
|
+
};
|
|
6143
|
+
|
|
6135
6144
|
const transformText = (node, context) => {
|
|
6136
6145
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
6137
6146
|
return () => {
|
|
@@ -6482,9 +6491,35 @@ const transformMemo = (node, context) => {
|
|
|
6482
6491
|
}
|
|
6483
6492
|
};
|
|
6484
6493
|
|
|
6494
|
+
const transformVBindShorthand = (node, context) => {
|
|
6495
|
+
if (node.type === 1) {
|
|
6496
|
+
for (const prop of node.props) {
|
|
6497
|
+
if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
|
|
6498
|
+
const arg = prop.arg;
|
|
6499
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
6500
|
+
context.onError(
|
|
6501
|
+
createCompilerError(
|
|
6502
|
+
52,
|
|
6503
|
+
arg.loc
|
|
6504
|
+
)
|
|
6505
|
+
);
|
|
6506
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
6507
|
+
} else {
|
|
6508
|
+
const propName = shared.camelize(arg.content);
|
|
6509
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
6510
|
+
propName[0] === "-") {
|
|
6511
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
6512
|
+
}
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
}
|
|
6517
|
+
};
|
|
6518
|
+
|
|
6485
6519
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
6486
6520
|
return [
|
|
6487
6521
|
[
|
|
6522
|
+
transformVBindShorthand,
|
|
6488
6523
|
transformOnce,
|
|
6489
6524
|
transformIf,
|
|
6490
6525
|
transformMemo,
|
|
@@ -6696,8 +6731,10 @@ exports.transformElement = transformElement;
|
|
|
6696
6731
|
exports.transformExpression = transformExpression;
|
|
6697
6732
|
exports.transformModel = transformModel;
|
|
6698
6733
|
exports.transformOn = transformOn;
|
|
6734
|
+
exports.transformVBindShorthand = transformVBindShorthand;
|
|
6699
6735
|
exports.traverseNode = traverseNode;
|
|
6700
6736
|
exports.unwrapTSNode = unwrapTSNode;
|
|
6737
|
+
exports.validFirstIdentCharRE = validFirstIdentCharRE;
|
|
6701
6738
|
exports.walkBlockDeclarations = walkBlockDeclarations;
|
|
6702
6739
|
exports.walkFunctionParams = walkFunctionParams;
|
|
6703
6740
|
exports.walkIdentifiers = walkIdentifiers;
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PatchFlags } from '@vue/shared';
|
|
2
2
|
export { generateCodeFrame } from '@vue/shared';
|
|
3
|
-
import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty } from '@babel/types';
|
|
3
|
+
import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, SwitchCase, Program, ObjectProperty } from '@babel/types';
|
|
4
4
|
import { ParserPlugin } from '@babel/parser';
|
|
5
5
|
|
|
6
6
|
export declare const FRAGMENT: unique symbol;
|
|
@@ -1011,6 +1011,7 @@ export declare function baseCompile(source: string | RootNode, options?: Compile
|
|
|
1011
1011
|
export declare const isStaticExp: (p: JSChildNode) => p is SimpleExpressionNode;
|
|
1012
1012
|
export declare function isCoreComponent(tag: string): symbol | void;
|
|
1013
1013
|
export declare const isSimpleIdentifier: (name: string) => boolean;
|
|
1014
|
+
export declare const validFirstIdentCharRE: RegExp;
|
|
1014
1015
|
/**
|
|
1015
1016
|
* Simple lexer to check if an expression is a member expression. This is
|
|
1016
1017
|
* lax and only checks validity at the root level (i.e. does not validate exps
|
|
@@ -1049,7 +1050,7 @@ export declare function isReferencedIdentifier(id: Identifier, parent: Node$1 |
|
|
|
1049
1050
|
export declare function isInDestructureAssignment(parent: Node$1, parentStack: Node$1[]): boolean;
|
|
1050
1051
|
export declare function isInNewExpression(parentStack: Node$1[]): boolean;
|
|
1051
1052
|
export declare function walkFunctionParams(node: Function, onIdent: (id: Identifier) => void): void;
|
|
1052
|
-
export declare function walkBlockDeclarations(block: BlockStatement$1 | Program, onIdent: (node: Identifier) => void): void;
|
|
1053
|
+
export declare function walkBlockDeclarations(block: BlockStatement$1 | SwitchCase | Program, onIdent: (node: Identifier) => void): void;
|
|
1053
1054
|
export declare function extractIdentifiers(param: Node$1, nodes?: Identifier[]): Identifier[];
|
|
1054
1055
|
export declare const isFunctionType: (node: Node$1) => node is Function;
|
|
1055
1056
|
export declare const isStaticProperty: (node: Node$1) => node is ObjectProperty;
|
|
@@ -1082,6 +1083,8 @@ export declare function buildSlots(node: ElementNode, context: TransformContext,
|
|
|
1082
1083
|
hasDynamicSlots: boolean;
|
|
1083
1084
|
};
|
|
1084
1085
|
|
|
1086
|
+
export declare const transformVBindShorthand: NodeTransform;
|
|
1087
|
+
|
|
1085
1088
|
interface SlotOutletProcessResult {
|
|
1086
1089
|
slotName: string | ExpressionNode;
|
|
1087
1090
|
slotProps: PropsExpression | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.22
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1514,7 +1514,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
}
|
|
1516
1516
|
function walkBlockDeclarations(block, onIdent) {
|
|
1517
|
-
|
|
1517
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1518
|
+
for (const stmt of body) {
|
|
1518
1519
|
if (stmt.type === "VariableDeclaration") {
|
|
1519
1520
|
if (stmt.declare) continue;
|
|
1520
1521
|
for (const decl of stmt.declarations) {
|
|
@@ -1527,6 +1528,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1527
1528
|
onIdent(stmt.id);
|
|
1528
1529
|
} else if (isForStatement(stmt)) {
|
|
1529
1530
|
walkForStatement(stmt, true, onIdent);
|
|
1531
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1532
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1530
1533
|
}
|
|
1531
1534
|
}
|
|
1532
1535
|
}
|
|
@@ -1543,6 +1546,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1543
1546
|
}
|
|
1544
1547
|
}
|
|
1545
1548
|
}
|
|
1549
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1550
|
+
for (const cs of stmt.cases) {
|
|
1551
|
+
for (const stmt2 of cs.consequent) {
|
|
1552
|
+
if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
|
|
1553
|
+
for (const decl of stmt2.declarations) {
|
|
1554
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
1555
|
+
onIdent(id);
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1546
1563
|
function extractIdentifiers(param, nodes = []) {
|
|
1547
1564
|
switch (param.type) {
|
|
1548
1565
|
case "Identifier":
|
|
@@ -1690,7 +1707,7 @@ const isMemberExpressionBrowser = (exp) => {
|
|
|
1690
1707
|
};
|
|
1691
1708
|
const isMemberExpressionNode = NOOP ;
|
|
1692
1709
|
const isMemberExpression = isMemberExpressionBrowser ;
|
|
1693
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
1710
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
1694
1711
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
1695
1712
|
const isFnExpressionNode = NOOP ;
|
|
1696
1713
|
const isFnExpression = isFnExpressionBrowser ;
|
|
@@ -3908,7 +3925,7 @@ function stringifyExpression(exp) {
|
|
|
3908
3925
|
}
|
|
3909
3926
|
|
|
3910
3927
|
const transformIf = createStructuralDirectiveTransform(
|
|
3911
|
-
/^(if|else|else-if)$/,
|
|
3928
|
+
/^(?:if|else|else-if)$/,
|
|
3912
3929
|
(node, dir, context) => {
|
|
3913
3930
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
3914
3931
|
const siblings = context.parent.children;
|
|
@@ -4126,80 +4143,6 @@ function getParentCondition(node) {
|
|
|
4126
4143
|
}
|
|
4127
4144
|
}
|
|
4128
4145
|
|
|
4129
|
-
const transformBind = (dir, _node, context) => {
|
|
4130
|
-
const { modifiers, loc } = dir;
|
|
4131
|
-
const arg = dir.arg;
|
|
4132
|
-
let { exp } = dir;
|
|
4133
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4134
|
-
{
|
|
4135
|
-
exp = void 0;
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
if (!exp) {
|
|
4139
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
4140
|
-
context.onError(
|
|
4141
|
-
createCompilerError(
|
|
4142
|
-
52,
|
|
4143
|
-
arg.loc
|
|
4144
|
-
)
|
|
4145
|
-
);
|
|
4146
|
-
return {
|
|
4147
|
-
props: [
|
|
4148
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4149
|
-
]
|
|
4150
|
-
};
|
|
4151
|
-
}
|
|
4152
|
-
transformBindShorthand(dir);
|
|
4153
|
-
exp = dir.exp;
|
|
4154
|
-
}
|
|
4155
|
-
if (arg.type !== 4) {
|
|
4156
|
-
arg.children.unshift(`(`);
|
|
4157
|
-
arg.children.push(`) || ""`);
|
|
4158
|
-
} else if (!arg.isStatic) {
|
|
4159
|
-
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
4160
|
-
}
|
|
4161
|
-
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4162
|
-
if (arg.type === 4) {
|
|
4163
|
-
if (arg.isStatic) {
|
|
4164
|
-
arg.content = camelize(arg.content);
|
|
4165
|
-
} else {
|
|
4166
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4167
|
-
}
|
|
4168
|
-
} else {
|
|
4169
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4170
|
-
arg.children.push(`)`);
|
|
4171
|
-
}
|
|
4172
|
-
}
|
|
4173
|
-
if (!context.inSSR) {
|
|
4174
|
-
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
4175
|
-
injectPrefix(arg, ".");
|
|
4176
|
-
}
|
|
4177
|
-
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
4178
|
-
injectPrefix(arg, "^");
|
|
4179
|
-
}
|
|
4180
|
-
}
|
|
4181
|
-
return {
|
|
4182
|
-
props: [createObjectProperty(arg, exp)]
|
|
4183
|
-
};
|
|
4184
|
-
};
|
|
4185
|
-
const transformBindShorthand = (dir, context) => {
|
|
4186
|
-
const arg = dir.arg;
|
|
4187
|
-
const propName = camelize(arg.content);
|
|
4188
|
-
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4189
|
-
};
|
|
4190
|
-
const injectPrefix = (arg, prefix) => {
|
|
4191
|
-
if (arg.type === 4) {
|
|
4192
|
-
if (arg.isStatic) {
|
|
4193
|
-
arg.content = prefix + arg.content;
|
|
4194
|
-
} else {
|
|
4195
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4196
|
-
}
|
|
4197
|
-
} else {
|
|
4198
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
4199
|
-
arg.children.push(`)`);
|
|
4200
|
-
}
|
|
4201
|
-
};
|
|
4202
|
-
|
|
4203
4146
|
const transformFor = createStructuralDirectiveTransform(
|
|
4204
4147
|
"for",
|
|
4205
4148
|
(node, dir, context) => {
|
|
@@ -4211,10 +4154,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4211
4154
|
const isTemplate = isTemplateNode(node);
|
|
4212
4155
|
const memo = findDir(node, "memo");
|
|
4213
4156
|
const keyProp = findProp(node, `key`, false, true);
|
|
4214
|
-
|
|
4215
|
-
if (isDirKey && !keyProp.exp) {
|
|
4216
|
-
transformBindShorthand(keyProp);
|
|
4217
|
-
}
|
|
4157
|
+
keyProp && keyProp.type === 7;
|
|
4218
4158
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4219
4159
|
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4220
4160
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
@@ -4514,7 +4454,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4514
4454
|
);
|
|
4515
4455
|
} else if (vElse = findDir(
|
|
4516
4456
|
slotElement,
|
|
4517
|
-
/^else(
|
|
4457
|
+
/^else(?:-if)?$/,
|
|
4518
4458
|
true
|
|
4519
4459
|
/* allowEmpty */
|
|
4520
4460
|
)) {
|
|
@@ -4526,7 +4466,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4526
4466
|
break;
|
|
4527
4467
|
}
|
|
4528
4468
|
}
|
|
4529
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
4469
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
4530
4470
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
4531
4471
|
while (conditional.alternate.type === 19) {
|
|
4532
4472
|
conditional = conditional.alternate;
|
|
@@ -5386,6 +5326,58 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
5386
5326
|
return ret;
|
|
5387
5327
|
};
|
|
5388
5328
|
|
|
5329
|
+
const transformBind = (dir, _node, context) => {
|
|
5330
|
+
const { modifiers, loc } = dir;
|
|
5331
|
+
const arg = dir.arg;
|
|
5332
|
+
let { exp } = dir;
|
|
5333
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
5334
|
+
{
|
|
5335
|
+
exp = void 0;
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
5338
|
+
if (arg.type !== 4) {
|
|
5339
|
+
arg.children.unshift(`(`);
|
|
5340
|
+
arg.children.push(`) || ""`);
|
|
5341
|
+
} else if (!arg.isStatic) {
|
|
5342
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
5343
|
+
}
|
|
5344
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
5345
|
+
if (arg.type === 4) {
|
|
5346
|
+
if (arg.isStatic) {
|
|
5347
|
+
arg.content = camelize(arg.content);
|
|
5348
|
+
} else {
|
|
5349
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
5350
|
+
}
|
|
5351
|
+
} else {
|
|
5352
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
5353
|
+
arg.children.push(`)`);
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
if (!context.inSSR) {
|
|
5357
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
5358
|
+
injectPrefix(arg, ".");
|
|
5359
|
+
}
|
|
5360
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
5361
|
+
injectPrefix(arg, "^");
|
|
5362
|
+
}
|
|
5363
|
+
}
|
|
5364
|
+
return {
|
|
5365
|
+
props: [createObjectProperty(arg, exp)]
|
|
5366
|
+
};
|
|
5367
|
+
};
|
|
5368
|
+
const injectPrefix = (arg, prefix) => {
|
|
5369
|
+
if (arg.type === 4) {
|
|
5370
|
+
if (arg.isStatic) {
|
|
5371
|
+
arg.content = prefix + arg.content;
|
|
5372
|
+
} else {
|
|
5373
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
5374
|
+
}
|
|
5375
|
+
} else {
|
|
5376
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
5377
|
+
arg.children.push(`)`);
|
|
5378
|
+
}
|
|
5379
|
+
};
|
|
5380
|
+
|
|
5389
5381
|
const transformText = (node, context) => {
|
|
5390
5382
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
5391
5383
|
return () => {
|
|
@@ -5716,9 +5708,35 @@ const transformMemo = (node, context) => {
|
|
|
5716
5708
|
}
|
|
5717
5709
|
};
|
|
5718
5710
|
|
|
5711
|
+
const transformVBindShorthand = (node, context) => {
|
|
5712
|
+
if (node.type === 1) {
|
|
5713
|
+
for (const prop of node.props) {
|
|
5714
|
+
if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
|
|
5715
|
+
const arg = prop.arg;
|
|
5716
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
5717
|
+
context.onError(
|
|
5718
|
+
createCompilerError(
|
|
5719
|
+
52,
|
|
5720
|
+
arg.loc
|
|
5721
|
+
)
|
|
5722
|
+
);
|
|
5723
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
5724
|
+
} else {
|
|
5725
|
+
const propName = camelize(arg.content);
|
|
5726
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
5727
|
+
propName[0] === "-") {
|
|
5728
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
5734
|
+
};
|
|
5735
|
+
|
|
5719
5736
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
5720
5737
|
return [
|
|
5721
5738
|
[
|
|
5739
|
+
transformVBindShorthand,
|
|
5722
5740
|
transformOnce,
|
|
5723
5741
|
transformIf,
|
|
5724
5742
|
transformMemo,
|
|
@@ -5793,4 +5811,4 @@ const BindingTypes = {
|
|
|
5793
5811
|
|
|
5794
5812
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
5795
5813
|
|
|
5796
|
-
export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
|
5814
|
+
export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.22",
|
|
4
4
|
"description": "@vue/compiler-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/compiler-core.esm-bundler.js",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@babel/parser": "^7.28.
|
|
49
|
+
"@babel/parser": "^7.28.4",
|
|
50
50
|
"entities": "^4.5.0",
|
|
51
51
|
"estree-walker": "^2.0.2",
|
|
52
52
|
"source-map-js": "^1.2.1",
|
|
53
|
-
"@vue/shared": "3.5.
|
|
53
|
+
"@vue/shared": "3.5.22"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/types": "^7.28.
|
|
56
|
+
"@babel/types": "^7.28.4"
|
|
57
57
|
}
|
|
58
58
|
}
|