@vue/compiler-core 3.6.0-alpha.2 → 3.6.0-alpha.3
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 +168 -128
- package/dist/compiler-core.cjs.prod.js +168 -128
- package/dist/compiler-core.d.ts +6 -2
- package/dist/compiler-core.esm-bundler.js +119 -106
- 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.3
|
|
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) {
|
|
@@ -1606,14 +1624,15 @@ function isReferencedIdentifier(id, parent, parentStack) {
|
|
|
1606
1624
|
if (id.name === "arguments") {
|
|
1607
1625
|
return false;
|
|
1608
1626
|
}
|
|
1609
|
-
if (isReferenced(id, parent)) {
|
|
1627
|
+
if (isReferenced(id, parent, parentStack[parentStack.length - 2])) {
|
|
1610
1628
|
return true;
|
|
1611
1629
|
}
|
|
1612
1630
|
switch (parent.type) {
|
|
1613
1631
|
case "AssignmentExpression":
|
|
1614
1632
|
case "AssignmentPattern":
|
|
1615
1633
|
return true;
|
|
1616
|
-
case "
|
|
1634
|
+
case "ObjectProperty":
|
|
1635
|
+
return parent.key !== id && isInDestructureAssignment(parent, parentStack);
|
|
1617
1636
|
case "ArrayPattern":
|
|
1618
1637
|
return isInDestructureAssignment(parent, parentStack);
|
|
1619
1638
|
}
|
|
@@ -1653,7 +1672,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1653
1672
|
}
|
|
1654
1673
|
}
|
|
1655
1674
|
function walkBlockDeclarations(block, onIdent) {
|
|
1656
|
-
|
|
1675
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1676
|
+
for (const stmt of body) {
|
|
1657
1677
|
if (stmt.type === "VariableDeclaration") {
|
|
1658
1678
|
if (stmt.declare) continue;
|
|
1659
1679
|
for (const decl of stmt.declarations) {
|
|
@@ -1666,6 +1686,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1666
1686
|
onIdent(stmt.id);
|
|
1667
1687
|
} else if (isForStatement(stmt)) {
|
|
1668
1688
|
walkForStatement(stmt, true, onIdent);
|
|
1689
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1690
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1669
1691
|
}
|
|
1670
1692
|
}
|
|
1671
1693
|
}
|
|
@@ -1682,6 +1704,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1682
1704
|
}
|
|
1683
1705
|
}
|
|
1684
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
|
+
}
|
|
1685
1721
|
function extractIdentifiers(param, nodes = []) {
|
|
1686
1722
|
switch (param.type) {
|
|
1687
1723
|
case "Identifier":
|
|
@@ -1782,7 +1818,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1782
1818
|
if (parent.key === node) {
|
|
1783
1819
|
return !!parent.computed;
|
|
1784
1820
|
}
|
|
1785
|
-
return
|
|
1821
|
+
return !grandparent || grandparent.type !== "ObjectPattern";
|
|
1786
1822
|
// no: class { NODE = value; }
|
|
1787
1823
|
// yes: class { [NODE] = value; }
|
|
1788
1824
|
// yes: class { key = NODE; }
|
|
@@ -1832,6 +1868,9 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1832
1868
|
// yes: export { NODE as foo };
|
|
1833
1869
|
// no: export { NODE as foo } from "foo";
|
|
1834
1870
|
case "ExportSpecifier":
|
|
1871
|
+
if (grandparent == null ? void 0 : grandparent.source) {
|
|
1872
|
+
return false;
|
|
1873
|
+
}
|
|
1835
1874
|
return parent.local === node;
|
|
1836
1875
|
// no: import NODE from "foo";
|
|
1837
1876
|
// no: import * as NODE from "foo";
|
|
@@ -1965,7 +2004,7 @@ function isCoreComponent(tag) {
|
|
|
1965
2004
|
return BASE_TRANSITION;
|
|
1966
2005
|
}
|
|
1967
2006
|
}
|
|
1968
|
-
const nonIdentifierRE =
|
|
2007
|
+
const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1969
2008
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1970
2009
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1971
2010
|
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
@@ -2045,7 +2084,7 @@ const isMemberExpressionNode = (exp, context) => {
|
|
|
2045
2084
|
}
|
|
2046
2085
|
};
|
|
2047
2086
|
const isMemberExpression = isMemberExpressionNode;
|
|
2048
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
2087
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
2049
2088
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
2050
2089
|
const isFnExpressionNode = (exp, context) => {
|
|
2051
2090
|
try {
|
|
@@ -2130,6 +2169,9 @@ function hasDynamicKeyVBind(node) {
|
|
|
2130
2169
|
function isText$1(node) {
|
|
2131
2170
|
return node.type === 5 || node.type === 2;
|
|
2132
2171
|
}
|
|
2172
|
+
function isVPre(p) {
|
|
2173
|
+
return p.type === 7 && p.name === "pre";
|
|
2174
|
+
}
|
|
2133
2175
|
function isVSlot(p) {
|
|
2134
2176
|
return p.type === 7 && p.name === "slot";
|
|
2135
2177
|
}
|
|
@@ -2428,7 +2470,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2428
2470
|
ondirarg(start, end) {
|
|
2429
2471
|
if (start === end) return;
|
|
2430
2472
|
const arg = getSlice(start, end);
|
|
2431
|
-
if (inVPre) {
|
|
2473
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2432
2474
|
currentProp.name += arg;
|
|
2433
2475
|
setLocEnd(currentProp.nameLoc, end);
|
|
2434
2476
|
} else {
|
|
@@ -2443,7 +2485,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2443
2485
|
},
|
|
2444
2486
|
ondirmodifier(start, end) {
|
|
2445
2487
|
const mod = getSlice(start, end);
|
|
2446
|
-
if (inVPre) {
|
|
2488
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2447
2489
|
currentProp.name += "." + mod;
|
|
2448
2490
|
setLocEnd(currentProp.nameLoc, end);
|
|
2449
2491
|
} else if (currentProp.name === "slot") {
|
|
@@ -3090,6 +3132,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3090
3132
|
} else if (child.type === 12) {
|
|
3091
3133
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
3092
3134
|
if (constantType >= 2) {
|
|
3135
|
+
if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
|
|
3136
|
+
child.codegenNode.arguments.push(
|
|
3137
|
+
-1 + (` /* ${shared.PatchFlagNames[-1]} */` )
|
|
3138
|
+
);
|
|
3139
|
+
}
|
|
3093
3140
|
toCache.push(child);
|
|
3094
3141
|
continue;
|
|
3095
3142
|
}
|
|
@@ -3118,7 +3165,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3118
3165
|
}
|
|
3119
3166
|
}
|
|
3120
3167
|
let cachedAsArray = false;
|
|
3121
|
-
const slotCacheKeys = [];
|
|
3122
3168
|
if (toCache.length === children.length && node.type === 1) {
|
|
3123
3169
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
3124
3170
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -3128,7 +3174,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3128
3174
|
} 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
3175
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
3130
3176
|
if (slot) {
|
|
3131
|
-
slotCacheKeys.push(context.cached.length);
|
|
3132
3177
|
slot.returns = getCacheExpression(
|
|
3133
3178
|
createArrayExpression(slot.returns)
|
|
3134
3179
|
);
|
|
@@ -3138,7 +3183,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3138
3183
|
const slotName = findDir(node, "slot", true);
|
|
3139
3184
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
3140
3185
|
if (slot) {
|
|
3141
|
-
slotCacheKeys.push(context.cached.length);
|
|
3142
3186
|
slot.returns = getCacheExpression(
|
|
3143
3187
|
createArrayExpression(slot.returns)
|
|
3144
3188
|
);
|
|
@@ -3148,23 +3192,12 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3148
3192
|
}
|
|
3149
3193
|
if (!cachedAsArray) {
|
|
3150
3194
|
for (const child of toCache) {
|
|
3151
|
-
slotCacheKeys.push(context.cached.length);
|
|
3152
3195
|
child.codegenNode = context.cache(child.codegenNode);
|
|
3153
3196
|
}
|
|
3154
3197
|
}
|
|
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
3198
|
function getCacheExpression(value) {
|
|
3164
3199
|
const exp = context.cache(value);
|
|
3165
|
-
|
|
3166
|
-
exp.needArraySpread = true;
|
|
3167
|
-
}
|
|
3200
|
+
exp.needArraySpread = true;
|
|
3168
3201
|
return exp;
|
|
3169
3202
|
}
|
|
3170
3203
|
function getSlotNode(node2, name) {
|
|
@@ -4629,14 +4662,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
4629
4662
|
knownIds
|
|
4630
4663
|
);
|
|
4631
4664
|
const children = [];
|
|
4665
|
+
const isTSNode = TS_NODE_TYPES.includes(ast.type);
|
|
4632
4666
|
ids.sort((a, b) => a.start - b.start);
|
|
4633
4667
|
ids.forEach((id, i) => {
|
|
4634
4668
|
const start = id.start - 1;
|
|
4635
4669
|
const end = id.end - 1;
|
|
4636
4670
|
const last = ids[i - 1];
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4671
|
+
if (!(isTSNode && i === 0)) {
|
|
4672
|
+
const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
|
|
4673
|
+
if (leadingText.length || id.prefix) {
|
|
4674
|
+
children.push(leadingText + (id.prefix || ``));
|
|
4675
|
+
}
|
|
4640
4676
|
}
|
|
4641
4677
|
const source = rawExp.slice(start, end);
|
|
4642
4678
|
children.push(
|
|
@@ -4651,7 +4687,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
4651
4687
|
id.isConstant ? 3 : 0
|
|
4652
4688
|
)
|
|
4653
4689
|
);
|
|
4654
|
-
if (i === ids.length - 1 && end < rawExp.length) {
|
|
4690
|
+
if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
|
|
4655
4691
|
children.push(rawExp.slice(end));
|
|
4656
4692
|
}
|
|
4657
4693
|
});
|
|
@@ -4689,7 +4725,7 @@ function isConst(type) {
|
|
|
4689
4725
|
}
|
|
4690
4726
|
|
|
4691
4727
|
const transformIf = createStructuralDirectiveTransform(
|
|
4692
|
-
/^(if|else|else-if)$/,
|
|
4728
|
+
/^(?:if|else|else-if)$/,
|
|
4693
4729
|
(node, dir, context) => {
|
|
4694
4730
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
4695
4731
|
const siblings = context.parent.children;
|
|
@@ -4758,7 +4794,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
4758
4794
|
continue;
|
|
4759
4795
|
}
|
|
4760
4796
|
if (sibling && sibling.type === 9) {
|
|
4761
|
-
if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4797
|
+
if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4762
4798
|
context.onError(
|
|
4763
4799
|
createCompilerError(30, node.loc)
|
|
4764
4800
|
);
|
|
@@ -4907,90 +4943,6 @@ function getParentCondition(node) {
|
|
|
4907
4943
|
}
|
|
4908
4944
|
}
|
|
4909
4945
|
|
|
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
4946
|
const transformFor = createStructuralDirectiveTransform(
|
|
4995
4947
|
"for",
|
|
4996
4948
|
(node, dir, context) => {
|
|
@@ -5003,9 +4955,6 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
5003
4955
|
const memo = findDir(node, "memo");
|
|
5004
4956
|
const keyProp = findProp(node, `key`, false, true);
|
|
5005
4957
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
5006
|
-
if (isDirKey && !keyProp.exp) {
|
|
5007
|
-
transformBindShorthand(keyProp, context);
|
|
5008
|
-
}
|
|
5009
4958
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
5010
4959
|
if (memo && keyExp && isDirKey) {
|
|
5011
4960
|
{
|
|
@@ -5286,7 +5235,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5286
5235
|
const dynamicSlots = [];
|
|
5287
5236
|
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0;
|
|
5288
5237
|
if (!context.ssr && context.prefixIdentifiers) {
|
|
5289
|
-
hasDynamicSlots =
|
|
5238
|
+
hasDynamicSlots = node.props.some(
|
|
5239
|
+
(prop) => isVSlot(prop) && (hasScopeRef(prop.arg, context.identifiers) || hasScopeRef(prop.exp, context.identifiers))
|
|
5240
|
+
) || children.some((child) => hasScopeRef(child, context.identifiers));
|
|
5290
5241
|
}
|
|
5291
5242
|
const onComponentSlot = findDir(node, "slot", true);
|
|
5292
5243
|
if (onComponentSlot) {
|
|
@@ -5349,7 +5300,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5349
5300
|
);
|
|
5350
5301
|
} else if (vElse = findDir(
|
|
5351
5302
|
slotElement,
|
|
5352
|
-
/^else(
|
|
5303
|
+
/^else(?:-if)?$/,
|
|
5353
5304
|
true
|
|
5354
5305
|
/* allowEmpty */
|
|
5355
5306
|
)) {
|
|
@@ -5361,7 +5312,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
5361
5312
|
break;
|
|
5362
5313
|
}
|
|
5363
5314
|
}
|
|
5364
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
5315
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
5365
5316
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
5366
5317
|
while (conditional.alternate.type === 19) {
|
|
5367
5318
|
conditional = conditional.alternate;
|
|
@@ -6319,6 +6270,65 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
6319
6270
|
return ret;
|
|
6320
6271
|
};
|
|
6321
6272
|
|
|
6273
|
+
const transformBind = (dir, _node, context) => {
|
|
6274
|
+
const { modifiers, loc } = dir;
|
|
6275
|
+
const arg = dir.arg;
|
|
6276
|
+
let { exp } = dir;
|
|
6277
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
6278
|
+
{
|
|
6279
|
+
context.onError(
|
|
6280
|
+
createCompilerError(34, loc)
|
|
6281
|
+
);
|
|
6282
|
+
return {
|
|
6283
|
+
props: [
|
|
6284
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
6285
|
+
]
|
|
6286
|
+
};
|
|
6287
|
+
}
|
|
6288
|
+
}
|
|
6289
|
+
if (arg.type !== 4) {
|
|
6290
|
+
arg.children.unshift(`(`);
|
|
6291
|
+
arg.children.push(`) || ""`);
|
|
6292
|
+
} else if (!arg.isStatic) {
|
|
6293
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
6294
|
+
}
|
|
6295
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
6296
|
+
if (arg.type === 4) {
|
|
6297
|
+
if (arg.isStatic) {
|
|
6298
|
+
arg.content = shared.camelize(arg.content);
|
|
6299
|
+
} else {
|
|
6300
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
6301
|
+
}
|
|
6302
|
+
} else {
|
|
6303
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
6304
|
+
arg.children.push(`)`);
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6307
|
+
if (!context.inSSR) {
|
|
6308
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
6309
|
+
injectPrefix(arg, ".");
|
|
6310
|
+
}
|
|
6311
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
6312
|
+
injectPrefix(arg, "^");
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
return {
|
|
6316
|
+
props: [createObjectProperty(arg, exp)]
|
|
6317
|
+
};
|
|
6318
|
+
};
|
|
6319
|
+
const injectPrefix = (arg, prefix) => {
|
|
6320
|
+
if (arg.type === 4) {
|
|
6321
|
+
if (arg.isStatic) {
|
|
6322
|
+
arg.content = prefix + arg.content;
|
|
6323
|
+
} else {
|
|
6324
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
6325
|
+
}
|
|
6326
|
+
} else {
|
|
6327
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
6328
|
+
arg.children.push(`)`);
|
|
6329
|
+
}
|
|
6330
|
+
};
|
|
6331
|
+
|
|
6322
6332
|
const transformText = (node, context) => {
|
|
6323
6333
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
6324
6334
|
return () => {
|
|
@@ -6652,7 +6662,7 @@ const seen = /* @__PURE__ */ new WeakSet();
|
|
|
6652
6662
|
const transformMemo = (node, context) => {
|
|
6653
6663
|
if (node.type === 1) {
|
|
6654
6664
|
const dir = findDir(node, "memo");
|
|
6655
|
-
if (!dir || seen.has(node)) {
|
|
6665
|
+
if (!dir || seen.has(node) || context.inSSR) {
|
|
6656
6666
|
return;
|
|
6657
6667
|
}
|
|
6658
6668
|
seen.add(node);
|
|
@@ -6674,9 +6684,36 @@ const transformMemo = (node, context) => {
|
|
|
6674
6684
|
}
|
|
6675
6685
|
};
|
|
6676
6686
|
|
|
6687
|
+
const transformVBindShorthand = (node, context) => {
|
|
6688
|
+
if (node.type === 1) {
|
|
6689
|
+
for (const prop of node.props) {
|
|
6690
|
+
if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
|
|
6691
|
+
false) && prop.arg) {
|
|
6692
|
+
const arg = prop.arg;
|
|
6693
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
6694
|
+
context.onError(
|
|
6695
|
+
createCompilerError(
|
|
6696
|
+
52,
|
|
6697
|
+
arg.loc
|
|
6698
|
+
)
|
|
6699
|
+
);
|
|
6700
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
6701
|
+
} else {
|
|
6702
|
+
const propName = shared.camelize(arg.content);
|
|
6703
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
6704
|
+
propName[0] === "-") {
|
|
6705
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
6706
|
+
}
|
|
6707
|
+
}
|
|
6708
|
+
}
|
|
6709
|
+
}
|
|
6710
|
+
}
|
|
6711
|
+
};
|
|
6712
|
+
|
|
6677
6713
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
6678
6714
|
return [
|
|
6679
6715
|
[
|
|
6716
|
+
transformVBindShorthand,
|
|
6680
6717
|
transformOnce,
|
|
6681
6718
|
transformIf,
|
|
6682
6719
|
transformMemo,
|
|
@@ -6875,6 +6912,7 @@ exports.isStaticProperty = isStaticProperty;
|
|
|
6875
6912
|
exports.isStaticPropertyKey = isStaticPropertyKey;
|
|
6876
6913
|
exports.isTemplateNode = isTemplateNode;
|
|
6877
6914
|
exports.isText = isText$1;
|
|
6915
|
+
exports.isVPre = isVPre;
|
|
6878
6916
|
exports.isVSlot = isVSlot;
|
|
6879
6917
|
exports.locStub = locStub;
|
|
6880
6918
|
exports.noopDirectiveTransform = noopDirectiveTransform;
|
|
@@ -6894,8 +6932,10 @@ exports.transformElement = transformElement;
|
|
|
6894
6932
|
exports.transformExpression = transformExpression;
|
|
6895
6933
|
exports.transformModel = transformModel;
|
|
6896
6934
|
exports.transformOn = transformOn;
|
|
6935
|
+
exports.transformVBindShorthand = transformVBindShorthand;
|
|
6897
6936
|
exports.traverseNode = traverseNode;
|
|
6898
6937
|
exports.unwrapTSNode = unwrapTSNode;
|
|
6938
|
+
exports.validFirstIdentCharRE = validFirstIdentCharRE;
|
|
6899
6939
|
exports.walkBlockDeclarations = walkBlockDeclarations;
|
|
6900
6940
|
exports.walkFunctionParams = walkFunctionParams;
|
|
6901
6941
|
exports.walkIdentifiers = walkIdentifiers;
|