@vue/compiler-core 3.6.0-alpha.2 → 3.6.0-alpha.4
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 +162 -134
- package/dist/compiler-core.cjs.prod.js +162 -134
- package/dist/compiler-core.d.ts +9 -11
- package/dist/compiler-core.esm-bundler.js +120 -115
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.6.0-alpha.
|
|
2
|
+
* @vue/compiler-core v3.6.0-alpha.4
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -135,14 +135,6 @@ function registerRuntimeHelpers(helpers) {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const Namespaces = {
|
|
139
|
-
"HTML": 0,
|
|
140
|
-
"0": "HTML",
|
|
141
|
-
"SVG": 1,
|
|
142
|
-
"1": "SVG",
|
|
143
|
-
"MATH_ML": 2,
|
|
144
|
-
"2": "MATH_ML"
|
|
145
|
-
};
|
|
146
138
|
const NodeTypes = {
|
|
147
139
|
"ROOT": 0,
|
|
148
140
|
"0": "ROOT",
|
|
@@ -1574,16 +1566,34 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
|
|
|
1574
1566
|
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1575
1567
|
);
|
|
1576
1568
|
}
|
|
1569
|
+
} else if (node.type === "SwitchStatement") {
|
|
1570
|
+
if (node.scopeIds) {
|
|
1571
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1572
|
+
} else {
|
|
1573
|
+
walkSwitchStatement(
|
|
1574
|
+
node,
|
|
1575
|
+
false,
|
|
1576
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1577
1579
|
} else if (node.type === "CatchClause" && node.param) {
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
+
if (node.scopeIds) {
|
|
1581
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1582
|
+
} else {
|
|
1583
|
+
for (const id of extractIdentifiers(node.param)) {
|
|
1584
|
+
markScopeIdentifier(node, id, knownIds);
|
|
1585
|
+
}
|
|
1580
1586
|
}
|
|
1581
1587
|
} else if (isForStatement(node)) {
|
|
1582
|
-
|
|
1583
|
-
node,
|
|
1584
|
-
|
|
1585
|
-
(
|
|
1586
|
-
|
|
1588
|
+
if (node.scopeIds) {
|
|
1589
|
+
node.scopeIds.forEach((id) => markKnownIds(id, knownIds));
|
|
1590
|
+
} else {
|
|
1591
|
+
walkForStatement(
|
|
1592
|
+
node,
|
|
1593
|
+
false,
|
|
1594
|
+
(id) => markScopeIdentifier(node, id, knownIds)
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1587
1597
|
}
|
|
1588
1598
|
},
|
|
1589
1599
|
leave(node, parent) {
|
|
@@ -1606,14 +1616,15 @@ function isReferencedIdentifier(id, parent, parentStack) {
|
|
|
1606
1616
|
if (id.name === "arguments") {
|
|
1607
1617
|
return false;
|
|
1608
1618
|
}
|
|
1609
|
-
if (isReferenced(id, parent)) {
|
|
1619
|
+
if (isReferenced(id, parent, parentStack[parentStack.length - 2])) {
|
|
1610
1620
|
return true;
|
|
1611
1621
|
}
|
|
1612
1622
|
switch (parent.type) {
|
|
1613
1623
|
case "AssignmentExpression":
|
|
1614
1624
|
case "AssignmentPattern":
|
|
1615
1625
|
return true;
|
|
1616
|
-
case "
|
|
1626
|
+
case "ObjectProperty":
|
|
1627
|
+
return parent.key !== id && isInDestructureAssignment(parent, parentStack);
|
|
1617
1628
|
case "ArrayPattern":
|
|
1618
1629
|
return isInDestructureAssignment(parent, parentStack);
|
|
1619
1630
|
}
|
|
@@ -1653,7 +1664,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1653
1664
|
}
|
|
1654
1665
|
}
|
|
1655
1666
|
function walkBlockDeclarations(block, onIdent) {
|
|
1656
|
-
|
|
1667
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1668
|
+
for (const stmt of body) {
|
|
1657
1669
|
if (stmt.type === "VariableDeclaration") {
|
|
1658
1670
|
if (stmt.declare) continue;
|
|
1659
1671
|
for (const decl of stmt.declarations) {
|
|
@@ -1666,6 +1678,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1666
1678
|
onIdent(stmt.id);
|
|
1667
1679
|
} else if (isForStatement(stmt)) {
|
|
1668
1680
|
walkForStatement(stmt, true, onIdent);
|
|
1681
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1682
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1669
1683
|
}
|
|
1670
1684
|
}
|
|
1671
1685
|
}
|
|
@@ -1682,6 +1696,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1682
1696
|
}
|
|
1683
1697
|
}
|
|
1684
1698
|
}
|
|
1699
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1700
|
+
for (const cs of stmt.cases) {
|
|
1701
|
+
for (const stmt2 of cs.consequent) {
|
|
1702
|
+
if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
|
|
1703
|
+
for (const decl of stmt2.declarations) {
|
|
1704
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
1705
|
+
onIdent(id);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1685
1713
|
function extractIdentifiers(param, nodes = []) {
|
|
1686
1714
|
switch (param.type) {
|
|
1687
1715
|
case "Identifier":
|
|
@@ -1782,7 +1810,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1782
1810
|
if (parent.key === node) {
|
|
1783
1811
|
return !!parent.computed;
|
|
1784
1812
|
}
|
|
1785
|
-
return
|
|
1813
|
+
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
1786
1814
|
// no: class { NODE = value; }
|
|
1787
1815
|
// yes: class { [NODE] = value; }
|
|
1788
1816
|
// yes: class { key = NODE; }
|
|
@@ -1832,6 +1860,9 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1832
1860
|
// yes: export { NODE as foo };
|
|
1833
1861
|
// no: export { NODE as foo } from "foo";
|
|
1834
1862
|
case "ExportSpecifier":
|
|
1863
|
+
if (grandparent == null ? void 0 : grandparent.source) {
|
|
1864
|
+
return false;
|
|
1865
|
+
}
|
|
1835
1866
|
return parent.local === node;
|
|
1836
1867
|
// no: import NODE from "foo";
|
|
1837
1868
|
// no: import * as NODE from "foo";
|
|
@@ -1965,7 +1996,7 @@ function isCoreComponent(tag) {
|
|
|
1965
1996
|
return BASE_TRANSITION;
|
|
1966
1997
|
}
|
|
1967
1998
|
}
|
|
1968
|
-
const nonIdentifierRE =
|
|
1999
|
+
const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1969
2000
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1970
2001
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1971
2002
|
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
@@ -2045,7 +2076,7 @@ const isMemberExpressionNode = (exp, context) => {
|
|
|
2045
2076
|
}
|
|
2046
2077
|
};
|
|
2047
2078
|
const isMemberExpression = isMemberExpressionNode;
|
|
2048
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
2079
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
2049
2080
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
2050
2081
|
const isFnExpressionNode = (exp, context) => {
|
|
2051
2082
|
try {
|
|
@@ -2130,6 +2161,9 @@ function hasDynamicKeyVBind(node) {
|
|
|
2130
2161
|
function isText$1(node) {
|
|
2131
2162
|
return node.type === 5 || node.type === 2;
|
|
2132
2163
|
}
|
|
2164
|
+
function isVPre(p) {
|
|
2165
|
+
return p.type === 7 && p.name === "pre";
|
|
2166
|
+
}
|
|
2133
2167
|
function isVSlot(p) {
|
|
2134
2168
|
return p.type === 7 && p.name === "slot";
|
|
2135
2169
|
}
|
|
@@ -2428,7 +2462,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2428
2462
|
ondirarg(start, end) {
|
|
2429
2463
|
if (start === end) return;
|
|
2430
2464
|
const arg = getSlice(start, end);
|
|
2431
|
-
if (inVPre) {
|
|
2465
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2432
2466
|
currentProp.name += arg;
|
|
2433
2467
|
setLocEnd(currentProp.nameLoc, end);
|
|
2434
2468
|
} else {
|
|
@@ -2443,7 +2477,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2443
2477
|
},
|
|
2444
2478
|
ondirmodifier(start, end) {
|
|
2445
2479
|
const mod = getSlice(start, end);
|
|
2446
|
-
if (inVPre) {
|
|
2480
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2447
2481
|
currentProp.name += "." + mod;
|
|
2448
2482
|
setLocEnd(currentProp.nameLoc, end);
|
|
2449
2483
|
} else if (currentProp.name === "slot") {
|
|
@@ -3090,6 +3124,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3090
3124
|
} else if (child.type === 12) {
|
|
3091
3125
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
3092
3126
|
if (constantType >= 2) {
|
|
3127
|
+
if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
|
|
3128
|
+
child.codegenNode.arguments.push(
|
|
3129
|
+
-1 + (` /* ${shared.PatchFlagNames[-1]} */` )
|
|
3130
|
+
);
|
|
3131
|
+
}
|
|
3093
3132
|
toCache.push(child);
|
|
3094
3133
|
continue;
|
|
3095
3134
|
}
|
|
@@ -3118,7 +3157,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3118
3157
|
}
|
|
3119
3158
|
}
|
|
3120
3159
|
let cachedAsArray = false;
|
|
3121
|
-
const slotCacheKeys = [];
|
|
3122
3160
|
if (toCache.length === children.length && node.type === 1) {
|
|
3123
3161
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
3124
3162
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -3128,7 +3166,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3128
3166
|
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3129
3167
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
3130
3168
|
if (slot) {
|
|
3131
|
-
slotCacheKeys.push(context.cached.length);
|
|
3132
3169
|
slot.returns = getCacheExpression(
|
|
3133
3170
|
createArrayExpression(slot.returns)
|
|
3134
3171
|
);
|
|
@@ -3138,7 +3175,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3138
3175
|
const slotName = findDir(node, "slot", true);
|
|
3139
3176
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
3140
3177
|
if (slot) {
|
|
3141
|
-
slotCacheKeys.push(context.cached.length);
|
|
3142
3178
|
slot.returns = getCacheExpression(
|
|
3143
3179
|
createArrayExpression(slot.returns)
|
|
3144
3180
|
);
|
|
@@ -3148,23 +3184,12 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3148
3184
|
}
|
|
3149
3185
|
if (!cachedAsArray) {
|
|
3150
3186
|
for (const child of toCache) {
|
|
3151
|
-
slotCacheKeys.push(context.cached.length);
|
|
3152
3187
|
child.codegenNode = context.cache(child.codegenNode);
|
|
3153
3188
|
}
|
|
3154
3189
|
}
|
|
3155
|
-
if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3156
|
-
node.codegenNode.children.properties.push(
|
|
3157
|
-
createObjectProperty(
|
|
3158
|
-
`__`,
|
|
3159
|
-
createSimpleExpression(JSON.stringify(slotCacheKeys), false)
|
|
3160
|
-
)
|
|
3161
|
-
);
|
|
3162
|
-
}
|
|
3163
3190
|
function getCacheExpression(value) {
|
|
3164
3191
|
const exp = context.cache(value);
|
|
3165
|
-
|
|
3166
|
-
exp.needArraySpread = true;
|
|
3167
|
-
}
|
|
3192
|
+
exp.needArraySpread = true;
|
|
3168
3193
|
return exp;
|
|
3169
3194
|
}
|
|
3170
3195
|
function getSlotNode(node2, name) {
|
|
@@ -4689,7 +4714,7 @@ function isConst(type) {
|
|
|
4689
4714
|
}
|
|
4690
4715
|
|
|
4691
4716
|
const transformIf = createStructuralDirectiveTransform(
|
|
4692
|
-
/^(if|else|else-if)$/,
|
|
4717
|
+
/^(?:if|else|else-if)$/,
|
|
4693
4718
|
(node, dir, context) => {
|
|
4694
4719
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
4695
4720
|
const siblings = context.parent.children;
|
|
@@ -4758,7 +4783,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
4758
4783
|
continue;
|
|
4759
4784
|
}
|
|
4760
4785
|
if (sibling && sibling.type === 9) {
|
|
4761
|
-
if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4786
|
+
if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4762
4787
|
context.onError(
|
|
4763
4788
|
createCompilerError(30, node.loc)
|
|
4764
4789
|
);
|
|
@@ -4907,90 +4932,6 @@ function getParentCondition(node) {
|
|
|
4907
4932
|
}
|
|
4908
4933
|
}
|
|
4909
4934
|
|
|
4910
|
-
const transformBind = (dir, _node, context) => {
|
|
4911
|
-
const { modifiers, loc } = dir;
|
|
4912
|
-
const arg = dir.arg;
|
|
4913
|
-
let { exp } = dir;
|
|
4914
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4915
|
-
{
|
|
4916
|
-
context.onError(
|
|
4917
|
-
createCompilerError(34, loc)
|
|
4918
|
-
);
|
|
4919
|
-
return {
|
|
4920
|
-
props: [
|
|
4921
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4922
|
-
]
|
|
4923
|
-
};
|
|
4924
|
-
}
|
|
4925
|
-
}
|
|
4926
|
-
if (!exp) {
|
|
4927
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
4928
|
-
context.onError(
|
|
4929
|
-
createCompilerError(
|
|
4930
|
-
52,
|
|
4931
|
-
arg.loc
|
|
4932
|
-
)
|
|
4933
|
-
);
|
|
4934
|
-
return {
|
|
4935
|
-
props: [
|
|
4936
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4937
|
-
]
|
|
4938
|
-
};
|
|
4939
|
-
}
|
|
4940
|
-
transformBindShorthand(dir, context);
|
|
4941
|
-
exp = dir.exp;
|
|
4942
|
-
}
|
|
4943
|
-
if (arg.type !== 4) {
|
|
4944
|
-
arg.children.unshift(`(`);
|
|
4945
|
-
arg.children.push(`) || ""`);
|
|
4946
|
-
} else if (!arg.isStatic) {
|
|
4947
|
-
arg.content = `${arg.content} || ""`;
|
|
4948
|
-
}
|
|
4949
|
-
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4950
|
-
if (arg.type === 4) {
|
|
4951
|
-
if (arg.isStatic) {
|
|
4952
|
-
arg.content = shared.camelize(arg.content);
|
|
4953
|
-
} else {
|
|
4954
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4955
|
-
}
|
|
4956
|
-
} else {
|
|
4957
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4958
|
-
arg.children.push(`)`);
|
|
4959
|
-
}
|
|
4960
|
-
}
|
|
4961
|
-
if (!context.inSSR) {
|
|
4962
|
-
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
4963
|
-
injectPrefix(arg, ".");
|
|
4964
|
-
}
|
|
4965
|
-
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
4966
|
-
injectPrefix(arg, "^");
|
|
4967
|
-
}
|
|
4968
|
-
}
|
|
4969
|
-
return {
|
|
4970
|
-
props: [createObjectProperty(arg, exp)]
|
|
4971
|
-
};
|
|
4972
|
-
};
|
|
4973
|
-
const transformBindShorthand = (dir, context) => {
|
|
4974
|
-
const arg = dir.arg;
|
|
4975
|
-
const propName = shared.camelize(arg.content);
|
|
4976
|
-
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4977
|
-
{
|
|
4978
|
-
dir.exp = processExpression(dir.exp, context);
|
|
4979
|
-
}
|
|
4980
|
-
};
|
|
4981
|
-
const injectPrefix = (arg, prefix) => {
|
|
4982
|
-
if (arg.type === 4) {
|
|
4983
|
-
if (arg.isStatic) {
|
|
4984
|
-
arg.content = prefix + arg.content;
|
|
4985
|
-
} else {
|
|
4986
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4987
|
-
}
|
|
4988
|
-
} else {
|
|
4989
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
4990
|
-
arg.children.push(`)`);
|
|
4991
|
-
}
|
|
4992
|
-
};
|
|
4993
|
-
|
|
4994
4935
|
const transformFor = createStructuralDirectiveTransform(
|
|
4995
4936
|
"for",
|
|
4996
4937
|
(node, dir, context) => {
|
|
@@ -5003,9 +4944,6 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
5003
4944
|
const memo = findDir(node, "memo");
|
|
5004
4945
|
const keyProp = findProp(node, `key`, false, true);
|
|
5005
4946
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
5006
|
-
if (isDirKey && !keyProp.exp) {
|
|
5007
|
-
transformBindShorthand(keyProp, context);
|
|
5008
|
-
}
|
|
5009
4947
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
5010
4948
|
if (memo && keyExp && isDirKey) {
|
|
5011
4949
|
{
|
|
@@ -5286,7 +5224,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5286
5224
|
const dynamicSlots = [];
|
|
5287
5225
|
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
|
5288
5226
|
if (!context.ssr && context.prefixIdentifiers) {
|
|
5289
|
-
hasDynamicSlots =
|
|
5227
|
+
hasDynamicSlots = node.props.some(
|
|
5228
|
+
(prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
|
|
5229
|
+
) || children.some((child) => hasScopeRef(child, context.identifiers));
|
|
5290
5230
|
}
|
|
5291
5231
|
const onComponentSlot = findDir(node, "slot", true);
|
|
5292
5232
|
if (onComponentSlot) {
|
|
@@ -5349,7 +5289,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5349
5289
|
);
|
|
5350
5290
|
} else if (vElse = findDir(
|
|
5351
5291
|
slotElement,
|
|
5352
|
-
/^else(
|
|
5292
|
+
/^else(?:-if)?$/,
|
|
5353
5293
|
true
|
|
5354
5294
|
/* allowEmpty */
|
|
5355
5295
|
)) {
|
|
@@ -5361,7 +5301,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5361
5301
|
break;
|
|
5362
5302
|
}
|
|
5363
5303
|
}
|
|
5364
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
5304
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
5365
5305
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
5366
5306
|
while (conditional.alternate.type === 19) {
|
|
5367
5307
|
conditional = conditional.alternate;
|
|
@@ -6319,6 +6259,65 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
6319
6259
|
return ret;
|
|
6320
6260
|
};
|
|
6321
6261
|
|
|
6262
|
+
const transformBind = (dir, _node, context) => {
|
|
6263
|
+
const { modifiers, loc } = dir;
|
|
6264
|
+
const arg = dir.arg;
|
|
6265
|
+
let { exp } = dir;
|
|
6266
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
6267
|
+
{
|
|
6268
|
+
context.onError(
|
|
6269
|
+
createCompilerError(34, loc)
|
|
6270
|
+
);
|
|
6271
|
+
return {
|
|
6272
|
+
props: [
|
|
6273
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
6274
|
+
]
|
|
6275
|
+
};
|
|
6276
|
+
}
|
|
6277
|
+
}
|
|
6278
|
+
if (arg.type !== 4) {
|
|
6279
|
+
arg.children.unshift(`(`);
|
|
6280
|
+
arg.children.push(`) || ""`);
|
|
6281
|
+
} else if (!arg.isStatic) {
|
|
6282
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
6283
|
+
}
|
|
6284
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
6285
|
+
if (arg.type === 4) {
|
|
6286
|
+
if (arg.isStatic) {
|
|
6287
|
+
arg.content = shared.camelize(arg.content);
|
|
6288
|
+
} else {
|
|
6289
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
6290
|
+
}
|
|
6291
|
+
} else {
|
|
6292
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
6293
|
+
arg.children.push(`)`);
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
if (!context.inSSR) {
|
|
6297
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
6298
|
+
injectPrefix(arg, ".");
|
|
6299
|
+
}
|
|
6300
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
6301
|
+
injectPrefix(arg, "^");
|
|
6302
|
+
}
|
|
6303
|
+
}
|
|
6304
|
+
return {
|
|
6305
|
+
props: [createObjectProperty(arg, exp)]
|
|
6306
|
+
};
|
|
6307
|
+
};
|
|
6308
|
+
const injectPrefix = (arg, prefix) => {
|
|
6309
|
+
if (arg.type === 4) {
|
|
6310
|
+
if (arg.isStatic) {
|
|
6311
|
+
arg.content = prefix + arg.content;
|
|
6312
|
+
} else {
|
|
6313
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
6314
|
+
}
|
|
6315
|
+
} else {
|
|
6316
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
6317
|
+
arg.children.push(`)`);
|
|
6318
|
+
}
|
|
6319
|
+
};
|
|
6320
|
+
|
|
6322
6321
|
const transformText = (node, context) => {
|
|
6323
6322
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
6324
6323
|
return () => {
|
|
@@ -6480,7 +6479,7 @@ const transformModel = (dir, node, context) => {
|
|
|
6480
6479
|
}
|
|
6481
6480
|
if (dir.modifiers.length && node.tagType === 1) {
|
|
6482
6481
|
const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
|
6483
|
-
const modifiersKey = arg ? isStaticExp(arg) ?
|
|
6482
|
+
const modifiersKey = arg ? isStaticExp(arg) ? shared.getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
|
6484
6483
|
props.push(
|
|
6485
6484
|
createObjectProperty(
|
|
6486
6485
|
modifiersKey,
|
|
@@ -6652,7 +6651,7 @@ const seen = /* @__PURE__ */ new WeakSet();
|
|
|
6652
6651
|
const transformMemo = (node, context) => {
|
|
6653
6652
|
if (node.type === 1) {
|
|
6654
6653
|
const dir = findDir(node, "memo");
|
|
6655
|
-
if (!dir || seen.has(node)) {
|
|
6654
|
+
if (!dir || seen.has(node) || context.inSSR) {
|
|
6656
6655
|
return;
|
|
6657
6656
|
}
|
|
6658
6657
|
seen.add(node);
|
|
@@ -6674,9 +6673,36 @@ const transformMemo = (node, context) => {
|
|
|
6674
6673
|
}
|
|
6675
6674
|
};
|
|
6676
6675
|
|
|
6676
|
+
const transformVBindShorthand = (node, context) => {
|
|
6677
|
+
if (node.type === 1) {
|
|
6678
|
+
for (const prop of node.props) {
|
|
6679
|
+
if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
|
|
6680
|
+
false) && prop.arg) {
|
|
6681
|
+
const arg = prop.arg;
|
|
6682
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
6683
|
+
context.onError(
|
|
6684
|
+
createCompilerError(
|
|
6685
|
+
52,
|
|
6686
|
+
arg.loc
|
|
6687
|
+
)
|
|
6688
|
+
);
|
|
6689
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
6690
|
+
} else {
|
|
6691
|
+
const propName = shared.camelize(arg.content);
|
|
6692
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
6693
|
+
propName[0] === "-") {
|
|
6694
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
};
|
|
6701
|
+
|
|
6677
6702
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
6678
6703
|
return [
|
|
6679
6704
|
[
|
|
6705
|
+
transformVBindShorthand,
|
|
6680
6706
|
transformOnce,
|
|
6681
6707
|
transformIf,
|
|
6682
6708
|
transformMemo,
|
|
@@ -6780,7 +6806,6 @@ exports.MERGE_PROPS = MERGE_PROPS;
|
|
|
6780
6806
|
exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
|
|
6781
6807
|
exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
|
|
6782
6808
|
exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
|
|
6783
|
-
exports.Namespaces = Namespaces;
|
|
6784
6809
|
exports.NewlineType = NewlineType;
|
|
6785
6810
|
exports.NodeTypes = NodeTypes;
|
|
6786
6811
|
exports.OPEN_BLOCK = OPEN_BLOCK;
|
|
@@ -6875,6 +6900,7 @@ exports.isStaticProperty = isStaticProperty;
|
|
|
6875
6900
|
exports.isStaticPropertyKey = isStaticPropertyKey;
|
|
6876
6901
|
exports.isTemplateNode = isTemplateNode;
|
|
6877
6902
|
exports.isText = isText$1;
|
|
6903
|
+
exports.isVPre = isVPre;
|
|
6878
6904
|
exports.isVSlot = isVSlot;
|
|
6879
6905
|
exports.locStub = locStub;
|
|
6880
6906
|
exports.noopDirectiveTransform = noopDirectiveTransform;
|
|
@@ -6894,8 +6920,10 @@ exports.transformElement = transformElement;
|
|
|
6894
6920
|
exports.transformExpression = transformExpression;
|
|
6895
6921
|
exports.transformModel = transformModel;
|
|
6896
6922
|
exports.transformOn = transformOn;
|
|
6923
|
+
exports.transformVBindShorthand = transformVBindShorthand;
|
|
6897
6924
|
exports.traverseNode = traverseNode;
|
|
6898
6925
|
exports.unwrapTSNode = unwrapTSNode;
|
|
6926
|
+
exports.validFirstIdentCharRE = validFirstIdentCharRE;
|
|
6899
6927
|
exports.walkBlockDeclarations = walkBlockDeclarations;
|
|
6900
6928
|
exports.walkFunctionParams = walkFunctionParams;
|
|
6901
6929
|
exports.walkIdentifiers = walkIdentifiers;
|