@vue/compiler-core 3.4.27 → 3.4.28
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 +136 -161
- package/dist/compiler-core.cjs.prod.js +136 -161
- package/dist/compiler-core.d.ts +1 -1
- package/dist/compiler-core.esm-bundler.js +119 -143
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.4.
|
|
2
|
+
* @vue/compiler-core v3.4.28
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1310,8 +1310,7 @@ function warnDeprecation(key, context, loc, ...args) {
|
|
|
1310
1310
|
Details: ${link}` : ``}`;
|
|
1311
1311
|
const err = new SyntaxError(msg);
|
|
1312
1312
|
err.code = key;
|
|
1313
|
-
if (loc)
|
|
1314
|
-
err.loc = loc;
|
|
1313
|
+
if (loc) err.loc = loc;
|
|
1315
1314
|
context.onWarn(err);
|
|
1316
1315
|
}
|
|
1317
1316
|
|
|
@@ -1514,7 +1513,8 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
|
|
|
1514
1513
|
if (includeAll || isRefed && !isLocal) {
|
|
1515
1514
|
onIdentifier(node, parent, parentStack, isRefed, isLocal);
|
|
1516
1515
|
}
|
|
1517
|
-
} else if (node.type === "ObjectProperty" &&
|
|
1516
|
+
} else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
|
|
1517
|
+
(parent == null ? void 0 : parent.type) === "ObjectPattern") {
|
|
1518
1518
|
node.inPattern = true;
|
|
1519
1519
|
} else if (isFunctionType(node)) {
|
|
1520
1520
|
if (node.scopeIds) {
|
|
@@ -1605,16 +1605,14 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1605
1605
|
function walkBlockDeclarations(block, onIdent) {
|
|
1606
1606
|
for (const stmt of block.body) {
|
|
1607
1607
|
if (stmt.type === "VariableDeclaration") {
|
|
1608
|
-
if (stmt.declare)
|
|
1609
|
-
continue;
|
|
1608
|
+
if (stmt.declare) continue;
|
|
1610
1609
|
for (const decl of stmt.declarations) {
|
|
1611
1610
|
for (const id of extractIdentifiers(decl.id)) {
|
|
1612
1611
|
onIdent(id);
|
|
1613
1612
|
}
|
|
1614
1613
|
}
|
|
1615
1614
|
} else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
|
|
1616
|
-
if (stmt.declare || !stmt.id)
|
|
1617
|
-
continue;
|
|
1615
|
+
if (stmt.declare || !stmt.id) continue;
|
|
1618
1616
|
onIdent(stmt.id);
|
|
1619
1617
|
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
1620
1618
|
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
@@ -1651,8 +1649,7 @@ function extractIdentifiers(param, nodes = []) {
|
|
|
1651
1649
|
break;
|
|
1652
1650
|
case "ArrayPattern":
|
|
1653
1651
|
param.elements.forEach((element) => {
|
|
1654
|
-
if (element)
|
|
1655
|
-
extractIdentifiers(element, nodes);
|
|
1652
|
+
if (element) extractIdentifiers(element, nodes);
|
|
1656
1653
|
});
|
|
1657
1654
|
break;
|
|
1658
1655
|
case "RestElement":
|
|
@@ -1805,7 +1802,7 @@ function isCoreComponent(tag) {
|
|
|
1805
1802
|
return BASE_TRANSITION;
|
|
1806
1803
|
}
|
|
1807
1804
|
}
|
|
1808
|
-
const nonIdentifierRE = /^\d|[^\$\w]/;
|
|
1805
|
+
const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1809
1806
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1810
1807
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1811
1808
|
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
@@ -1926,8 +1923,7 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
|
1926
1923
|
for (let i = 0; i < node.props.length; i++) {
|
|
1927
1924
|
const p = node.props[i];
|
|
1928
1925
|
if (p.type === 6) {
|
|
1929
|
-
if (dynamicOnly)
|
|
1930
|
-
continue;
|
|
1926
|
+
if (dynamicOnly) continue;
|
|
1931
1927
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
1932
1928
|
return p;
|
|
1933
1929
|
}
|
|
@@ -2091,7 +2087,7 @@ function getMemoedVNodeCall(node) {
|
|
|
2091
2087
|
return node;
|
|
2092
2088
|
}
|
|
2093
2089
|
}
|
|
2094
|
-
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
2090
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
|
|
2095
2091
|
|
|
2096
2092
|
const defaultParserOptions = {
|
|
2097
2093
|
parseMode: "base",
|
|
@@ -2244,8 +2240,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2244
2240
|
}
|
|
2245
2241
|
},
|
|
2246
2242
|
ondirarg(start, end) {
|
|
2247
|
-
if (start === end)
|
|
2248
|
-
return;
|
|
2243
|
+
if (start === end) return;
|
|
2249
2244
|
const arg = getSlice(start, end);
|
|
2250
2245
|
if (inVPre) {
|
|
2251
2246
|
currentProp.name += arg;
|
|
@@ -2277,14 +2272,12 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2277
2272
|
},
|
|
2278
2273
|
onattribdata(start, end) {
|
|
2279
2274
|
currentAttrValue += getSlice(start, end);
|
|
2280
|
-
if (currentAttrStartIndex < 0)
|
|
2281
|
-
currentAttrStartIndex = start;
|
|
2275
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
2282
2276
|
currentAttrEndIndex = end;
|
|
2283
2277
|
},
|
|
2284
2278
|
onattribentity(char, start, end) {
|
|
2285
2279
|
currentAttrValue += char;
|
|
2286
|
-
if (currentAttrStartIndex < 0)
|
|
2287
|
-
currentAttrStartIndex = start;
|
|
2280
|
+
if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
|
|
2288
2281
|
currentAttrEndIndex = end;
|
|
2289
2282
|
},
|
|
2290
2283
|
onattribnameend(end) {
|
|
@@ -2434,8 +2427,7 @@ function parseForExpression(input) {
|
|
|
2434
2427
|
const loc = input.loc;
|
|
2435
2428
|
const exp = input.content;
|
|
2436
2429
|
const inMatch = exp.match(forAliasRE);
|
|
2437
|
-
if (!inMatch)
|
|
2438
|
-
return;
|
|
2430
|
+
if (!inMatch) return;
|
|
2439
2431
|
const [, LHS, RHS] = inMatch;
|
|
2440
2432
|
const createAliasExpression = (content, offset, asParam = false) => {
|
|
2441
2433
|
const start = loc.start.offset + offset;
|
|
@@ -2592,14 +2584,12 @@ function onCloseTag(el, end, isImplied = false) {
|
|
|
2592
2584
|
}
|
|
2593
2585
|
function lookAhead(index, c) {
|
|
2594
2586
|
let i = index;
|
|
2595
|
-
while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
|
|
2596
|
-
i++;
|
|
2587
|
+
while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
|
|
2597
2588
|
return i;
|
|
2598
2589
|
}
|
|
2599
2590
|
function backTrack(index, c) {
|
|
2600
2591
|
let i = index;
|
|
2601
|
-
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2602
|
-
i--;
|
|
2592
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
|
|
2603
2593
|
return i;
|
|
2604
2594
|
}
|
|
2605
2595
|
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
@@ -2917,7 +2907,7 @@ function getConstantType(node, context) {
|
|
|
2917
2907
|
if (codegenNode.type !== 13) {
|
|
2918
2908
|
return 0;
|
|
2919
2909
|
}
|
|
2920
|
-
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
|
2910
|
+
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
|
|
2921
2911
|
return 0;
|
|
2922
2912
|
}
|
|
2923
2913
|
const flag = getPatchFlag(codegenNode);
|
|
@@ -3201,8 +3191,7 @@ function createTransformContext(root, {
|
|
|
3201
3191
|
}
|
|
3202
3192
|
},
|
|
3203
3193
|
hoist(exp) {
|
|
3204
|
-
if (shared.isString(exp))
|
|
3205
|
-
exp = createSimpleExpression(exp);
|
|
3194
|
+
if (shared.isString(exp)) exp = createSimpleExpression(exp);
|
|
3206
3195
|
context.hoists.push(exp);
|
|
3207
3196
|
const identifier = createSimpleExpression(
|
|
3208
3197
|
`_hoisted_${context.hoists.length}`,
|
|
@@ -3291,8 +3280,7 @@ function traverseChildren(parent, context) {
|
|
|
3291
3280
|
};
|
|
3292
3281
|
for (; i < parent.children.length; i++) {
|
|
3293
3282
|
const child = parent.children[i];
|
|
3294
|
-
if (shared.isString(child))
|
|
3295
|
-
continue;
|
|
3283
|
+
if (shared.isString(child)) continue;
|
|
3296
3284
|
context.grandParent = context.parent;
|
|
3297
3285
|
context.parent = parent;
|
|
3298
3286
|
context.childIndex = i;
|
|
@@ -3363,8 +3351,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
3363
3351
|
props.splice(i, 1);
|
|
3364
3352
|
i--;
|
|
3365
3353
|
const onExit = fn(node, prop, context);
|
|
3366
|
-
if (onExit)
|
|
3367
|
-
exitFns.push(onExit);
|
|
3354
|
+
if (onExit) exitFns.push(onExit);
|
|
3368
3355
|
}
|
|
3369
3356
|
}
|
|
3370
3357
|
return exitFns;
|
|
@@ -3463,8 +3450,7 @@ function createCodegenContext(ast, {
|
|
|
3463
3450
|
}
|
|
3464
3451
|
function addMapping(loc, name = null) {
|
|
3465
3452
|
const { _names, _mappings } = context.map;
|
|
3466
|
-
if (name !== null && !_names.has(name))
|
|
3467
|
-
_names.add(name);
|
|
3453
|
+
if (name !== null && !_names.has(name)) _names.add(name);
|
|
3468
3454
|
_mappings.add({
|
|
3469
3455
|
originalLine: loc.line,
|
|
3470
3456
|
originalColumn: loc.column - 1,
|
|
@@ -3484,8 +3470,7 @@ function createCodegenContext(ast, {
|
|
|
3484
3470
|
}
|
|
3485
3471
|
function generate(ast, options = {}) {
|
|
3486
3472
|
const context = createCodegenContext(ast, options);
|
|
3487
|
-
if (options.onContextCreated)
|
|
3488
|
-
options.onContextCreated(context);
|
|
3473
|
+
if (options.onContextCreated) options.onContextCreated(context);
|
|
3489
3474
|
const {
|
|
3490
3475
|
mode,
|
|
3491
3476
|
push,
|
|
@@ -3705,8 +3690,9 @@ function genHoists(hoists, context) {
|
|
|
3705
3690
|
const genScopeId = scopeId != null && mode !== "function";
|
|
3706
3691
|
newline();
|
|
3707
3692
|
if (genScopeId) {
|
|
3693
|
+
const param = context.isTS ? "(n: any)" : "n";
|
|
3708
3694
|
push(
|
|
3709
|
-
`const _withScopeId =
|
|
3695
|
+
`const _withScopeId = ${param} => (${helper(
|
|
3710
3696
|
PUSH_SCOPE_ID
|
|
3711
3697
|
)}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
|
|
3712
3698
|
);
|
|
@@ -3858,8 +3844,7 @@ function genExpression(node, context) {
|
|
|
3858
3844
|
}
|
|
3859
3845
|
function genInterpolation(node, context) {
|
|
3860
3846
|
const { push, helper, pure } = context;
|
|
3861
|
-
if (pure)
|
|
3862
|
-
push(PURE_ANNOTATION);
|
|
3847
|
+
if (pure) push(PURE_ANNOTATION);
|
|
3863
3848
|
push(`${helper(TO_DISPLAY_STRING)}(`);
|
|
3864
3849
|
genNode(node.content, context);
|
|
3865
3850
|
push(`)`);
|
|
@@ -3939,8 +3924,7 @@ function genVNodeCall(node, context) {
|
|
|
3939
3924
|
function genNullableArgs(args) {
|
|
3940
3925
|
let i = args.length;
|
|
3941
3926
|
while (i--) {
|
|
3942
|
-
if (args[i] != null)
|
|
3943
|
-
break;
|
|
3927
|
+
if (args[i] != null) break;
|
|
3944
3928
|
}
|
|
3945
3929
|
return args.slice(0, i + 1).map((arg) => arg || `null`);
|
|
3946
3930
|
}
|
|
@@ -4086,11 +4070,9 @@ function genTemplateLiteral(node, context) {
|
|
|
4086
4070
|
push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
|
|
4087
4071
|
} else {
|
|
4088
4072
|
push("${");
|
|
4089
|
-
if (multilines)
|
|
4090
|
-
indent();
|
|
4073
|
+
if (multilines) indent();
|
|
4091
4074
|
genNode(e, context);
|
|
4092
|
-
if (multilines)
|
|
4093
|
-
deindent();
|
|
4075
|
+
if (multilines) deindent();
|
|
4094
4076
|
push("}");
|
|
4095
4077
|
}
|
|
4096
4078
|
}
|
|
@@ -4458,8 +4440,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
4458
4440
|
sibling.branches.push(branch);
|
|
4459
4441
|
const onExit = processCodegen && processCodegen(sibling, branch, false);
|
|
4460
4442
|
traverseNode(branch, context);
|
|
4461
|
-
if (onExit)
|
|
4462
|
-
onExit();
|
|
4443
|
+
if (onExit) onExit();
|
|
4463
4444
|
context.currentNode = null;
|
|
4464
4445
|
} else {
|
|
4465
4446
|
context.onError(
|
|
@@ -4577,6 +4558,90 @@ function getParentCondition(node) {
|
|
|
4577
4558
|
}
|
|
4578
4559
|
}
|
|
4579
4560
|
|
|
4561
|
+
const transformBind = (dir, _node, context) => {
|
|
4562
|
+
const { modifiers, loc } = dir;
|
|
4563
|
+
const arg = dir.arg;
|
|
4564
|
+
let { exp } = dir;
|
|
4565
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4566
|
+
{
|
|
4567
|
+
context.onError(
|
|
4568
|
+
createCompilerError(34, loc)
|
|
4569
|
+
);
|
|
4570
|
+
return {
|
|
4571
|
+
props: [
|
|
4572
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4573
|
+
]
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
}
|
|
4577
|
+
if (!exp) {
|
|
4578
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
4579
|
+
context.onError(
|
|
4580
|
+
createCompilerError(
|
|
4581
|
+
52,
|
|
4582
|
+
arg.loc
|
|
4583
|
+
)
|
|
4584
|
+
);
|
|
4585
|
+
return {
|
|
4586
|
+
props: [
|
|
4587
|
+
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4588
|
+
]
|
|
4589
|
+
};
|
|
4590
|
+
}
|
|
4591
|
+
transformBindShorthand(dir, context);
|
|
4592
|
+
exp = dir.exp;
|
|
4593
|
+
}
|
|
4594
|
+
if (arg.type !== 4) {
|
|
4595
|
+
arg.children.unshift(`(`);
|
|
4596
|
+
arg.children.push(`) || ""`);
|
|
4597
|
+
} else if (!arg.isStatic) {
|
|
4598
|
+
arg.content = `${arg.content} || ""`;
|
|
4599
|
+
}
|
|
4600
|
+
if (modifiers.includes("camel")) {
|
|
4601
|
+
if (arg.type === 4) {
|
|
4602
|
+
if (arg.isStatic) {
|
|
4603
|
+
arg.content = shared.camelize(arg.content);
|
|
4604
|
+
} else {
|
|
4605
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4606
|
+
}
|
|
4607
|
+
} else {
|
|
4608
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4609
|
+
arg.children.push(`)`);
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
if (!context.inSSR) {
|
|
4613
|
+
if (modifiers.includes("prop")) {
|
|
4614
|
+
injectPrefix(arg, ".");
|
|
4615
|
+
}
|
|
4616
|
+
if (modifiers.includes("attr")) {
|
|
4617
|
+
injectPrefix(arg, "^");
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
return {
|
|
4621
|
+
props: [createObjectProperty(arg, exp)]
|
|
4622
|
+
};
|
|
4623
|
+
};
|
|
4624
|
+
const transformBindShorthand = (dir, context) => {
|
|
4625
|
+
const arg = dir.arg;
|
|
4626
|
+
const propName = shared.camelize(arg.content);
|
|
4627
|
+
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4628
|
+
{
|
|
4629
|
+
dir.exp = processExpression(dir.exp, context);
|
|
4630
|
+
}
|
|
4631
|
+
};
|
|
4632
|
+
const injectPrefix = (arg, prefix) => {
|
|
4633
|
+
if (arg.type === 4) {
|
|
4634
|
+
if (arg.isStatic) {
|
|
4635
|
+
arg.content = prefix + arg.content;
|
|
4636
|
+
} else {
|
|
4637
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4638
|
+
}
|
|
4639
|
+
} else {
|
|
4640
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
4641
|
+
arg.children.push(`)`);
|
|
4642
|
+
}
|
|
4643
|
+
};
|
|
4644
|
+
|
|
4580
4645
|
const transformFor = createStructuralDirectiveTransform(
|
|
4581
4646
|
"for",
|
|
4582
4647
|
(node, dir, context) => {
|
|
@@ -4587,9 +4652,12 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4587
4652
|
]);
|
|
4588
4653
|
const isTemplate = isTemplateNode(node);
|
|
4589
4654
|
const memo = findDir(node, "memo");
|
|
4590
|
-
const keyProp = findProp(node, `key
|
|
4591
|
-
|
|
4592
|
-
|
|
4655
|
+
const keyProp = findProp(node, `key`, false, true);
|
|
4656
|
+
if (keyProp && keyProp.type === 7 && !keyProp.exp) {
|
|
4657
|
+
transformBindShorthand(keyProp, context);
|
|
4658
|
+
}
|
|
4659
|
+
const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4660
|
+
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4593
4661
|
if (isTemplate) {
|
|
4594
4662
|
if (memo) {
|
|
4595
4663
|
memo.exp = processExpression(
|
|
@@ -4762,13 +4830,11 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
4762
4830
|
key && removeIdentifiers(key);
|
|
4763
4831
|
index && removeIdentifiers(index);
|
|
4764
4832
|
}
|
|
4765
|
-
if (onExit)
|
|
4766
|
-
onExit();
|
|
4833
|
+
if (onExit) onExit();
|
|
4767
4834
|
};
|
|
4768
4835
|
}
|
|
4769
4836
|
function finalizeForParseResult(result, context) {
|
|
4770
|
-
if (result.finalized)
|
|
4771
|
-
return;
|
|
4837
|
+
if (result.finalized) return;
|
|
4772
4838
|
if (context.prefixIdentifiers) {
|
|
4773
4839
|
result.source = processExpression(
|
|
4774
4840
|
result.source,
|
|
@@ -4804,8 +4870,7 @@ function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
|
4804
4870
|
function createParamsList(args) {
|
|
4805
4871
|
let i = args.length;
|
|
4806
4872
|
while (i--) {
|
|
4807
|
-
if (args[i])
|
|
4808
|
-
break;
|
|
4873
|
+
if (args[i]) break;
|
|
4809
4874
|
}
|
|
4810
4875
|
return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
|
|
4811
4876
|
}
|
|
@@ -5076,13 +5141,11 @@ function hasForwardedSlots(children) {
|
|
|
5076
5141
|
}
|
|
5077
5142
|
break;
|
|
5078
5143
|
case 9:
|
|
5079
|
-
if (hasForwardedSlots(child.branches))
|
|
5080
|
-
return true;
|
|
5144
|
+
if (hasForwardedSlots(child.branches)) return true;
|
|
5081
5145
|
break;
|
|
5082
5146
|
case 10:
|
|
5083
5147
|
case 11:
|
|
5084
|
-
if (hasForwardedSlots(child.children))
|
|
5085
|
-
return true;
|
|
5148
|
+
if (hasForwardedSlots(child.children)) return true;
|
|
5086
5149
|
break;
|
|
5087
5150
|
}
|
|
5088
5151
|
}
|
|
@@ -5118,7 +5181,7 @@ const transformElement = (node, context) => {
|
|
|
5118
5181
|
// updates inside get proper isSVG flag at runtime. (#639, #643)
|
|
5119
5182
|
// This is technically web-specific, but splitting the logic out of core
|
|
5120
5183
|
// leads to too much unnecessary complexity.
|
|
5121
|
-
(tag === "svg" || tag === "foreignObject")
|
|
5184
|
+
(tag === "svg" || tag === "foreignObject" || tag === "math")
|
|
5122
5185
|
);
|
|
5123
5186
|
if (props.length > 0) {
|
|
5124
5187
|
const propsBuildResult = buildProps(
|
|
@@ -5230,8 +5293,7 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
5230
5293
|
}
|
|
5231
5294
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
5232
5295
|
if (builtIn) {
|
|
5233
|
-
if (!ssr)
|
|
5234
|
-
context.helper(builtIn);
|
|
5296
|
+
if (!ssr) context.helper(builtIn);
|
|
5235
5297
|
return builtIn;
|
|
5236
5298
|
}
|
|
5237
5299
|
{
|
|
@@ -5315,8 +5377,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
5315
5377
|
);
|
|
5316
5378
|
properties = [];
|
|
5317
5379
|
}
|
|
5318
|
-
if (arg)
|
|
5319
|
-
mergeArgs.push(arg);
|
|
5380
|
+
if (arg) mergeArgs.push(arg);
|
|
5320
5381
|
};
|
|
5321
5382
|
const pushRefVForMarker = () => {
|
|
5322
5383
|
if (context.scopes.vFor > 0) {
|
|
@@ -5647,8 +5708,7 @@ function buildDirectiveArgs(dir, context) {
|
|
|
5647
5708
|
}
|
|
5648
5709
|
}
|
|
5649
5710
|
const { loc } = dir;
|
|
5650
|
-
if (dir.exp)
|
|
5651
|
-
dirArgs.push(dir.exp);
|
|
5711
|
+
if (dir.exp) dirArgs.push(dir.exp);
|
|
5652
5712
|
if (dir.arg) {
|
|
5653
5713
|
if (!dir.exp) {
|
|
5654
5714
|
dirArgs.push(`void 0`);
|
|
@@ -5678,8 +5738,7 @@ function stringifyDynamicPropNames(props) {
|
|
|
5678
5738
|
let propsNamesString = `[`;
|
|
5679
5739
|
for (let i = 0, l = props.length; i < l; i++) {
|
|
5680
5740
|
propsNamesString += JSON.stringify(props[i]);
|
|
5681
|
-
if (i < l - 1)
|
|
5682
|
-
propsNamesString += ", ";
|
|
5741
|
+
if (i < l - 1) propsNamesString += ", ";
|
|
5683
5742
|
}
|
|
5684
5743
|
return propsNamesString + `]`;
|
|
5685
5744
|
}
|
|
@@ -5876,85 +5935,6 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
5876
5935
|
return ret;
|
|
5877
5936
|
};
|
|
5878
5937
|
|
|
5879
|
-
const transformBind = (dir, _node, context) => {
|
|
5880
|
-
const { modifiers, loc } = dir;
|
|
5881
|
-
const arg = dir.arg;
|
|
5882
|
-
let { exp } = dir;
|
|
5883
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
5884
|
-
{
|
|
5885
|
-
context.onError(
|
|
5886
|
-
createCompilerError(34, loc)
|
|
5887
|
-
);
|
|
5888
|
-
return {
|
|
5889
|
-
props: [
|
|
5890
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
5891
|
-
]
|
|
5892
|
-
};
|
|
5893
|
-
}
|
|
5894
|
-
}
|
|
5895
|
-
if (!exp) {
|
|
5896
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
5897
|
-
context.onError(
|
|
5898
|
-
createCompilerError(
|
|
5899
|
-
52,
|
|
5900
|
-
arg.loc
|
|
5901
|
-
)
|
|
5902
|
-
);
|
|
5903
|
-
return {
|
|
5904
|
-
props: [
|
|
5905
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
5906
|
-
]
|
|
5907
|
-
};
|
|
5908
|
-
}
|
|
5909
|
-
const propName = shared.camelize(arg.content);
|
|
5910
|
-
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5911
|
-
{
|
|
5912
|
-
exp = dir.exp = processExpression(exp, context);
|
|
5913
|
-
}
|
|
5914
|
-
}
|
|
5915
|
-
if (arg.type !== 4) {
|
|
5916
|
-
arg.children.unshift(`(`);
|
|
5917
|
-
arg.children.push(`) || ""`);
|
|
5918
|
-
} else if (!arg.isStatic) {
|
|
5919
|
-
arg.content = `${arg.content} || ""`;
|
|
5920
|
-
}
|
|
5921
|
-
if (modifiers.includes("camel")) {
|
|
5922
|
-
if (arg.type === 4) {
|
|
5923
|
-
if (arg.isStatic) {
|
|
5924
|
-
arg.content = shared.camelize(arg.content);
|
|
5925
|
-
} else {
|
|
5926
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
5927
|
-
}
|
|
5928
|
-
} else {
|
|
5929
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
5930
|
-
arg.children.push(`)`);
|
|
5931
|
-
}
|
|
5932
|
-
}
|
|
5933
|
-
if (!context.inSSR) {
|
|
5934
|
-
if (modifiers.includes("prop")) {
|
|
5935
|
-
injectPrefix(arg, ".");
|
|
5936
|
-
}
|
|
5937
|
-
if (modifiers.includes("attr")) {
|
|
5938
|
-
injectPrefix(arg, "^");
|
|
5939
|
-
}
|
|
5940
|
-
}
|
|
5941
|
-
return {
|
|
5942
|
-
props: [createObjectProperty(arg, exp)]
|
|
5943
|
-
};
|
|
5944
|
-
};
|
|
5945
|
-
const injectPrefix = (arg, prefix) => {
|
|
5946
|
-
if (arg.type === 4) {
|
|
5947
|
-
if (arg.isStatic) {
|
|
5948
|
-
arg.content = prefix + arg.content;
|
|
5949
|
-
} else {
|
|
5950
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
5951
|
-
}
|
|
5952
|
-
} else {
|
|
5953
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
5954
|
-
arg.children.push(`)`);
|
|
5955
|
-
}
|
|
5956
|
-
};
|
|
5957
|
-
|
|
5958
5938
|
const transformText = (node, context) => {
|
|
5959
5939
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
5960
5940
|
return () => {
|
|
@@ -6157,8 +6137,7 @@ function rewriteFilter(node, context) {
|
|
|
6157
6137
|
} else {
|
|
6158
6138
|
for (let i = 0; i < node.children.length; i++) {
|
|
6159
6139
|
const child = node.children[i];
|
|
6160
|
-
if (typeof child !== "object")
|
|
6161
|
-
continue;
|
|
6140
|
+
if (typeof child !== "object") continue;
|
|
6162
6141
|
if (child.type === 4) {
|
|
6163
6142
|
parseFilter(child, context);
|
|
6164
6143
|
} else if (child.type === 8) {
|
|
@@ -6184,17 +6163,13 @@ function parseFilter(node, context) {
|
|
|
6184
6163
|
prev = c;
|
|
6185
6164
|
c = exp.charCodeAt(i);
|
|
6186
6165
|
if (inSingle) {
|
|
6187
|
-
if (c === 39 && prev !== 92)
|
|
6188
|
-
inSingle = false;
|
|
6166
|
+
if (c === 39 && prev !== 92) inSingle = false;
|
|
6189
6167
|
} else if (inDouble) {
|
|
6190
|
-
if (c === 34 && prev !== 92)
|
|
6191
|
-
inDouble = false;
|
|
6168
|
+
if (c === 34 && prev !== 92) inDouble = false;
|
|
6192
6169
|
} else if (inTemplateString) {
|
|
6193
|
-
if (c === 96 && prev !== 92)
|
|
6194
|
-
inTemplateString = false;
|
|
6170
|
+
if (c === 96 && prev !== 92) inTemplateString = false;
|
|
6195
6171
|
} else if (inRegex) {
|
|
6196
|
-
if (c === 47 && prev !== 92)
|
|
6197
|
-
inRegex = false;
|
|
6172
|
+
if (c === 47 && prev !== 92) inRegex = false;
|
|
6198
6173
|
} else if (c === 124 && // pipe
|
|
6199
6174
|
exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
|
|
6200
6175
|
if (expression === void 0) {
|
|
@@ -6238,8 +6213,7 @@ function parseFilter(node, context) {
|
|
|
6238
6213
|
let p;
|
|
6239
6214
|
for (; j >= 0; j--) {
|
|
6240
6215
|
p = exp.charAt(j);
|
|
6241
|
-
if (p !== " ")
|
|
6242
|
-
break;
|
|
6216
|
+
if (p !== " ") break;
|
|
6243
6217
|
}
|
|
6244
6218
|
if (!p || !validDivisionCharRE.test(p)) {
|
|
6245
6219
|
inRegex = true;
|
|
@@ -6261,6 +6235,7 @@ function parseFilter(node, context) {
|
|
|
6261
6235
|
expression = wrapFilter(expression, filters[i], context);
|
|
6262
6236
|
}
|
|
6263
6237
|
node.content = expression;
|
|
6238
|
+
node.ast = void 0;
|
|
6264
6239
|
}
|
|
6265
6240
|
}
|
|
6266
6241
|
function wrapFilter(exp, filter, context) {
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -522,7 +522,7 @@ export interface ForRenderListExpression extends CallExpression {
|
|
|
522
522
|
arguments: [ExpressionNode, ForIteratorExpression];
|
|
523
523
|
}
|
|
524
524
|
export interface ForIteratorExpression extends FunctionExpression {
|
|
525
|
-
returns
|
|
525
|
+
returns?: BlockCodegenNode;
|
|
526
526
|
}
|
|
527
527
|
export declare const locStub: SourceLocation;
|
|
528
528
|
export declare function createRoot(children: TemplateChildNode[], source?: string): RootNode;
|