@vue/compiler-dom 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-dom.cjs.js +42 -38
- package/dist/compiler-dom.cjs.prod.js +47 -5
- package/dist/compiler-dom.d.ts +3 -1
- package/dist/compiler-dom.esm-browser.js +160 -153
- package/dist/compiler-dom.esm-browser.prod.js +9 -9
- package/dist/compiler-dom.esm-bundler.js +38 -38
- package/dist/compiler-dom.global.js +163 -153
- package/dist/compiler-dom.global.prod.js +9 -9
- package/package.json +3 -3
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-dom v3.6.0-alpha.
|
|
2
|
+
* @vue/compiler-dom v3.6.0-alpha.4
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
7
6
|
// @__NO_SIDE_EFFECTS__
|
|
8
7
|
function makeMap(str) {
|
|
9
8
|
const map = /* @__PURE__ */ Object.create(null);
|
|
@@ -31,10 +30,10 @@ const isBuiltInDirective = /* @__PURE__ */ makeMap(
|
|
|
31
30
|
);
|
|
32
31
|
const cacheStringFunction = (fn) => {
|
|
33
32
|
const cache = /* @__PURE__ */ Object.create(null);
|
|
34
|
-
return (str) => {
|
|
33
|
+
return ((str) => {
|
|
35
34
|
const hit = cache[str];
|
|
36
35
|
return hit || (cache[str] = fn(str));
|
|
37
|
-
};
|
|
36
|
+
});
|
|
38
37
|
};
|
|
39
38
|
const camelizeRE = /-(\w)/g;
|
|
40
39
|
const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
|
|
@@ -50,6 +49,9 @@ const toHandlerKey = cacheStringFunction(
|
|
|
50
49
|
return s;
|
|
51
50
|
}
|
|
52
51
|
);
|
|
52
|
+
const getModifierPropName = (name) => {
|
|
53
|
+
return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
|
|
54
|
+
};
|
|
53
55
|
|
|
54
56
|
const PatchFlagNames = {
|
|
55
57
|
[1]: `TEXT`,
|
|
@@ -261,14 +263,6 @@ function registerRuntimeHelpers(helpers) {
|
|
|
261
263
|
});
|
|
262
264
|
}
|
|
263
265
|
|
|
264
|
-
const Namespaces = {
|
|
265
|
-
"HTML": 0,
|
|
266
|
-
"0": "HTML",
|
|
267
|
-
"SVG": 1,
|
|
268
|
-
"1": "SVG",
|
|
269
|
-
"MATH_ML": 2,
|
|
270
|
-
"2": "MATH_ML"
|
|
271
|
-
};
|
|
272
266
|
const NodeTypes = {
|
|
273
267
|
"ROOT": 0,
|
|
274
268
|
"0": "ROOT",
|
|
@@ -1647,7 +1641,8 @@ function walkFunctionParams(node, onIdent) {
|
|
|
1647
1641
|
}
|
|
1648
1642
|
}
|
|
1649
1643
|
function walkBlockDeclarations(block, onIdent) {
|
|
1650
|
-
|
|
1644
|
+
const body = block.type === "SwitchCase" ? block.consequent : block.body;
|
|
1645
|
+
for (const stmt of body) {
|
|
1651
1646
|
if (stmt.type === "VariableDeclaration") {
|
|
1652
1647
|
if (stmt.declare) continue;
|
|
1653
1648
|
for (const decl of stmt.declarations) {
|
|
@@ -1660,6 +1655,8 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
1660
1655
|
onIdent(stmt.id);
|
|
1661
1656
|
} else if (isForStatement(stmt)) {
|
|
1662
1657
|
walkForStatement(stmt, true, onIdent);
|
|
1658
|
+
} else if (stmt.type === "SwitchStatement") {
|
|
1659
|
+
walkSwitchStatement(stmt, true, onIdent);
|
|
1663
1660
|
}
|
|
1664
1661
|
}
|
|
1665
1662
|
}
|
|
@@ -1676,6 +1673,20 @@ function walkForStatement(stmt, isVar, onIdent) {
|
|
|
1676
1673
|
}
|
|
1677
1674
|
}
|
|
1678
1675
|
}
|
|
1676
|
+
function walkSwitchStatement(stmt, isVar, onIdent) {
|
|
1677
|
+
for (const cs of stmt.cases) {
|
|
1678
|
+
for (const stmt2 of cs.consequent) {
|
|
1679
|
+
if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
|
|
1680
|
+
for (const decl of stmt2.declarations) {
|
|
1681
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
1682
|
+
onIdent(id);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
walkBlockDeclarations(cs, onIdent);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1679
1690
|
function extractIdentifiers(param, nodes = []) {
|
|
1680
1691
|
switch (param.type) {
|
|
1681
1692
|
case "Identifier":
|
|
@@ -1806,7 +1817,7 @@ function isCoreComponent(tag) {
|
|
|
1806
1817
|
return BASE_TRANSITION;
|
|
1807
1818
|
}
|
|
1808
1819
|
}
|
|
1809
|
-
const nonIdentifierRE =
|
|
1820
|
+
const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
|
|
1810
1821
|
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1811
1822
|
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1812
1823
|
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
@@ -1876,7 +1887,7 @@ const isMemberExpressionBrowser = (exp) => {
|
|
|
1876
1887
|
};
|
|
1877
1888
|
const isMemberExpressionNode = NOOP ;
|
|
1878
1889
|
const isMemberExpression = isMemberExpressionBrowser ;
|
|
1879
|
-
const fnExpRE = /^\s*(async\s*)?(
|
|
1890
|
+
const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
|
|
1880
1891
|
const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
|
|
1881
1892
|
const isFnExpressionNode = NOOP ;
|
|
1882
1893
|
const isFnExpression = isFnExpressionBrowser ;
|
|
@@ -1945,6 +1956,9 @@ function hasDynamicKeyVBind(node) {
|
|
|
1945
1956
|
function isText$1(node) {
|
|
1946
1957
|
return node.type === 5 || node.type === 2;
|
|
1947
1958
|
}
|
|
1959
|
+
function isVPre(p) {
|
|
1960
|
+
return p.type === 7 && p.name === "pre";
|
|
1961
|
+
}
|
|
1948
1962
|
function isVSlot(p) {
|
|
1949
1963
|
return p.type === 7 && p.name === "slot";
|
|
1950
1964
|
}
|
|
@@ -2243,7 +2257,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2243
2257
|
ondirarg(start, end) {
|
|
2244
2258
|
if (start === end) return;
|
|
2245
2259
|
const arg = getSlice(start, end);
|
|
2246
|
-
if (inVPre) {
|
|
2260
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2247
2261
|
currentProp.name += arg;
|
|
2248
2262
|
setLocEnd(currentProp.nameLoc, end);
|
|
2249
2263
|
} else {
|
|
@@ -2258,7 +2272,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2258
2272
|
},
|
|
2259
2273
|
ondirmodifier(start, end) {
|
|
2260
2274
|
const mod = getSlice(start, end);
|
|
2261
|
-
if (inVPre) {
|
|
2275
|
+
if (inVPre && !isVPre(currentProp)) {
|
|
2262
2276
|
currentProp.name += "." + mod;
|
|
2263
2277
|
setLocEnd(currentProp.nameLoc, end);
|
|
2264
2278
|
} else if (currentProp.name === "slot") {
|
|
@@ -2886,6 +2900,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2886
2900
|
} else if (child.type === 12) {
|
|
2887
2901
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
2888
2902
|
if (constantType >= 2) {
|
|
2903
|
+
if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
|
|
2904
|
+
child.codegenNode.arguments.push(
|
|
2905
|
+
-1 + (` /* ${PatchFlagNames[-1]} */` )
|
|
2906
|
+
);
|
|
2907
|
+
}
|
|
2889
2908
|
toCache.push(child);
|
|
2890
2909
|
continue;
|
|
2891
2910
|
}
|
|
@@ -2914,7 +2933,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2914
2933
|
}
|
|
2915
2934
|
}
|
|
2916
2935
|
let cachedAsArray = false;
|
|
2917
|
-
const slotCacheKeys = [];
|
|
2918
2936
|
if (toCache.length === children.length && node.type === 1) {
|
|
2919
2937
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
|
2920
2938
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -2924,7 +2942,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2924
2942
|
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2925
2943
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
2926
2944
|
if (slot) {
|
|
2927
|
-
slotCacheKeys.push(context.cached.length);
|
|
2928
2945
|
slot.returns = getCacheExpression(
|
|
2929
2946
|
createArrayExpression(slot.returns)
|
|
2930
2947
|
);
|
|
@@ -2934,7 +2951,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2934
2951
|
const slotName = findDir(node, "slot", true);
|
|
2935
2952
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
2936
2953
|
if (slot) {
|
|
2937
|
-
slotCacheKeys.push(context.cached.length);
|
|
2938
2954
|
slot.returns = getCacheExpression(
|
|
2939
2955
|
createArrayExpression(slot.returns)
|
|
2940
2956
|
);
|
|
@@ -2944,23 +2960,12 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2944
2960
|
}
|
|
2945
2961
|
if (!cachedAsArray) {
|
|
2946
2962
|
for (const child of toCache) {
|
|
2947
|
-
slotCacheKeys.push(context.cached.length);
|
|
2948
2963
|
child.codegenNode = context.cache(child.codegenNode);
|
|
2949
2964
|
}
|
|
2950
2965
|
}
|
|
2951
|
-
if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2952
|
-
node.codegenNode.children.properties.push(
|
|
2953
|
-
createObjectProperty(
|
|
2954
|
-
`__`,
|
|
2955
|
-
createSimpleExpression(JSON.stringify(slotCacheKeys), false)
|
|
2956
|
-
)
|
|
2957
|
-
);
|
|
2958
|
-
}
|
|
2959
2966
|
function getCacheExpression(value) {
|
|
2960
2967
|
const exp = context.cache(value);
|
|
2961
|
-
|
|
2962
|
-
exp.needArraySpread = true;
|
|
2963
|
-
}
|
|
2968
|
+
exp.needArraySpread = true;
|
|
2964
2969
|
return exp;
|
|
2965
2970
|
}
|
|
2966
2971
|
function getSlotNode(node2, name) {
|
|
@@ -4111,7 +4116,7 @@ function stringifyExpression(exp) {
|
|
|
4111
4116
|
}
|
|
4112
4117
|
|
|
4113
4118
|
const transformIf = createStructuralDirectiveTransform(
|
|
4114
|
-
/^(if|else|else-if)$/,
|
|
4119
|
+
/^(?:if|else|else-if)$/,
|
|
4115
4120
|
(node, dir, context) => {
|
|
4116
4121
|
return processIf(node, dir, context, (ifNode, branch, isRoot) => {
|
|
4117
4122
|
const siblings = context.parent.children;
|
|
@@ -4180,7 +4185,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
4180
4185
|
continue;
|
|
4181
4186
|
}
|
|
4182
4187
|
if (sibling && sibling.type === 9) {
|
|
4183
|
-
if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4188
|
+
if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
4184
4189
|
context.onError(
|
|
4185
4190
|
createCompilerError(30, node.loc)
|
|
4186
4191
|
);
|
|
@@ -4329,80 +4334,6 @@ function getParentCondition(node) {
|
|
|
4329
4334
|
}
|
|
4330
4335
|
}
|
|
4331
4336
|
|
|
4332
|
-
const transformBind = (dir, _node, context) => {
|
|
4333
|
-
const { modifiers, loc } = dir;
|
|
4334
|
-
const arg = dir.arg;
|
|
4335
|
-
let { exp } = dir;
|
|
4336
|
-
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
4337
|
-
{
|
|
4338
|
-
exp = void 0;
|
|
4339
|
-
}
|
|
4340
|
-
}
|
|
4341
|
-
if (!exp) {
|
|
4342
|
-
if (arg.type !== 4 || !arg.isStatic) {
|
|
4343
|
-
context.onError(
|
|
4344
|
-
createCompilerError(
|
|
4345
|
-
52,
|
|
4346
|
-
arg.loc
|
|
4347
|
-
)
|
|
4348
|
-
);
|
|
4349
|
-
return {
|
|
4350
|
-
props: [
|
|
4351
|
-
createObjectProperty(arg, createSimpleExpression("", true, loc))
|
|
4352
|
-
]
|
|
4353
|
-
};
|
|
4354
|
-
}
|
|
4355
|
-
transformBindShorthand(dir);
|
|
4356
|
-
exp = dir.exp;
|
|
4357
|
-
}
|
|
4358
|
-
if (arg.type !== 4) {
|
|
4359
|
-
arg.children.unshift(`(`);
|
|
4360
|
-
arg.children.push(`) || ""`);
|
|
4361
|
-
} else if (!arg.isStatic) {
|
|
4362
|
-
arg.content = `${arg.content} || ""`;
|
|
4363
|
-
}
|
|
4364
|
-
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
4365
|
-
if (arg.type === 4) {
|
|
4366
|
-
if (arg.isStatic) {
|
|
4367
|
-
arg.content = camelize(arg.content);
|
|
4368
|
-
} else {
|
|
4369
|
-
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
4370
|
-
}
|
|
4371
|
-
} else {
|
|
4372
|
-
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
4373
|
-
arg.children.push(`)`);
|
|
4374
|
-
}
|
|
4375
|
-
}
|
|
4376
|
-
if (!context.inSSR) {
|
|
4377
|
-
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
4378
|
-
injectPrefix(arg, ".");
|
|
4379
|
-
}
|
|
4380
|
-
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
4381
|
-
injectPrefix(arg, "^");
|
|
4382
|
-
}
|
|
4383
|
-
}
|
|
4384
|
-
return {
|
|
4385
|
-
props: [createObjectProperty(arg, exp)]
|
|
4386
|
-
};
|
|
4387
|
-
};
|
|
4388
|
-
const transformBindShorthand = (dir, context) => {
|
|
4389
|
-
const arg = dir.arg;
|
|
4390
|
-
const propName = camelize(arg.content);
|
|
4391
|
-
dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4392
|
-
};
|
|
4393
|
-
const injectPrefix = (arg, prefix) => {
|
|
4394
|
-
if (arg.type === 4) {
|
|
4395
|
-
if (arg.isStatic) {
|
|
4396
|
-
arg.content = prefix + arg.content;
|
|
4397
|
-
} else {
|
|
4398
|
-
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
4399
|
-
}
|
|
4400
|
-
} else {
|
|
4401
|
-
arg.children.unshift(`'${prefix}' + (`);
|
|
4402
|
-
arg.children.push(`)`);
|
|
4403
|
-
}
|
|
4404
|
-
};
|
|
4405
|
-
|
|
4406
4337
|
const transformFor = createStructuralDirectiveTransform(
|
|
4407
4338
|
"for",
|
|
4408
4339
|
(node, dir, context) => {
|
|
@@ -4414,10 +4345,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4414
4345
|
const isTemplate = isTemplateNode(node);
|
|
4415
4346
|
const memo = findDir(node, "memo");
|
|
4416
4347
|
const keyProp = findProp(node, `key`, false, true);
|
|
4417
|
-
|
|
4418
|
-
if (isDirKey && !keyProp.exp) {
|
|
4419
|
-
transformBindShorthand(keyProp);
|
|
4420
|
-
}
|
|
4348
|
+
keyProp && keyProp.type === 7;
|
|
4421
4349
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4422
4350
|
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4423
4351
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
@@ -4717,7 +4645,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4717
4645
|
);
|
|
4718
4646
|
} else if (vElse = findDir(
|
|
4719
4647
|
slotElement,
|
|
4720
|
-
/^else(
|
|
4648
|
+
/^else(?:-if)?$/,
|
|
4721
4649
|
true
|
|
4722
4650
|
/* allowEmpty */
|
|
4723
4651
|
)) {
|
|
@@ -4729,7 +4657,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4729
4657
|
break;
|
|
4730
4658
|
}
|
|
4731
4659
|
}
|
|
4732
|
-
if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
|
|
4660
|
+
if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
|
|
4733
4661
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
4734
4662
|
while (conditional.alternate.type === 19) {
|
|
4735
4663
|
conditional = conditional.alternate;
|
|
@@ -5589,6 +5517,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
|
|
|
5589
5517
|
return ret;
|
|
5590
5518
|
};
|
|
5591
5519
|
|
|
5520
|
+
const transformBind = (dir, _node, context) => {
|
|
5521
|
+
const { modifiers, loc } = dir;
|
|
5522
|
+
const arg = dir.arg;
|
|
5523
|
+
let { exp } = dir;
|
|
5524
|
+
if (exp && exp.type === 4 && !exp.content.trim()) {
|
|
5525
|
+
{
|
|
5526
|
+
exp = void 0;
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
if (arg.type !== 4) {
|
|
5530
|
+
arg.children.unshift(`(`);
|
|
5531
|
+
arg.children.push(`) || ""`);
|
|
5532
|
+
} else if (!arg.isStatic) {
|
|
5533
|
+
arg.content = arg.content ? `${arg.content} || ""` : `""`;
|
|
5534
|
+
}
|
|
5535
|
+
if (modifiers.some((mod) => mod.content === "camel")) {
|
|
5536
|
+
if (arg.type === 4) {
|
|
5537
|
+
if (arg.isStatic) {
|
|
5538
|
+
arg.content = camelize(arg.content);
|
|
5539
|
+
} else {
|
|
5540
|
+
arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
|
|
5541
|
+
}
|
|
5542
|
+
} else {
|
|
5543
|
+
arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
|
|
5544
|
+
arg.children.push(`)`);
|
|
5545
|
+
}
|
|
5546
|
+
}
|
|
5547
|
+
if (!context.inSSR) {
|
|
5548
|
+
if (modifiers.some((mod) => mod.content === "prop")) {
|
|
5549
|
+
injectPrefix(arg, ".");
|
|
5550
|
+
}
|
|
5551
|
+
if (modifiers.some((mod) => mod.content === "attr")) {
|
|
5552
|
+
injectPrefix(arg, "^");
|
|
5553
|
+
}
|
|
5554
|
+
}
|
|
5555
|
+
return {
|
|
5556
|
+
props: [createObjectProperty(arg, exp)]
|
|
5557
|
+
};
|
|
5558
|
+
};
|
|
5559
|
+
const injectPrefix = (arg, prefix) => {
|
|
5560
|
+
if (arg.type === 4) {
|
|
5561
|
+
if (arg.isStatic) {
|
|
5562
|
+
arg.content = prefix + arg.content;
|
|
5563
|
+
} else {
|
|
5564
|
+
arg.content = `\`${prefix}\${${arg.content}}\``;
|
|
5565
|
+
}
|
|
5566
|
+
} else {
|
|
5567
|
+
arg.children.unshift(`'${prefix}' + (`);
|
|
5568
|
+
arg.children.push(`)`);
|
|
5569
|
+
}
|
|
5570
|
+
};
|
|
5571
|
+
|
|
5592
5572
|
const transformText = (node, context) => {
|
|
5593
5573
|
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
5594
5574
|
return () => {
|
|
@@ -5725,7 +5705,7 @@ const transformModel$1 = (dir, node, context) => {
|
|
|
5725
5705
|
];
|
|
5726
5706
|
if (dir.modifiers.length && node.tagType === 1) {
|
|
5727
5707
|
const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
|
5728
|
-
const modifiersKey = arg ? isStaticExp(arg) ?
|
|
5708
|
+
const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
|
5729
5709
|
props.push(
|
|
5730
5710
|
createObjectProperty(
|
|
5731
5711
|
modifiersKey,
|
|
@@ -5897,7 +5877,7 @@ const seen = /* @__PURE__ */ new WeakSet();
|
|
|
5897
5877
|
const transformMemo = (node, context) => {
|
|
5898
5878
|
if (node.type === 1) {
|
|
5899
5879
|
const dir = findDir(node, "memo");
|
|
5900
|
-
if (!dir || seen.has(node)) {
|
|
5880
|
+
if (!dir || seen.has(node) || context.inSSR) {
|
|
5901
5881
|
return;
|
|
5902
5882
|
}
|
|
5903
5883
|
seen.add(node);
|
|
@@ -5919,9 +5899,36 @@ const transformMemo = (node, context) => {
|
|
|
5919
5899
|
}
|
|
5920
5900
|
};
|
|
5921
5901
|
|
|
5902
|
+
const transformVBindShorthand = (node, context) => {
|
|
5903
|
+
if (node.type === 1) {
|
|
5904
|
+
for (const prop of node.props) {
|
|
5905
|
+
if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
|
|
5906
|
+
prop.exp.type === 4 && !prop.exp.content.trim()) && prop.arg) {
|
|
5907
|
+
const arg = prop.arg;
|
|
5908
|
+
if (arg.type !== 4 || !arg.isStatic) {
|
|
5909
|
+
context.onError(
|
|
5910
|
+
createCompilerError(
|
|
5911
|
+
52,
|
|
5912
|
+
arg.loc
|
|
5913
|
+
)
|
|
5914
|
+
);
|
|
5915
|
+
prop.exp = createSimpleExpression("", true, arg.loc);
|
|
5916
|
+
} else {
|
|
5917
|
+
const propName = camelize(arg.content);
|
|
5918
|
+
if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
|
|
5919
|
+
propName[0] === "-") {
|
|
5920
|
+
prop.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
}
|
|
5926
|
+
};
|
|
5927
|
+
|
|
5922
5928
|
function getBaseTransformPreset(prefixIdentifiers) {
|
|
5923
5929
|
return [
|
|
5924
5930
|
[
|
|
5931
|
+
transformVBindShorthand,
|
|
5925
5932
|
transformOnce,
|
|
5926
5933
|
transformIf,
|
|
5927
5934
|
transformMemo,
|
|
@@ -6064,7 +6071,7 @@ const parserOptions = {
|
|
|
6064
6071
|
let ns = parent ? parent.ns : rootNamespace;
|
|
6065
6072
|
if (parent && ns === 2) {
|
|
6066
6073
|
if (parent.tag === "annotation-xml") {
|
|
6067
|
-
if (tag
|
|
6074
|
+
if (isSVGTag(tag)) {
|
|
6068
6075
|
return 1;
|
|
6069
6076
|
}
|
|
6070
6077
|
if (parent.props.some(
|
|
@@ -6081,10 +6088,10 @@ const parserOptions = {
|
|
|
6081
6088
|
}
|
|
6082
6089
|
}
|
|
6083
6090
|
if (ns === 0) {
|
|
6084
|
-
if (tag
|
|
6091
|
+
if (isSVGTag(tag)) {
|
|
6085
6092
|
return 1;
|
|
6086
6093
|
}
|
|
6087
|
-
if (tag
|
|
6094
|
+
if (isMathMLTag(tag)) {
|
|
6088
6095
|
return 2;
|
|
6089
6096
|
}
|
|
6090
6097
|
}
|
|
@@ -6411,46 +6418,46 @@ const transformTransition = (node, context) => {
|
|
|
6411
6418
|
if (node.type === 1 && node.tagType === 1) {
|
|
6412
6419
|
const component = context.isBuiltInComponent(node.tag);
|
|
6413
6420
|
if (component === TRANSITION) {
|
|
6414
|
-
return ()
|
|
6415
|
-
if (!node.children.length) {
|
|
6416
|
-
return;
|
|
6417
|
-
}
|
|
6418
|
-
if (hasMultipleChildren(node)) {
|
|
6419
|
-
context.onError(
|
|
6420
|
-
createDOMCompilerError(
|
|
6421
|
-
62,
|
|
6422
|
-
{
|
|
6423
|
-
start: node.children[0].loc.start,
|
|
6424
|
-
end: node.children[node.children.length - 1].loc.end,
|
|
6425
|
-
source: ""
|
|
6426
|
-
}
|
|
6427
|
-
)
|
|
6428
|
-
);
|
|
6429
|
-
}
|
|
6430
|
-
const child = node.children[0];
|
|
6431
|
-
if (child.type === 1) {
|
|
6432
|
-
for (const p of child.props) {
|
|
6433
|
-
if (p.type === 7 && p.name === "show") {
|
|
6434
|
-
node.props.push({
|
|
6435
|
-
type: 6,
|
|
6436
|
-
name: "persisted",
|
|
6437
|
-
nameLoc: node.loc,
|
|
6438
|
-
value: void 0,
|
|
6439
|
-
loc: node.loc
|
|
6440
|
-
});
|
|
6441
|
-
}
|
|
6442
|
-
}
|
|
6443
|
-
}
|
|
6444
|
-
};
|
|
6421
|
+
return postTransformTransition(node, context.onError);
|
|
6445
6422
|
}
|
|
6446
6423
|
}
|
|
6447
6424
|
};
|
|
6448
|
-
function
|
|
6425
|
+
function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
|
|
6426
|
+
return () => {
|
|
6427
|
+
if (!node.children.length) {
|
|
6428
|
+
return;
|
|
6429
|
+
}
|
|
6430
|
+
if (hasMultipleChildren(node)) {
|
|
6431
|
+
onError(
|
|
6432
|
+
createDOMCompilerError(62, {
|
|
6433
|
+
start: node.children[0].loc.start,
|
|
6434
|
+
end: node.children[node.children.length - 1].loc.end,
|
|
6435
|
+
source: ""
|
|
6436
|
+
})
|
|
6437
|
+
);
|
|
6438
|
+
}
|
|
6439
|
+
const child = node.children[0];
|
|
6440
|
+
if (child.type === 1) {
|
|
6441
|
+
for (const p of child.props) {
|
|
6442
|
+
if (p.type === 7 && p.name === "show") {
|
|
6443
|
+
node.props.push({
|
|
6444
|
+
type: 6,
|
|
6445
|
+
name: "persisted",
|
|
6446
|
+
nameLoc: node.loc,
|
|
6447
|
+
value: void 0,
|
|
6448
|
+
loc: node.loc
|
|
6449
|
+
});
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6453
|
+
};
|
|
6454
|
+
}
|
|
6455
|
+
function defaultHasMultipleChildren(node) {
|
|
6449
6456
|
const children = node.children = node.children.filter(
|
|
6450
6457
|
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
|
6451
6458
|
);
|
|
6452
6459
|
const child = children[0];
|
|
6453
|
-
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(
|
|
6460
|
+
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
|
|
6454
6461
|
}
|
|
6455
6462
|
|
|
6456
6463
|
const ignoreSideEffectTags = (node, context) => {
|
|
@@ -6679,4 +6686,4 @@ function parse(template, options = {}) {
|
|
|
6679
6686
|
return baseParse(template, extend({}, parserOptions, options));
|
|
6680
6687
|
}
|
|
6681
6688
|
|
|
6682
|
-
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, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE,
|
|
6689
|
+
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, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, NewlineType, 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, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|