@vue/compiler-core 3.3.0-alpha.1 → 3.3.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 +379 -379
- package/dist/compiler-core.cjs.prod.js +371 -371
- package/dist/compiler-core.esm-bundler.js +368 -367
- package/package.json +2 -2
|
@@ -22,63 +22,63 @@ function createCompilerError(code, loc, messages, additionalMessage) {
|
|
|
22
22
|
}
|
|
23
23
|
const errorMessages = {
|
|
24
24
|
// parse errors
|
|
25
|
-
[0]: "Illegal comment.",
|
|
26
|
-
[1]: "CDATA section is allowed only in XML context.",
|
|
27
|
-
[2]: "Duplicate attribute.",
|
|
28
|
-
[3]: "End tag cannot have attributes.",
|
|
29
|
-
[4]: "Illegal '/' in tags.",
|
|
30
|
-
[5]: "Unexpected EOF in tag.",
|
|
31
|
-
[6]: "Unexpected EOF in CDATA section.",
|
|
32
|
-
[7]: "Unexpected EOF in comment.",
|
|
33
|
-
[8]: "Unexpected EOF in script.",
|
|
34
|
-
[9]: "Unexpected EOF in tag.",
|
|
35
|
-
[10]: "Incorrectly closed comment.",
|
|
36
|
-
[11]: "Incorrectly opened comment.",
|
|
37
|
-
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
38
|
-
[13]: "Attribute value was expected.",
|
|
39
|
-
[14]: "End tag name was expected.",
|
|
40
|
-
[15]: "Whitespace was expected.",
|
|
41
|
-
[16]: "Unexpected '<!--' in comment.",
|
|
42
|
-
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
43
|
-
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
44
|
-
[19]: "Attribute name cannot start with '='.",
|
|
45
|
-
[21]: "'<?' is allowed only in XML context.",
|
|
46
|
-
[20]: `Unexpected null character.`,
|
|
47
|
-
[22]: "Illegal '/' in tags.",
|
|
25
|
+
["0"]: "Illegal comment.",
|
|
26
|
+
["1"]: "CDATA section is allowed only in XML context.",
|
|
27
|
+
["2"]: "Duplicate attribute.",
|
|
28
|
+
["3"]: "End tag cannot have attributes.",
|
|
29
|
+
["4"]: "Illegal '/' in tags.",
|
|
30
|
+
["5"]: "Unexpected EOF in tag.",
|
|
31
|
+
["6"]: "Unexpected EOF in CDATA section.",
|
|
32
|
+
["7"]: "Unexpected EOF in comment.",
|
|
33
|
+
["8"]: "Unexpected EOF in script.",
|
|
34
|
+
["9"]: "Unexpected EOF in tag.",
|
|
35
|
+
["10"]: "Incorrectly closed comment.",
|
|
36
|
+
["11"]: "Incorrectly opened comment.",
|
|
37
|
+
["12"]: "Illegal tag name. Use '<' to print '<'.",
|
|
38
|
+
["13"]: "Attribute value was expected.",
|
|
39
|
+
["14"]: "End tag name was expected.",
|
|
40
|
+
["15"]: "Whitespace was expected.",
|
|
41
|
+
["16"]: "Unexpected '<!--' in comment.",
|
|
42
|
+
["17"]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
43
|
+
["18"]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
44
|
+
["19"]: "Attribute name cannot start with '='.",
|
|
45
|
+
["21"]: "'<?' is allowed only in XML context.",
|
|
46
|
+
["20"]: `Unexpected null character.`,
|
|
47
|
+
["22"]: "Illegal '/' in tags.",
|
|
48
48
|
// Vue-specific parse errors
|
|
49
|
-
[23]: "Invalid end tag.",
|
|
50
|
-
[24]: "Element is missing end tag.",
|
|
51
|
-
[25]: "Interpolation end sign was not found.",
|
|
52
|
-
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
53
|
-
[26]: "Legal directive name was expected.",
|
|
49
|
+
["23"]: "Invalid end tag.",
|
|
50
|
+
["24"]: "Element is missing end tag.",
|
|
51
|
+
["25"]: "Interpolation end sign was not found.",
|
|
52
|
+
["27"]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
53
|
+
["26"]: "Legal directive name was expected.",
|
|
54
54
|
// transform errors
|
|
55
|
-
[28]: `v-if/v-else-if is missing expression.`,
|
|
56
|
-
[29]: `v-if/else branches must use unique keys.`,
|
|
57
|
-
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
58
|
-
[31]: `v-for is missing expression.`,
|
|
59
|
-
[32]: `v-for has invalid expression.`,
|
|
60
|
-
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
61
|
-
[34]: `v-bind is missing expression.`,
|
|
62
|
-
[35]: `v-on is missing expression.`,
|
|
63
|
-
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
64
|
-
[37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
|
65
|
-
[38]: `Duplicate slot names found. `,
|
|
66
|
-
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
67
|
-
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
68
|
-
[41]: `v-model is missing expression.`,
|
|
69
|
-
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
70
|
-
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
71
|
-
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
55
|
+
["28"]: `v-if/v-else-if is missing expression.`,
|
|
56
|
+
["29"]: `v-if/else branches must use unique keys.`,
|
|
57
|
+
["30"]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
58
|
+
["31"]: `v-for is missing expression.`,
|
|
59
|
+
["32"]: `v-for has invalid expression.`,
|
|
60
|
+
["33"]: `<template v-for> key should be placed on the <template> tag.`,
|
|
61
|
+
["34"]: `v-bind is missing expression.`,
|
|
62
|
+
["35"]: `v-on is missing expression.`,
|
|
63
|
+
["36"]: `Unexpected custom directive on <slot> outlet.`,
|
|
64
|
+
["37"]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
|
65
|
+
["38"]: `Duplicate slot names found. `,
|
|
66
|
+
["39"]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
67
|
+
["40"]: `v-slot can only be used on components or <template> tags.`,
|
|
68
|
+
["41"]: `v-model is missing expression.`,
|
|
69
|
+
["42"]: `v-model value must be a valid JavaScript member expression.`,
|
|
70
|
+
["43"]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
71
|
+
["44"]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
72
72
|
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
73
|
-
[45]: `Error parsing JavaScript expression: `,
|
|
74
|
-
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
73
|
+
["45"]: `Error parsing JavaScript expression: `,
|
|
74
|
+
["46"]: `<KeepAlive> expects exactly one child component.`,
|
|
75
75
|
// generic errors
|
|
76
|
-
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
77
|
-
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
78
|
-
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
79
|
-
[50]: `"scopeId" option is only supported in module mode.`,
|
|
76
|
+
["47"]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
77
|
+
["48"]: `ES module mode is not supported in this build of compiler.`,
|
|
78
|
+
["49"]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
79
|
+
["50"]: `"scopeId" option is only supported in module mode.`,
|
|
80
80
|
// just to fulfill types
|
|
81
|
-
[51]: ``
|
|
81
|
+
["51"]: ``
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const FRAGMENT = Symbol(`Fragment` );
|
|
@@ -176,7 +176,7 @@ const locStub = {
|
|
|
176
176
|
};
|
|
177
177
|
function createRoot(children, loc = locStub) {
|
|
178
178
|
return {
|
|
179
|
-
type: 0,
|
|
179
|
+
type: "0",
|
|
180
180
|
children,
|
|
181
181
|
helpers: /* @__PURE__ */ new Set(),
|
|
182
182
|
components: [],
|
|
@@ -202,7 +202,7 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
return {
|
|
205
|
-
type: 13,
|
|
205
|
+
type: "13",
|
|
206
206
|
tag,
|
|
207
207
|
props,
|
|
208
208
|
children,
|
|
@@ -217,21 +217,21 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
217
217
|
}
|
|
218
218
|
function createArrayExpression(elements, loc = locStub) {
|
|
219
219
|
return {
|
|
220
|
-
type: 17,
|
|
220
|
+
type: "17",
|
|
221
221
|
loc,
|
|
222
222
|
elements
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
function createObjectExpression(properties, loc = locStub) {
|
|
226
226
|
return {
|
|
227
|
-
type: 15,
|
|
227
|
+
type: "15",
|
|
228
228
|
loc,
|
|
229
229
|
properties
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
function createObjectProperty(key, value) {
|
|
233
233
|
return {
|
|
234
|
-
type: 16,
|
|
234
|
+
type: "16",
|
|
235
235
|
loc: locStub,
|
|
236
236
|
key: shared.isString(key) ? createSimpleExpression(key, true) : key,
|
|
237
237
|
value
|
|
@@ -239,30 +239,30 @@ function createObjectProperty(key, value) {
|
|
|
239
239
|
}
|
|
240
240
|
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
|
241
241
|
return {
|
|
242
|
-
type: 4,
|
|
242
|
+
type: "4",
|
|
243
243
|
loc,
|
|
244
244
|
content,
|
|
245
245
|
isStatic,
|
|
246
|
-
constType: isStatic ? 3 : constType
|
|
246
|
+
constType: isStatic ? "3" : constType
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
function createInterpolation(content, loc) {
|
|
250
250
|
return {
|
|
251
|
-
type: 5,
|
|
251
|
+
type: "5",
|
|
252
252
|
loc,
|
|
253
253
|
content: shared.isString(content) ? createSimpleExpression(content, false, loc) : content
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
function createCompoundExpression(children, loc = locStub) {
|
|
257
257
|
return {
|
|
258
|
-
type: 8,
|
|
258
|
+
type: "8",
|
|
259
259
|
loc,
|
|
260
260
|
children
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
263
|
function createCallExpression(callee, args = [], loc = locStub) {
|
|
264
264
|
return {
|
|
265
|
-
type: 14,
|
|
265
|
+
type: "14",
|
|
266
266
|
loc,
|
|
267
267
|
callee,
|
|
268
268
|
arguments: args
|
|
@@ -270,7 +270,7 @@ function createCallExpression(callee, args = [], loc = locStub) {
|
|
|
270
270
|
}
|
|
271
271
|
function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
|
272
272
|
return {
|
|
273
|
-
type: 18,
|
|
273
|
+
type: "18",
|
|
274
274
|
params,
|
|
275
275
|
returns,
|
|
276
276
|
newline,
|
|
@@ -280,7 +280,7 @@ function createFunctionExpression(params, returns = void 0, newline = false, isS
|
|
|
280
280
|
}
|
|
281
281
|
function createConditionalExpression(test, consequent, alternate, newline = true) {
|
|
282
282
|
return {
|
|
283
|
-
type: 19,
|
|
283
|
+
type: "19",
|
|
284
284
|
test,
|
|
285
285
|
consequent,
|
|
286
286
|
alternate,
|
|
@@ -290,7 +290,7 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
290
290
|
}
|
|
291
291
|
function createCacheExpression(index, value, isVNode = false) {
|
|
292
292
|
return {
|
|
293
|
-
type: 20,
|
|
293
|
+
type: "20",
|
|
294
294
|
index,
|
|
295
295
|
value,
|
|
296
296
|
isVNode,
|
|
@@ -299,21 +299,21 @@ function createCacheExpression(index, value, isVNode = false) {
|
|
|
299
299
|
}
|
|
300
300
|
function createBlockStatement(body) {
|
|
301
301
|
return {
|
|
302
|
-
type: 21,
|
|
302
|
+
type: "21",
|
|
303
303
|
body,
|
|
304
304
|
loc: locStub
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
function createTemplateLiteral(elements) {
|
|
308
308
|
return {
|
|
309
|
-
type: 22,
|
|
309
|
+
type: "22",
|
|
310
310
|
elements,
|
|
311
311
|
loc: locStub
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
function createIfStatement(test, consequent, alternate) {
|
|
315
315
|
return {
|
|
316
|
-
type: 23,
|
|
316
|
+
type: "23",
|
|
317
317
|
test,
|
|
318
318
|
consequent,
|
|
319
319
|
alternate,
|
|
@@ -322,7 +322,7 @@ function createIfStatement(test, consequent, alternate) {
|
|
|
322
322
|
}
|
|
323
323
|
function createAssignmentExpression(left, right) {
|
|
324
324
|
return {
|
|
325
|
-
type: 24,
|
|
325
|
+
type: "24",
|
|
326
326
|
left,
|
|
327
327
|
right,
|
|
328
328
|
loc: locStub
|
|
@@ -330,20 +330,20 @@ function createAssignmentExpression(left, right) {
|
|
|
330
330
|
}
|
|
331
331
|
function createSequenceExpression(expressions) {
|
|
332
332
|
return {
|
|
333
|
-
type: 25,
|
|
333
|
+
type: "25",
|
|
334
334
|
expressions,
|
|
335
335
|
loc: locStub
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
function createReturnStatement(returns) {
|
|
339
339
|
return {
|
|
340
|
-
type: 26,
|
|
340
|
+
type: "26",
|
|
341
341
|
returns,
|
|
342
342
|
loc: locStub
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
346
|
+
const isStaticExp = (p) => p.type === "4" && p.isStatic;
|
|
347
347
|
const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
|
|
348
348
|
function isCoreComponent(tag) {
|
|
349
349
|
if (isBuiltInType(tag, "Teleport")) {
|
|
@@ -482,7 +482,7 @@ function assert(condition, msg) {
|
|
|
482
482
|
function findDir(node, name, allowEmpty = false) {
|
|
483
483
|
for (let i = 0; i < node.props.length; i++) {
|
|
484
484
|
const p = node.props[i];
|
|
485
|
-
if (p.type === 7 && (allowEmpty || p.exp) && (shared.isString(name) ? p.name === name : name.test(p.name))) {
|
|
485
|
+
if (p.type === "7" && (allowEmpty || p.exp) && (shared.isString(name) ? p.name === name : name.test(p.name))) {
|
|
486
486
|
return p;
|
|
487
487
|
}
|
|
488
488
|
}
|
|
@@ -490,7 +490,7 @@ function findDir(node, name, allowEmpty = false) {
|
|
|
490
490
|
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
491
491
|
for (let i = 0; i < node.props.length; i++) {
|
|
492
492
|
const p = node.props[i];
|
|
493
|
-
if (p.type === 6) {
|
|
493
|
+
if (p.type === "6") {
|
|
494
494
|
if (dynamicOnly)
|
|
495
495
|
continue;
|
|
496
496
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
@@ -506,23 +506,23 @@ function isStaticArgOf(arg, name) {
|
|
|
506
506
|
}
|
|
507
507
|
function hasDynamicKeyVBind(node) {
|
|
508
508
|
return node.props.some(
|
|
509
|
-
(p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
|
|
510
|
-
p.arg.type !== 4 || // v-bind:[_ctx.foo]
|
|
509
|
+
(p) => p.type === "7" && p.name === "bind" && (!p.arg || // v-bind="obj"
|
|
510
|
+
p.arg.type !== "4" || // v-bind:[_ctx.foo]
|
|
511
511
|
!p.arg.isStatic)
|
|
512
512
|
// v-bind:[foo]
|
|
513
513
|
);
|
|
514
514
|
}
|
|
515
515
|
function isText$1(node) {
|
|
516
|
-
return node.type === 5 || node.type === "
|
|
516
|
+
return node.type === "5" || node.type === "2";
|
|
517
517
|
}
|
|
518
518
|
function isVSlot(p) {
|
|
519
|
-
return p.type === 7 && p.name === "slot";
|
|
519
|
+
return p.type === "7" && p.name === "slot";
|
|
520
520
|
}
|
|
521
521
|
function isTemplateNode(node) {
|
|
522
|
-
return node.type === "
|
|
522
|
+
return node.type === "1" && node.tagType === "3";
|
|
523
523
|
}
|
|
524
524
|
function isSlotOutlet(node) {
|
|
525
|
-
return node.type === "
|
|
525
|
+
return node.type === "1" && node.tagType === "2";
|
|
526
526
|
}
|
|
527
527
|
function getVNodeHelper(ssr, isComponent) {
|
|
528
528
|
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
@@ -532,7 +532,7 @@ function getVNodeBlockHelper(ssr, isComponent) {
|
|
|
532
532
|
}
|
|
533
533
|
const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
534
534
|
function getUnnormalizedProps(props, callPath = []) {
|
|
535
|
-
if (props && !shared.isString(props) && props.type === 14) {
|
|
535
|
+
if (props && !shared.isString(props) && props.type === "14") {
|
|
536
536
|
const callee = props.callee;
|
|
537
537
|
if (!shared.isString(callee) && propsHelperSet.has(callee)) {
|
|
538
538
|
return getUnnormalizedProps(
|
|
@@ -545,10 +545,10 @@ function getUnnormalizedProps(props, callPath = []) {
|
|
|
545
545
|
}
|
|
546
546
|
function injectProp(node, prop, context) {
|
|
547
547
|
let propsWithInjection;
|
|
548
|
-
let props = node.type === 13 ? node.props : node.arguments[2];
|
|
548
|
+
let props = node.type === "13" ? node.props : node.arguments[2];
|
|
549
549
|
let callPath = [];
|
|
550
550
|
let parentCall;
|
|
551
|
-
if (props && !shared.isString(props) && props.type === 14) {
|
|
551
|
+
if (props && !shared.isString(props) && props.type === "14") {
|
|
552
552
|
const ret = getUnnormalizedProps(props);
|
|
553
553
|
props = ret[0];
|
|
554
554
|
callPath = ret[1];
|
|
@@ -556,9 +556,9 @@ function injectProp(node, prop, context) {
|
|
|
556
556
|
}
|
|
557
557
|
if (props == null || shared.isString(props)) {
|
|
558
558
|
propsWithInjection = createObjectExpression([prop]);
|
|
559
|
-
} else if (props.type === 14) {
|
|
559
|
+
} else if (props.type === "14") {
|
|
560
560
|
const first = props.arguments[0];
|
|
561
|
-
if (!shared.isString(first) && first.type === 15) {
|
|
561
|
+
if (!shared.isString(first) && first.type === "15") {
|
|
562
562
|
if (!hasProp(prop, first)) {
|
|
563
563
|
first.properties.unshift(prop);
|
|
564
564
|
}
|
|
@@ -573,7 +573,7 @@ function injectProp(node, prop, context) {
|
|
|
573
573
|
}
|
|
574
574
|
}
|
|
575
575
|
!propsWithInjection && (propsWithInjection = props);
|
|
576
|
-
} else if (props.type === 15) {
|
|
576
|
+
} else if (props.type === "15") {
|
|
577
577
|
if (!hasProp(prop, props)) {
|
|
578
578
|
props.properties.unshift(prop);
|
|
579
579
|
}
|
|
@@ -587,7 +587,7 @@ function injectProp(node, prop, context) {
|
|
|
587
587
|
parentCall = callPath[callPath.length - 2];
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
|
-
if (node.type === 13) {
|
|
590
|
+
if (node.type === "13") {
|
|
591
591
|
if (parentCall) {
|
|
592
592
|
parentCall.arguments[0] = propsWithInjection;
|
|
593
593
|
} else {
|
|
@@ -603,10 +603,10 @@ function injectProp(node, prop, context) {
|
|
|
603
603
|
}
|
|
604
604
|
function hasProp(prop, props) {
|
|
605
605
|
let result = false;
|
|
606
|
-
if (prop.key.type === 4) {
|
|
606
|
+
if (prop.key.type === "4") {
|
|
607
607
|
const propKeyName = prop.key.content;
|
|
608
608
|
result = props.properties.some(
|
|
609
|
-
(p) => p.key.type === 4 && p.key.content === propKeyName
|
|
609
|
+
(p) => p.key.type === "4" && p.key.content === propKeyName
|
|
610
610
|
);
|
|
611
611
|
}
|
|
612
612
|
return result;
|
|
@@ -621,42 +621,42 @@ function hasScopeRef(node, ids) {
|
|
|
621
621
|
return false;
|
|
622
622
|
}
|
|
623
623
|
switch (node.type) {
|
|
624
|
-
case "
|
|
624
|
+
case "1":
|
|
625
625
|
for (let i = 0; i < node.props.length; i++) {
|
|
626
626
|
const p = node.props[i];
|
|
627
|
-
if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
627
|
+
if (p.type === "7" && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
628
628
|
return true;
|
|
629
629
|
}
|
|
630
630
|
}
|
|
631
631
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
632
|
-
case 11:
|
|
632
|
+
case "11":
|
|
633
633
|
if (hasScopeRef(node.source, ids)) {
|
|
634
634
|
return true;
|
|
635
635
|
}
|
|
636
636
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
637
|
-
case 9:
|
|
637
|
+
case "9":
|
|
638
638
|
return node.branches.some((b) => hasScopeRef(b, ids));
|
|
639
|
-
case 10:
|
|
639
|
+
case "10":
|
|
640
640
|
if (hasScopeRef(node.condition, ids)) {
|
|
641
641
|
return true;
|
|
642
642
|
}
|
|
643
643
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
644
|
-
case 4:
|
|
644
|
+
case "4":
|
|
645
645
|
return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
|
|
646
|
-
case 8:
|
|
646
|
+
case "8":
|
|
647
647
|
return node.children.some((c) => shared.isObject(c) && hasScopeRef(c, ids));
|
|
648
|
-
case 5:
|
|
649
|
-
case 12:
|
|
648
|
+
case "5":
|
|
649
|
+
case "12":
|
|
650
650
|
return hasScopeRef(node.content, ids);
|
|
651
|
-
case "
|
|
652
|
-
case "
|
|
651
|
+
case "2":
|
|
652
|
+
case "3":
|
|
653
653
|
return false;
|
|
654
654
|
default:
|
|
655
655
|
return false;
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
function getMemoedVNodeCall(node) {
|
|
659
|
-
if (node.type === 14 && node.callee === WITH_MEMO) {
|
|
659
|
+
if (node.type === "14" && node.callee === WITH_MEMO) {
|
|
660
660
|
return node.arguments[1].returns;
|
|
661
661
|
} else {
|
|
662
662
|
return node;
|
|
@@ -753,8 +753,8 @@ const decodeMap = {
|
|
|
753
753
|
};
|
|
754
754
|
const defaultParserOptions = {
|
|
755
755
|
delimiters: [`{{`, `}}`],
|
|
756
|
-
getNamespace: () => 0,
|
|
757
|
-
getTextMode: () => 0,
|
|
756
|
+
getNamespace: () => "0",
|
|
757
|
+
getTextMode: () => "0",
|
|
758
758
|
isVoidTag: shared.NO,
|
|
759
759
|
isPreTag: shared.NO,
|
|
760
760
|
isCustomElement: shared.NO,
|
|
@@ -767,7 +767,7 @@ function baseParse(content, options = {}) {
|
|
|
767
767
|
const context = createParserContext(content, options);
|
|
768
768
|
const start = getCursor(context);
|
|
769
769
|
return createRoot(
|
|
770
|
-
parseChildren(context, 0, []),
|
|
770
|
+
parseChildren(context, "0", []),
|
|
771
771
|
getSelection(context, start)
|
|
772
772
|
);
|
|
773
773
|
}
|
|
@@ -791,48 +791,48 @@ function createParserContext(content, rawOptions) {
|
|
|
791
791
|
}
|
|
792
792
|
function parseChildren(context, mode, ancestors) {
|
|
793
793
|
const parent = last(ancestors);
|
|
794
|
-
const ns = parent ? parent.ns : 0;
|
|
794
|
+
const ns = parent ? parent.ns : "0";
|
|
795
795
|
const nodes = [];
|
|
796
796
|
while (!isEnd(context, mode, ancestors)) {
|
|
797
797
|
const s = context.source;
|
|
798
798
|
let node = void 0;
|
|
799
|
-
if (mode === 0 || mode === 1) {
|
|
799
|
+
if (mode === "0" || mode === "1") {
|
|
800
800
|
if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
|
801
801
|
node = parseInterpolation(context, mode);
|
|
802
|
-
} else if (mode === 0 && s[0] === "<") {
|
|
802
|
+
} else if (mode === "0" && s[0] === "<") {
|
|
803
803
|
if (s.length === 1) {
|
|
804
|
-
emitError(context, 5, 1);
|
|
804
|
+
emitError(context, "5", 1);
|
|
805
805
|
} else if (s[1] === "!") {
|
|
806
806
|
if (startsWith(s, "<!--")) {
|
|
807
807
|
node = parseComment(context);
|
|
808
808
|
} else if (startsWith(s, "<!DOCTYPE")) {
|
|
809
809
|
node = parseBogusComment(context);
|
|
810
810
|
} else if (startsWith(s, "<![CDATA[")) {
|
|
811
|
-
if (ns !== 0) {
|
|
811
|
+
if (ns !== "0") {
|
|
812
812
|
node = parseCDATA(context, ancestors);
|
|
813
813
|
} else {
|
|
814
|
-
emitError(context, 1);
|
|
814
|
+
emitError(context, "1");
|
|
815
815
|
node = parseBogusComment(context);
|
|
816
816
|
}
|
|
817
817
|
} else {
|
|
818
|
-
emitError(context, 11);
|
|
818
|
+
emitError(context, "11");
|
|
819
819
|
node = parseBogusComment(context);
|
|
820
820
|
}
|
|
821
821
|
} else if (s[1] === "/") {
|
|
822
822
|
if (s.length === 2) {
|
|
823
|
-
emitError(context, 5, 2);
|
|
823
|
+
emitError(context, "5", 2);
|
|
824
824
|
} else if (s[2] === ">") {
|
|
825
|
-
emitError(context, 14, 2);
|
|
825
|
+
emitError(context, "14", 2);
|
|
826
826
|
advanceBy(context, 3);
|
|
827
827
|
continue;
|
|
828
828
|
} else if (/[a-z]/i.test(s[2])) {
|
|
829
|
-
emitError(context, 23);
|
|
829
|
+
emitError(context, "23");
|
|
830
830
|
parseTag(context, TagType.End, parent);
|
|
831
831
|
continue;
|
|
832
832
|
} else {
|
|
833
833
|
emitError(
|
|
834
834
|
context,
|
|
835
|
-
12,
|
|
835
|
+
"12",
|
|
836
836
|
2
|
|
837
837
|
);
|
|
838
838
|
node = parseBogusComment(context);
|
|
@@ -843,7 +843,7 @@ function parseChildren(context, mode, ancestors) {
|
|
|
843
843
|
"COMPILER_NATIVE_TEMPLATE",
|
|
844
844
|
context
|
|
845
845
|
) && node && node.tag === "template" && !node.props.some(
|
|
846
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
846
|
+
(p) => p.type === "7" && isSpecialTemplateDirective(p.name)
|
|
847
847
|
)) {
|
|
848
848
|
warnDeprecation(
|
|
849
849
|
"COMPILER_NATIVE_TEMPLATE",
|
|
@@ -855,12 +855,12 @@ function parseChildren(context, mode, ancestors) {
|
|
|
855
855
|
} else if (s[1] === "?") {
|
|
856
856
|
emitError(
|
|
857
857
|
context,
|
|
858
|
-
21,
|
|
858
|
+
"21",
|
|
859
859
|
1
|
|
860
860
|
);
|
|
861
861
|
node = parseBogusComment(context);
|
|
862
862
|
} else {
|
|
863
|
-
emitError(context, 12, 1);
|
|
863
|
+
emitError(context, "12", 1);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
866
|
}
|
|
@@ -876,16 +876,16 @@ function parseChildren(context, mode, ancestors) {
|
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
878
|
let removedWhitespace = false;
|
|
879
|
-
if (mode !== 2 && mode !== 1) {
|
|
879
|
+
if (mode !== "2" && mode !== "1") {
|
|
880
880
|
const shouldCondense = context.options.whitespace !== "preserve";
|
|
881
881
|
for (let i = 0; i < nodes.length; i++) {
|
|
882
882
|
const node = nodes[i];
|
|
883
|
-
if (node.type === "
|
|
883
|
+
if (node.type === "2") {
|
|
884
884
|
if (!context.inPre) {
|
|
885
885
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
886
886
|
const prev = nodes[i - 1];
|
|
887
887
|
const next = nodes[i + 1];
|
|
888
|
-
if (!prev || !next || shouldCondense && (prev.type === "
|
|
888
|
+
if (!prev || !next || shouldCondense && (prev.type === "3" && next.type === "3" || prev.type === "3" && next.type === "1" || prev.type === "1" && next.type === "3" || prev.type === "1" && next.type === "1" && /[\r\n]/.test(node.content))) {
|
|
889
889
|
removedWhitespace = true;
|
|
890
890
|
nodes[i] = null;
|
|
891
891
|
} else {
|
|
@@ -897,14 +897,14 @@ function parseChildren(context, mode, ancestors) {
|
|
|
897
897
|
} else {
|
|
898
898
|
node.content = node.content.replace(/\r\n/g, "\n");
|
|
899
899
|
}
|
|
900
|
-
} else if (node.type === "
|
|
900
|
+
} else if (node.type === "3" && !context.options.comments) {
|
|
901
901
|
removedWhitespace = true;
|
|
902
902
|
nodes[i] = null;
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
905
|
if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
|
906
906
|
const first = nodes[0];
|
|
907
|
-
if (first && first.type === "
|
|
907
|
+
if (first && first.type === "2") {
|
|
908
908
|
first.content = first.content.replace(/^\r?\n/, "");
|
|
909
909
|
}
|
|
910
910
|
}
|
|
@@ -912,9 +912,9 @@ function parseChildren(context, mode, ancestors) {
|
|
|
912
912
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
913
913
|
}
|
|
914
914
|
function pushNode(nodes, node) {
|
|
915
|
-
if (node.type === "
|
|
915
|
+
if (node.type === "2") {
|
|
916
916
|
const prev = last(nodes);
|
|
917
|
-
if (prev && prev.type === "
|
|
917
|
+
if (prev && prev.type === "2" && prev.loc.end.offset === node.loc.start.offset) {
|
|
918
918
|
prev.content += node.content;
|
|
919
919
|
prev.loc.end = node.loc.end;
|
|
920
920
|
prev.loc.source += node.loc.source;
|
|
@@ -925,9 +925,9 @@ function pushNode(nodes, node) {
|
|
|
925
925
|
}
|
|
926
926
|
function parseCDATA(context, ancestors) {
|
|
927
927
|
advanceBy(context, 9);
|
|
928
|
-
const nodes = parseChildren(context, 3, ancestors);
|
|
928
|
+
const nodes = parseChildren(context, "3", ancestors);
|
|
929
929
|
if (context.source.length === 0) {
|
|
930
|
-
emitError(context, 6);
|
|
930
|
+
emitError(context, "6");
|
|
931
931
|
} else {
|
|
932
932
|
advanceBy(context, 3);
|
|
933
933
|
}
|
|
@@ -940,13 +940,13 @@ function parseComment(context) {
|
|
|
940
940
|
if (!match) {
|
|
941
941
|
content = context.source.slice(4);
|
|
942
942
|
advanceBy(context, context.source.length);
|
|
943
|
-
emitError(context, 7);
|
|
943
|
+
emitError(context, "7");
|
|
944
944
|
} else {
|
|
945
945
|
if (match.index <= 3) {
|
|
946
|
-
emitError(context, 0);
|
|
946
|
+
emitError(context, "0");
|
|
947
947
|
}
|
|
948
948
|
if (match[1]) {
|
|
949
|
-
emitError(context, 10);
|
|
949
|
+
emitError(context, "10");
|
|
950
950
|
}
|
|
951
951
|
content = context.source.slice(4, match.index);
|
|
952
952
|
const s = context.source.slice(0, match.index);
|
|
@@ -954,14 +954,14 @@ function parseComment(context) {
|
|
|
954
954
|
while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
|
|
955
955
|
advanceBy(context, nestedIndex - prevIndex + 1);
|
|
956
956
|
if (nestedIndex + 4 < s.length) {
|
|
957
|
-
emitError(context, 16);
|
|
957
|
+
emitError(context, "16");
|
|
958
958
|
}
|
|
959
959
|
prevIndex = nestedIndex + 1;
|
|
960
960
|
}
|
|
961
961
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
962
962
|
}
|
|
963
963
|
return {
|
|
964
|
-
type: "
|
|
964
|
+
type: "3",
|
|
965
965
|
content,
|
|
966
966
|
loc: getSelection(context, start)
|
|
967
967
|
};
|
|
@@ -979,7 +979,7 @@ function parseBogusComment(context) {
|
|
|
979
979
|
advanceBy(context, closeIndex + 1);
|
|
980
980
|
}
|
|
981
981
|
return {
|
|
982
|
-
type: "
|
|
982
|
+
type: "3",
|
|
983
983
|
content,
|
|
984
984
|
loc: getSelection(context, start)
|
|
985
985
|
};
|
|
@@ -1006,7 +1006,7 @@ function parseElement(context, ancestors) {
|
|
|
1006
1006
|
ancestors.pop();
|
|
1007
1007
|
{
|
|
1008
1008
|
const inlineTemplateProp = element.props.find(
|
|
1009
|
-
(p) => p.type === 6 && p.name === "inline-template"
|
|
1009
|
+
(p) => p.type === "6" && p.name === "inline-template"
|
|
1010
1010
|
);
|
|
1011
1011
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1012
1012
|
"COMPILER_INLINE_TEMPLATE",
|
|
@@ -1015,7 +1015,7 @@ function parseElement(context, ancestors) {
|
|
|
1015
1015
|
)) {
|
|
1016
1016
|
const loc = getSelection(context, element.loc.end);
|
|
1017
1017
|
inlineTemplateProp.value = {
|
|
1018
|
-
type: "
|
|
1018
|
+
type: "2",
|
|
1019
1019
|
content: loc.source,
|
|
1020
1020
|
loc
|
|
1021
1021
|
};
|
|
@@ -1025,11 +1025,11 @@ function parseElement(context, ancestors) {
|
|
|
1025
1025
|
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1026
1026
|
parseTag(context, TagType.End, parent);
|
|
1027
1027
|
} else {
|
|
1028
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1028
|
+
emitError(context, "24", 0, element.loc.start);
|
|
1029
1029
|
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1030
1030
|
const first = children[0];
|
|
1031
1031
|
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1032
|
-
emitError(context, 8);
|
|
1032
|
+
emitError(context, "8");
|
|
1033
1033
|
}
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
@@ -1063,7 +1063,7 @@ function parseTag(context, type, parent) {
|
|
|
1063
1063
|
context.inPre = true;
|
|
1064
1064
|
}
|
|
1065
1065
|
let props = parseAttributes(context, type);
|
|
1066
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1066
|
+
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === "7" && p.name === "pre")) {
|
|
1067
1067
|
context.inVPre = true;
|
|
1068
1068
|
shared.extend(context, cursor);
|
|
1069
1069
|
context.source = currentSource;
|
|
@@ -1071,11 +1071,11 @@ function parseTag(context, type, parent) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
let isSelfClosing = false;
|
|
1073
1073
|
if (context.source.length === 0) {
|
|
1074
|
-
emitError(context, 9);
|
|
1074
|
+
emitError(context, "9");
|
|
1075
1075
|
} else {
|
|
1076
1076
|
isSelfClosing = startsWith(context.source, "/>");
|
|
1077
1077
|
if (type === 1 /* End */ && isSelfClosing) {
|
|
1078
|
-
emitError(context, 4);
|
|
1078
|
+
emitError(context, "4");
|
|
1079
1079
|
}
|
|
1080
1080
|
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1081
1081
|
}
|
|
@@ -1090,7 +1090,7 @@ function parseTag(context, type, parent) {
|
|
|
1090
1090
|
let hasFor = false;
|
|
1091
1091
|
for (let i = 0; i < props.length; i++) {
|
|
1092
1092
|
const p = props[i];
|
|
1093
|
-
if (p.type === 7) {
|
|
1093
|
+
if (p.type === "7") {
|
|
1094
1094
|
if (p.name === "if") {
|
|
1095
1095
|
hasIf = true;
|
|
1096
1096
|
} else if (p.name === "for") {
|
|
@@ -1107,22 +1107,22 @@ function parseTag(context, type, parent) {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
|
-
let tagType = 0;
|
|
1110
|
+
let tagType = "0";
|
|
1111
1111
|
if (!context.inVPre) {
|
|
1112
1112
|
if (tag === "slot") {
|
|
1113
|
-
tagType = 2;
|
|
1113
|
+
tagType = "2";
|
|
1114
1114
|
} else if (tag === "template") {
|
|
1115
1115
|
if (props.some(
|
|
1116
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1116
|
+
(p) => p.type === "7" && isSpecialTemplateDirective(p.name)
|
|
1117
1117
|
)) {
|
|
1118
|
-
tagType = 3;
|
|
1118
|
+
tagType = "3";
|
|
1119
1119
|
}
|
|
1120
1120
|
} else if (isComponent(tag, props, context)) {
|
|
1121
|
-
tagType = 1;
|
|
1121
|
+
tagType = "1";
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
1124
|
return {
|
|
1125
|
-
type: "
|
|
1125
|
+
type: "1",
|
|
1126
1126
|
ns,
|
|
1127
1127
|
tag,
|
|
1128
1128
|
tagType,
|
|
@@ -1144,7 +1144,7 @@ function isComponent(tag, props, context) {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
for (let i = 0; i < props.length; i++) {
|
|
1146
1146
|
const p = props[i];
|
|
1147
|
-
if (p.type === 6) {
|
|
1147
|
+
if (p.type === "6") {
|
|
1148
1148
|
if (p.name === "is" && p.value) {
|
|
1149
1149
|
if (p.value.content.startsWith("vue:")) {
|
|
1150
1150
|
return true;
|
|
@@ -1177,23 +1177,23 @@ function parseAttributes(context, type) {
|
|
|
1177
1177
|
const attributeNames = /* @__PURE__ */ new Set();
|
|
1178
1178
|
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1179
1179
|
if (startsWith(context.source, "/")) {
|
|
1180
|
-
emitError(context, 22);
|
|
1180
|
+
emitError(context, "22");
|
|
1181
1181
|
advanceBy(context, 1);
|
|
1182
1182
|
advanceSpaces(context);
|
|
1183
1183
|
continue;
|
|
1184
1184
|
}
|
|
1185
1185
|
if (type === 1 /* End */) {
|
|
1186
|
-
emitError(context, 3);
|
|
1186
|
+
emitError(context, "3");
|
|
1187
1187
|
}
|
|
1188
1188
|
const attr = parseAttribute(context, attributeNames);
|
|
1189
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1189
|
+
if (attr.type === "6" && attr.value && attr.name === "class") {
|
|
1190
1190
|
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1191
1191
|
}
|
|
1192
1192
|
if (type === 0 /* Start */) {
|
|
1193
1193
|
props.push(attr);
|
|
1194
1194
|
}
|
|
1195
1195
|
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1196
|
-
emitError(context, 15);
|
|
1196
|
+
emitError(context, "15");
|
|
1197
1197
|
}
|
|
1198
1198
|
advanceSpaces(context);
|
|
1199
1199
|
}
|
|
@@ -1204,11 +1204,11 @@ function parseAttribute(context, nameSet) {
|
|
|
1204
1204
|
const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
|
1205
1205
|
const name = match[0];
|
|
1206
1206
|
if (nameSet.has(name)) {
|
|
1207
|
-
emitError(context, 2);
|
|
1207
|
+
emitError(context, "2");
|
|
1208
1208
|
}
|
|
1209
1209
|
nameSet.add(name);
|
|
1210
1210
|
if (name[0] === "=") {
|
|
1211
|
-
emitError(context, 19);
|
|
1211
|
+
emitError(context, "19");
|
|
1212
1212
|
}
|
|
1213
1213
|
{
|
|
1214
1214
|
const pattern = /["'<]/g;
|
|
@@ -1216,7 +1216,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1216
1216
|
while (m = pattern.exec(name)) {
|
|
1217
1217
|
emitError(
|
|
1218
1218
|
context,
|
|
1219
|
-
17,
|
|
1219
|
+
"17",
|
|
1220
1220
|
m.index
|
|
1221
1221
|
);
|
|
1222
1222
|
}
|
|
@@ -1229,7 +1229,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1229
1229
|
advanceSpaces(context);
|
|
1230
1230
|
value = parseAttributeValue(context);
|
|
1231
1231
|
if (!value) {
|
|
1232
|
-
emitError(context, 13);
|
|
1232
|
+
emitError(context, "13");
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
const loc = getSelection(context, start);
|
|
@@ -1259,7 +1259,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1259
1259
|
if (!content.endsWith("]")) {
|
|
1260
1260
|
emitError(
|
|
1261
1261
|
context,
|
|
1262
|
-
27
|
|
1262
|
+
"27"
|
|
1263
1263
|
);
|
|
1264
1264
|
content = content.slice(1);
|
|
1265
1265
|
} else {
|
|
@@ -1269,10 +1269,10 @@ function parseAttribute(context, nameSet) {
|
|
|
1269
1269
|
content += match2[3] || "";
|
|
1270
1270
|
}
|
|
1271
1271
|
arg = {
|
|
1272
|
-
type: 4,
|
|
1272
|
+
type: "4",
|
|
1273
1273
|
content,
|
|
1274
1274
|
isStatic,
|
|
1275
|
-
constType: isStatic ? 3 : 0,
|
|
1275
|
+
constType: isStatic ? "3" : 0,
|
|
1276
1276
|
loc: loc2
|
|
1277
1277
|
};
|
|
1278
1278
|
}
|
|
@@ -1305,10 +1305,10 @@ function parseAttribute(context, nameSet) {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
}
|
|
1307
1307
|
return {
|
|
1308
|
-
type: 7,
|
|
1308
|
+
type: "7",
|
|
1309
1309
|
name: dirName,
|
|
1310
1310
|
exp: value && {
|
|
1311
|
-
type: 4,
|
|
1311
|
+
type: "4",
|
|
1312
1312
|
content: value.content,
|
|
1313
1313
|
isStatic: false,
|
|
1314
1314
|
// Treat as non-constant by default. This can be potentially set to
|
|
@@ -1322,13 +1322,13 @@ function parseAttribute(context, nameSet) {
|
|
|
1322
1322
|
};
|
|
1323
1323
|
}
|
|
1324
1324
|
if (!context.inVPre && startsWith(name, "v-")) {
|
|
1325
|
-
emitError(context, 26);
|
|
1325
|
+
emitError(context, "26");
|
|
1326
1326
|
}
|
|
1327
1327
|
return {
|
|
1328
|
-
type: 6,
|
|
1328
|
+
type: "6",
|
|
1329
1329
|
name,
|
|
1330
1330
|
value: value && {
|
|
1331
|
-
type: "
|
|
1331
|
+
type: "2",
|
|
1332
1332
|
content: value.content,
|
|
1333
1333
|
loc: value.loc
|
|
1334
1334
|
},
|
|
@@ -1347,10 +1347,10 @@ function parseAttributeValue(context) {
|
|
|
1347
1347
|
content = parseTextData(
|
|
1348
1348
|
context,
|
|
1349
1349
|
context.source.length,
|
|
1350
|
-
4
|
|
1350
|
+
"4"
|
|
1351
1351
|
);
|
|
1352
1352
|
} else {
|
|
1353
|
-
content = parseTextData(context, endIndex, 4);
|
|
1353
|
+
content = parseTextData(context, endIndex, "4");
|
|
1354
1354
|
advanceBy(context, 1);
|
|
1355
1355
|
}
|
|
1356
1356
|
} else {
|
|
@@ -1363,11 +1363,11 @@ function parseAttributeValue(context) {
|
|
|
1363
1363
|
while (m = unexpectedChars.exec(match[0])) {
|
|
1364
1364
|
emitError(
|
|
1365
1365
|
context,
|
|
1366
|
-
18,
|
|
1366
|
+
"18",
|
|
1367
1367
|
m.index
|
|
1368
1368
|
);
|
|
1369
1369
|
}
|
|
1370
|
-
content = parseTextData(context, match[0].length, 4);
|
|
1370
|
+
content = parseTextData(context, match[0].length, "4");
|
|
1371
1371
|
}
|
|
1372
1372
|
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1373
1373
|
}
|
|
@@ -1375,7 +1375,7 @@ function parseInterpolation(context, mode) {
|
|
|
1375
1375
|
const [open, close] = context.options.delimiters;
|
|
1376
1376
|
const closeIndex = context.source.indexOf(close, open.length);
|
|
1377
1377
|
if (closeIndex === -1) {
|
|
1378
|
-
emitError(context, 25);
|
|
1378
|
+
emitError(context, "25");
|
|
1379
1379
|
return void 0;
|
|
1380
1380
|
}
|
|
1381
1381
|
const start = getCursor(context);
|
|
@@ -1394,9 +1394,9 @@ function parseInterpolation(context, mode) {
|
|
|
1394
1394
|
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1395
1395
|
advanceBy(context, close.length);
|
|
1396
1396
|
return {
|
|
1397
|
-
type: 5,
|
|
1397
|
+
type: "5",
|
|
1398
1398
|
content: {
|
|
1399
|
-
type: 4,
|
|
1399
|
+
type: "4",
|
|
1400
1400
|
isStatic: false,
|
|
1401
1401
|
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1402
1402
|
constType: 0,
|
|
@@ -1407,7 +1407,7 @@ function parseInterpolation(context, mode) {
|
|
|
1407
1407
|
};
|
|
1408
1408
|
}
|
|
1409
1409
|
function parseText(context, mode) {
|
|
1410
|
-
const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
|
|
1410
|
+
const endTokens = mode === "3" ? ["]]>"] : ["<", context.options.delimiters[0]];
|
|
1411
1411
|
let endIndex = context.source.length;
|
|
1412
1412
|
for (let i = 0; i < endTokens.length; i++) {
|
|
1413
1413
|
const index = context.source.indexOf(endTokens[i], 1);
|
|
@@ -1418,7 +1418,7 @@ function parseText(context, mode) {
|
|
|
1418
1418
|
const start = getCursor(context);
|
|
1419
1419
|
const content = parseTextData(context, endIndex, mode);
|
|
1420
1420
|
return {
|
|
1421
|
-
type: "
|
|
1421
|
+
type: "2",
|
|
1422
1422
|
content,
|
|
1423
1423
|
loc: getSelection(context, start)
|
|
1424
1424
|
};
|
|
@@ -1426,12 +1426,12 @@ function parseText(context, mode) {
|
|
|
1426
1426
|
function parseTextData(context, length, mode) {
|
|
1427
1427
|
const rawText = context.source.slice(0, length);
|
|
1428
1428
|
advanceBy(context, length);
|
|
1429
|
-
if (mode === 2 || mode === 3 || !rawText.includes("&")) {
|
|
1429
|
+
if (mode === "2" || mode === "3" || !rawText.includes("&")) {
|
|
1430
1430
|
return rawText;
|
|
1431
1431
|
} else {
|
|
1432
1432
|
return context.options.decodeEntities(
|
|
1433
1433
|
rawText,
|
|
1434
|
-
mode === 4
|
|
1434
|
+
mode === "4"
|
|
1435
1435
|
);
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
@@ -1487,7 +1487,7 @@ function emitError(context, code, offset, loc = getCursor(context)) {
|
|
|
1487
1487
|
function isEnd(context, mode, ancestors) {
|
|
1488
1488
|
const s = context.source;
|
|
1489
1489
|
switch (mode) {
|
|
1490
|
-
case 0:
|
|
1490
|
+
case "0":
|
|
1491
1491
|
if (startsWith(s, "</")) {
|
|
1492
1492
|
for (let i = ancestors.length - 1; i >= 0; --i) {
|
|
1493
1493
|
if (startsWithEndTagOpen(s, ancestors[i].tag)) {
|
|
@@ -1496,15 +1496,15 @@ function isEnd(context, mode, ancestors) {
|
|
|
1496
1496
|
}
|
|
1497
1497
|
}
|
|
1498
1498
|
break;
|
|
1499
|
-
case 1:
|
|
1500
|
-
case 2: {
|
|
1499
|
+
case "1":
|
|
1500
|
+
case "2": {
|
|
1501
1501
|
const parent = last(ancestors);
|
|
1502
1502
|
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1503
1503
|
return true;
|
|
1504
1504
|
}
|
|
1505
1505
|
break;
|
|
1506
1506
|
}
|
|
1507
|
-
case 3:
|
|
1507
|
+
case "3":
|
|
1508
1508
|
if (startsWith(s, "]]>")) {
|
|
1509
1509
|
return true;
|
|
1510
1510
|
}
|
|
@@ -1527,7 +1527,7 @@ function hoistStatic(root, context) {
|
|
|
1527
1527
|
}
|
|
1528
1528
|
function isSingleElementRoot(root, child) {
|
|
1529
1529
|
const { children } = root;
|
|
1530
|
-
return children.length === 1 && child.type === "
|
|
1530
|
+
return children.length === 1 && child.type === "1" && !isSlotOutlet(child);
|
|
1531
1531
|
}
|
|
1532
1532
|
function walk(node, context, doNotHoistNode = false) {
|
|
1533
1533
|
const { children } = node;
|
|
@@ -1535,10 +1535,10 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1535
1535
|
let hoistedCount = 0;
|
|
1536
1536
|
for (let i = 0; i < children.length; i++) {
|
|
1537
1537
|
const child = children[i];
|
|
1538
|
-
if (child.type === "
|
|
1538
|
+
if (child.type === "1" && child.tagType === "0") {
|
|
1539
1539
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
1540
1540
|
if (constantType > 0) {
|
|
1541
|
-
if (constantType >= 2) {
|
|
1541
|
+
if (constantType >= "2") {
|
|
1542
1542
|
child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
|
|
1543
1543
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1544
1544
|
hoistedCount++;
|
|
@@ -1546,9 +1546,9 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
} else {
|
|
1548
1548
|
const codegenNode = child.codegenNode;
|
|
1549
|
-
if (codegenNode.type === 13) {
|
|
1549
|
+
if (codegenNode.type === "13") {
|
|
1550
1550
|
const flag = getPatchFlag(codegenNode);
|
|
1551
|
-
if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
|
1551
|
+
if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= "2") {
|
|
1552
1552
|
const props = getNodeProps(child);
|
|
1553
1553
|
if (props) {
|
|
1554
1554
|
codegenNode.props = context.hoist(props);
|
|
@@ -1560,8 +1560,8 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1560
1560
|
}
|
|
1561
1561
|
}
|
|
1562
1562
|
}
|
|
1563
|
-
if (child.type === "
|
|
1564
|
-
const isComponent = child.tagType === 1;
|
|
1563
|
+
if (child.type === "1") {
|
|
1564
|
+
const isComponent = child.tagType === "1";
|
|
1565
1565
|
if (isComponent) {
|
|
1566
1566
|
context.scopes.vSlot++;
|
|
1567
1567
|
}
|
|
@@ -1569,9 +1569,9 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1569
1569
|
if (isComponent) {
|
|
1570
1570
|
context.scopes.vSlot--;
|
|
1571
1571
|
}
|
|
1572
|
-
} else if (child.type === 11) {
|
|
1572
|
+
} else if (child.type === "11") {
|
|
1573
1573
|
walk(child, context, child.children.length === 1);
|
|
1574
|
-
} else if (child.type === 9) {
|
|
1574
|
+
} else if (child.type === "9") {
|
|
1575
1575
|
for (let i2 = 0; i2 < child.branches.length; i2++) {
|
|
1576
1576
|
walk(
|
|
1577
1577
|
child.branches[i2],
|
|
@@ -1584,7 +1584,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1584
1584
|
if (hoistedCount && context.transformHoist) {
|
|
1585
1585
|
context.transformHoist(children, context, node);
|
|
1586
1586
|
}
|
|
1587
|
-
if (hoistedCount && hoistedCount === originalCount && node.type === "
|
|
1587
|
+
if (hoistedCount && hoistedCount === originalCount && node.type === "1" && node.tagType === "0" && node.codegenNode && node.codegenNode.type === "13" && shared.isArray(node.codegenNode.children)) {
|
|
1588
1588
|
node.codegenNode.children = context.hoist(
|
|
1589
1589
|
createArrayExpression(node.codegenNode.children)
|
|
1590
1590
|
);
|
|
@@ -1593,8 +1593,8 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1593
1593
|
function getConstantType(node, context) {
|
|
1594
1594
|
const { constantCache } = context;
|
|
1595
1595
|
switch (node.type) {
|
|
1596
|
-
case "
|
|
1597
|
-
if (node.tagType !== 0) {
|
|
1596
|
+
case "1":
|
|
1597
|
+
if (node.tagType !== "0") {
|
|
1598
1598
|
return 0;
|
|
1599
1599
|
}
|
|
1600
1600
|
const cached = constantCache.get(node);
|
|
@@ -1602,7 +1602,7 @@ function getConstantType(node, context) {
|
|
|
1602
1602
|
return cached;
|
|
1603
1603
|
}
|
|
1604
1604
|
const codegenNode = node.codegenNode;
|
|
1605
|
-
if (codegenNode.type !== 13) {
|
|
1605
|
+
if (codegenNode.type !== "13") {
|
|
1606
1606
|
return 0;
|
|
1607
1607
|
}
|
|
1608
1608
|
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
|
@@ -1610,7 +1610,7 @@ function getConstantType(node, context) {
|
|
|
1610
1610
|
}
|
|
1611
1611
|
const flag = getPatchFlag(codegenNode);
|
|
1612
1612
|
if (!flag) {
|
|
1613
|
-
let returnType2 = 3;
|
|
1613
|
+
let returnType2 = "3";
|
|
1614
1614
|
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
1615
1615
|
if (generatedPropsType === 0) {
|
|
1616
1616
|
constantCache.set(node, 0);
|
|
@@ -1629,10 +1629,10 @@ function getConstantType(node, context) {
|
|
|
1629
1629
|
returnType2 = childType;
|
|
1630
1630
|
}
|
|
1631
1631
|
}
|
|
1632
|
-
if (returnType2 > 1) {
|
|
1632
|
+
if (returnType2 > "1") {
|
|
1633
1633
|
for (let i = 0; i < node.props.length; i++) {
|
|
1634
1634
|
const p = node.props[i];
|
|
1635
|
-
if (p.type === 7 && p.name === "bind" && p.exp) {
|
|
1635
|
+
if (p.type === "7" && p.name === "bind" && p.exp) {
|
|
1636
1636
|
const expType = getConstantType(p.exp, context);
|
|
1637
1637
|
if (expType === 0) {
|
|
1638
1638
|
constantCache.set(node, 0);
|
|
@@ -1647,7 +1647,7 @@ function getConstantType(node, context) {
|
|
|
1647
1647
|
if (codegenNode.isBlock) {
|
|
1648
1648
|
for (let i = 0; i < node.props.length; i++) {
|
|
1649
1649
|
const p = node.props[i];
|
|
1650
|
-
if (p.type === 7) {
|
|
1650
|
+
if (p.type === "7") {
|
|
1651
1651
|
constantCache.set(node, 0);
|
|
1652
1652
|
return 0;
|
|
1653
1653
|
}
|
|
@@ -1665,20 +1665,20 @@ function getConstantType(node, context) {
|
|
|
1665
1665
|
constantCache.set(node, 0);
|
|
1666
1666
|
return 0;
|
|
1667
1667
|
}
|
|
1668
|
-
case "
|
|
1669
|
-
case "
|
|
1670
|
-
return 3;
|
|
1671
|
-
case 9:
|
|
1672
|
-
case 11:
|
|
1673
|
-
case 10:
|
|
1668
|
+
case "2":
|
|
1669
|
+
case "3":
|
|
1670
|
+
return "3";
|
|
1671
|
+
case "9":
|
|
1672
|
+
case "11":
|
|
1673
|
+
case "10":
|
|
1674
1674
|
return 0;
|
|
1675
|
-
case 5:
|
|
1676
|
-
case 12:
|
|
1675
|
+
case "5":
|
|
1676
|
+
case "12":
|
|
1677
1677
|
return getConstantType(node.content, context);
|
|
1678
|
-
case 4:
|
|
1678
|
+
case "4":
|
|
1679
1679
|
return node.constType;
|
|
1680
|
-
case 8:
|
|
1681
|
-
let returnType = 3;
|
|
1680
|
+
case "8":
|
|
1681
|
+
let returnType = "3";
|
|
1682
1682
|
for (let i = 0; i < node.children.length; i++) {
|
|
1683
1683
|
const child = node.children[i];
|
|
1684
1684
|
if (shared.isString(child) || shared.isSymbol(child)) {
|
|
@@ -1703,20 +1703,20 @@ const allowHoistedHelperSet = /* @__PURE__ */ new Set([
|
|
|
1703
1703
|
GUARD_REACTIVE_PROPS
|
|
1704
1704
|
]);
|
|
1705
1705
|
function getConstantTypeOfHelperCall(value, context) {
|
|
1706
|
-
if (value.type === 14 && !shared.isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
|
1706
|
+
if (value.type === "14" && !shared.isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
|
1707
1707
|
const arg = value.arguments[0];
|
|
1708
|
-
if (arg.type === 4) {
|
|
1708
|
+
if (arg.type === "4") {
|
|
1709
1709
|
return getConstantType(arg, context);
|
|
1710
|
-
} else if (arg.type === 14) {
|
|
1710
|
+
} else if (arg.type === "14") {
|
|
1711
1711
|
return getConstantTypeOfHelperCall(arg, context);
|
|
1712
1712
|
}
|
|
1713
1713
|
}
|
|
1714
1714
|
return 0;
|
|
1715
1715
|
}
|
|
1716
1716
|
function getGeneratedPropsConstantType(node, context) {
|
|
1717
|
-
let returnType = 3;
|
|
1717
|
+
let returnType = "3";
|
|
1718
1718
|
const props = getNodeProps(node);
|
|
1719
|
-
if (props && props.type === 15) {
|
|
1719
|
+
if (props && props.type === "15") {
|
|
1720
1720
|
const { properties } = props;
|
|
1721
1721
|
for (let i = 0; i < properties.length; i++) {
|
|
1722
1722
|
const { key, value } = properties[i];
|
|
@@ -1728,9 +1728,9 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
1728
1728
|
returnType = keyType;
|
|
1729
1729
|
}
|
|
1730
1730
|
let valueType;
|
|
1731
|
-
if (value.type === 4) {
|
|
1731
|
+
if (value.type === "4") {
|
|
1732
1732
|
valueType = getConstantType(value, context);
|
|
1733
|
-
} else if (value.type === 14) {
|
|
1733
|
+
} else if (value.type === "14") {
|
|
1734
1734
|
valueType = getConstantTypeOfHelperCall(value, context);
|
|
1735
1735
|
} else {
|
|
1736
1736
|
valueType = 0;
|
|
@@ -1747,7 +1747,7 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
1747
1747
|
}
|
|
1748
1748
|
function getNodeProps(node) {
|
|
1749
1749
|
const codegenNode = node.codegenNode;
|
|
1750
|
-
if (codegenNode.type === 13) {
|
|
1750
|
+
if (codegenNode.type === "13") {
|
|
1751
1751
|
return codegenNode.props;
|
|
1752
1752
|
}
|
|
1753
1753
|
}
|
|
@@ -1883,7 +1883,7 @@ function createTransformContext(root, {
|
|
|
1883
1883
|
addId(exp);
|
|
1884
1884
|
} else if (exp.identifiers) {
|
|
1885
1885
|
exp.identifiers.forEach(addId);
|
|
1886
|
-
} else if (exp.type === 4) {
|
|
1886
|
+
} else if (exp.type === "4") {
|
|
1887
1887
|
addId(exp.content);
|
|
1888
1888
|
}
|
|
1889
1889
|
}
|
|
@@ -1894,7 +1894,7 @@ function createTransformContext(root, {
|
|
|
1894
1894
|
removeId(exp);
|
|
1895
1895
|
} else if (exp.identifiers) {
|
|
1896
1896
|
exp.identifiers.forEach(removeId);
|
|
1897
|
-
} else if (exp.type === 4) {
|
|
1897
|
+
} else if (exp.type === "4") {
|
|
1898
1898
|
removeId(exp.content);
|
|
1899
1899
|
}
|
|
1900
1900
|
}
|
|
@@ -1907,7 +1907,7 @@ function createTransformContext(root, {
|
|
|
1907
1907
|
`_hoisted_${context.hoists.length}`,
|
|
1908
1908
|
false,
|
|
1909
1909
|
exp.loc,
|
|
1910
|
-
2
|
|
1910
|
+
"2"
|
|
1911
1911
|
);
|
|
1912
1912
|
identifier.hoisted = exp;
|
|
1913
1913
|
return identifier;
|
|
@@ -1958,7 +1958,7 @@ function createRootCodegen(root, context) {
|
|
|
1958
1958
|
const child = children[0];
|
|
1959
1959
|
if (isSingleElementRoot(root, child) && child.codegenNode) {
|
|
1960
1960
|
const codegenNode = child.codegenNode;
|
|
1961
|
-
if (codegenNode.type === 13) {
|
|
1961
|
+
if (codegenNode.type === "13") {
|
|
1962
1962
|
makeBlock(codegenNode, context);
|
|
1963
1963
|
}
|
|
1964
1964
|
root.codegenNode = codegenNode;
|
|
@@ -1968,7 +1968,7 @@ function createRootCodegen(root, context) {
|
|
|
1968
1968
|
} else if (children.length > 1) {
|
|
1969
1969
|
let patchFlag = 64;
|
|
1970
1970
|
let patchFlagText = shared.PatchFlagNames[64];
|
|
1971
|
-
if (children.filter((c) => c.type !== "
|
|
1971
|
+
if (children.filter((c) => c.type !== "3").length === 1) {
|
|
1972
1972
|
patchFlag |= 2048;
|
|
1973
1973
|
patchFlagText += `, ${shared.PatchFlagNames[2048]}`;
|
|
1974
1974
|
}
|
|
@@ -2022,25 +2022,25 @@ function traverseNode(node, context) {
|
|
|
2022
2022
|
}
|
|
2023
2023
|
}
|
|
2024
2024
|
switch (node.type) {
|
|
2025
|
-
case "
|
|
2025
|
+
case "3":
|
|
2026
2026
|
if (!context.ssr) {
|
|
2027
2027
|
context.helper(CREATE_COMMENT);
|
|
2028
2028
|
}
|
|
2029
2029
|
break;
|
|
2030
|
-
case 5:
|
|
2030
|
+
case "5":
|
|
2031
2031
|
if (!context.ssr) {
|
|
2032
2032
|
context.helper(TO_DISPLAY_STRING);
|
|
2033
2033
|
}
|
|
2034
2034
|
break;
|
|
2035
|
-
case 9:
|
|
2035
|
+
case "9":
|
|
2036
2036
|
for (let i2 = 0; i2 < node.branches.length; i2++) {
|
|
2037
2037
|
traverseNode(node.branches[i2], context);
|
|
2038
2038
|
}
|
|
2039
2039
|
break;
|
|
2040
|
-
case 10:
|
|
2041
|
-
case 11:
|
|
2042
|
-
case "
|
|
2043
|
-
case 0:
|
|
2040
|
+
case "10":
|
|
2041
|
+
case "11":
|
|
2042
|
+
case "1":
|
|
2043
|
+
case "0":
|
|
2044
2044
|
traverseChildren(node, context);
|
|
2045
2045
|
break;
|
|
2046
2046
|
}
|
|
@@ -2053,15 +2053,15 @@ function traverseNode(node, context) {
|
|
|
2053
2053
|
function createStructuralDirectiveTransform(name, fn) {
|
|
2054
2054
|
const matches = shared.isString(name) ? (n) => n === name : (n) => name.test(n);
|
|
2055
2055
|
return (node, context) => {
|
|
2056
|
-
if (node.type === "
|
|
2056
|
+
if (node.type === "1") {
|
|
2057
2057
|
const { props } = node;
|
|
2058
|
-
if (node.tagType === 3 && props.some(isVSlot)) {
|
|
2058
|
+
if (node.tagType === "3" && props.some(isVSlot)) {
|
|
2059
2059
|
return;
|
|
2060
2060
|
}
|
|
2061
2061
|
const exitFns = [];
|
|
2062
2062
|
for (let i = 0; i < props.length; i++) {
|
|
2063
2063
|
const prop = props[i];
|
|
2064
|
-
if (prop.type === 7 && matches(prop.name)) {
|
|
2064
|
+
if (prop.type === "7" && matches(prop.name)) {
|
|
2065
2065
|
props.splice(i, 1);
|
|
2066
2066
|
i--;
|
|
2067
2067
|
const onExit = fn(node, prop, context);
|
|
@@ -2119,7 +2119,7 @@ function createCodegenContext(ast, {
|
|
|
2119
2119
|
if (context.map) {
|
|
2120
2120
|
if (node) {
|
|
2121
2121
|
let name;
|
|
2122
|
-
if (node.type === 4 && !node.isStatic) {
|
|
2122
|
+
if (node.type === "4" && !node.isStatic) {
|
|
2123
2123
|
const content = node.content.replace(/^_ctx\./, "");
|
|
2124
2124
|
if (content !== node.content && isSimpleIdentifier(content)) {
|
|
2125
2125
|
name = content;
|
|
@@ -2395,7 +2395,7 @@ function genHoists(hoists, context) {
|
|
|
2395
2395
|
for (let i = 0; i < hoists.length; i++) {
|
|
2396
2396
|
const exp = hoists[i];
|
|
2397
2397
|
if (exp) {
|
|
2398
|
-
const needScopeIdWrapper = genScopeId && exp.type === 13;
|
|
2398
|
+
const needScopeIdWrapper = genScopeId && exp.type === "13";
|
|
2399
2399
|
push(
|
|
2400
2400
|
`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
|
|
2401
2401
|
);
|
|
@@ -2420,7 +2420,7 @@ function genImports(importsOptions, context) {
|
|
|
2420
2420
|
});
|
|
2421
2421
|
}
|
|
2422
2422
|
function isText(n) {
|
|
2423
|
-
return shared.isString(n) || n.type === 4 || n.type === "
|
|
2423
|
+
return shared.isString(n) || n.type === "4" || n.type === "2" || n.type === "5" || n.type === "8";
|
|
2424
2424
|
}
|
|
2425
2425
|
function genNodeListAsArray(nodes, context) {
|
|
2426
2426
|
const multilines = nodes.length > 3 || nodes.some((n) => shared.isArray(n) || !isText(n));
|
|
@@ -2461,73 +2461,73 @@ function genNode(node, context) {
|
|
|
2461
2461
|
return;
|
|
2462
2462
|
}
|
|
2463
2463
|
switch (node.type) {
|
|
2464
|
-
case "
|
|
2465
|
-
case 9:
|
|
2466
|
-
case 11:
|
|
2464
|
+
case "1":
|
|
2465
|
+
case "9":
|
|
2466
|
+
case "11":
|
|
2467
2467
|
assert(
|
|
2468
2468
|
node.codegenNode != null,
|
|
2469
2469
|
`Codegen node is missing for element/if/for node. Apply appropriate transforms first.`
|
|
2470
2470
|
);
|
|
2471
2471
|
genNode(node.codegenNode, context);
|
|
2472
2472
|
break;
|
|
2473
|
-
case "
|
|
2473
|
+
case "2":
|
|
2474
2474
|
genText(node, context);
|
|
2475
2475
|
break;
|
|
2476
|
-
case 4:
|
|
2476
|
+
case "4":
|
|
2477
2477
|
genExpression(node, context);
|
|
2478
2478
|
break;
|
|
2479
|
-
case 5:
|
|
2479
|
+
case "5":
|
|
2480
2480
|
genInterpolation(node, context);
|
|
2481
2481
|
break;
|
|
2482
|
-
case 12:
|
|
2482
|
+
case "12":
|
|
2483
2483
|
genNode(node.codegenNode, context);
|
|
2484
2484
|
break;
|
|
2485
|
-
case 8:
|
|
2485
|
+
case "8":
|
|
2486
2486
|
genCompoundExpression(node, context);
|
|
2487
2487
|
break;
|
|
2488
|
-
case "
|
|
2488
|
+
case "3":
|
|
2489
2489
|
genComment(node, context);
|
|
2490
2490
|
break;
|
|
2491
|
-
case 13:
|
|
2491
|
+
case "13":
|
|
2492
2492
|
genVNodeCall(node, context);
|
|
2493
2493
|
break;
|
|
2494
|
-
case 14:
|
|
2494
|
+
case "14":
|
|
2495
2495
|
genCallExpression(node, context);
|
|
2496
2496
|
break;
|
|
2497
|
-
case 15:
|
|
2497
|
+
case "15":
|
|
2498
2498
|
genObjectExpression(node, context);
|
|
2499
2499
|
break;
|
|
2500
|
-
case 17:
|
|
2500
|
+
case "17":
|
|
2501
2501
|
genArrayExpression(node, context);
|
|
2502
2502
|
break;
|
|
2503
|
-
case 18:
|
|
2503
|
+
case "18":
|
|
2504
2504
|
genFunctionExpression(node, context);
|
|
2505
2505
|
break;
|
|
2506
|
-
case 19:
|
|
2506
|
+
case "19":
|
|
2507
2507
|
genConditionalExpression(node, context);
|
|
2508
2508
|
break;
|
|
2509
|
-
case 20:
|
|
2509
|
+
case "20":
|
|
2510
2510
|
genCacheExpression(node, context);
|
|
2511
2511
|
break;
|
|
2512
|
-
case 21:
|
|
2512
|
+
case "21":
|
|
2513
2513
|
genNodeList(node.body, context, true, false);
|
|
2514
2514
|
break;
|
|
2515
|
-
case 22:
|
|
2515
|
+
case "22":
|
|
2516
2516
|
genTemplateLiteral(node, context);
|
|
2517
2517
|
break;
|
|
2518
|
-
case 23:
|
|
2518
|
+
case "23":
|
|
2519
2519
|
genIfStatement(node, context);
|
|
2520
2520
|
break;
|
|
2521
|
-
case 24:
|
|
2521
|
+
case "24":
|
|
2522
2522
|
genAssignmentExpression(node, context);
|
|
2523
2523
|
break;
|
|
2524
|
-
case 25:
|
|
2524
|
+
case "25":
|
|
2525
2525
|
genSequenceExpression(node, context);
|
|
2526
2526
|
break;
|
|
2527
|
-
case 26:
|
|
2527
|
+
case "26":
|
|
2528
2528
|
genReturnStatement(node, context);
|
|
2529
2529
|
break;
|
|
2530
|
-
case 10:
|
|
2530
|
+
case "10":
|
|
2531
2531
|
break;
|
|
2532
2532
|
default:
|
|
2533
2533
|
{
|
|
@@ -2564,7 +2564,7 @@ function genCompoundExpression(node, context) {
|
|
|
2564
2564
|
}
|
|
2565
2565
|
function genExpressionAsPropertyKey(node, context) {
|
|
2566
2566
|
const { push } = context;
|
|
2567
|
-
if (node.type === 8) {
|
|
2567
|
+
if (node.type === "8") {
|
|
2568
2568
|
push(`[`);
|
|
2569
2569
|
genCompoundExpression(node, context);
|
|
2570
2570
|
push(`]`);
|
|
@@ -2645,7 +2645,7 @@ function genObjectExpression(node, context) {
|
|
|
2645
2645
|
push(`{}`, node);
|
|
2646
2646
|
return;
|
|
2647
2647
|
}
|
|
2648
|
-
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
2648
|
+
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== "4");
|
|
2649
2649
|
push(multilines ? `{` : `{ `);
|
|
2650
2650
|
multilines && indent();
|
|
2651
2651
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2707,7 +2707,7 @@ function genFunctionExpression(node, context) {
|
|
|
2707
2707
|
function genConditionalExpression(node, context) {
|
|
2708
2708
|
const { test, consequent, alternate, newline: needNewline } = node;
|
|
2709
2709
|
const { push, indent, deindent, newline } = context;
|
|
2710
|
-
if (test.type === 4) {
|
|
2710
|
+
if (test.type === "4") {
|
|
2711
2711
|
const needsParens = !isSimpleIdentifier(test.content);
|
|
2712
2712
|
needsParens && push(`(`);
|
|
2713
2713
|
genExpression(test, context);
|
|
@@ -2726,7 +2726,7 @@ function genConditionalExpression(node, context) {
|
|
|
2726
2726
|
needNewline && newline();
|
|
2727
2727
|
needNewline || push(` `);
|
|
2728
2728
|
push(`: `);
|
|
2729
|
-
const isNested = alternate.type === 19;
|
|
2729
|
+
const isNested = alternate.type === "19";
|
|
2730
2730
|
if (!isNested) {
|
|
2731
2731
|
context.indentLevel++;
|
|
2732
2732
|
}
|
|
@@ -2792,7 +2792,7 @@ function genIfStatement(node, context) {
|
|
|
2792
2792
|
push(`}`);
|
|
2793
2793
|
if (alternate) {
|
|
2794
2794
|
push(` else `);
|
|
2795
|
-
if (alternate.type === 23) {
|
|
2795
|
+
if (alternate.type === "23") {
|
|
2796
2796
|
genIfStatement(alternate, context);
|
|
2797
2797
|
} else {
|
|
2798
2798
|
push(`{`);
|
|
@@ -3061,18 +3061,18 @@ function isReferenced(node, parent, grandparent) {
|
|
|
3061
3061
|
|
|
3062
3062
|
const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
|
|
3063
3063
|
const transformExpression = (node, context) => {
|
|
3064
|
-
if (node.type === 5) {
|
|
3064
|
+
if (node.type === "5") {
|
|
3065
3065
|
node.content = processExpression(
|
|
3066
3066
|
node.content,
|
|
3067
3067
|
context
|
|
3068
3068
|
);
|
|
3069
|
-
} else if (node.type === "
|
|
3069
|
+
} else if (node.type === "1") {
|
|
3070
3070
|
for (let i = 0; i < node.props.length; i++) {
|
|
3071
3071
|
const dir = node.props[i];
|
|
3072
|
-
if (dir.type === 7 && dir.name !== "for") {
|
|
3072
|
+
if (dir.type === "7" && dir.name !== "for") {
|
|
3073
3073
|
const exp = dir.exp;
|
|
3074
3074
|
const arg = dir.arg;
|
|
3075
|
-
if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
|
|
3075
|
+
if (exp && exp.type === "4" && !(dir.name === "on" && arg)) {
|
|
3076
3076
|
dir.exp = processExpression(
|
|
3077
3077
|
exp,
|
|
3078
3078
|
context,
|
|
@@ -3080,7 +3080,7 @@ const transformExpression = (node, context) => {
|
|
|
3080
3080
|
dir.name === "slot"
|
|
3081
3081
|
);
|
|
3082
3082
|
}
|
|
3083
|
-
if (arg && arg.type === 4 && !arg.isStatic) {
|
|
3083
|
+
if (arg && arg.type === "4" && !arg.isStatic) {
|
|
3084
3084
|
dir.arg = processExpression(arg, context);
|
|
3085
3085
|
}
|
|
3086
3086
|
}
|
|
@@ -3156,14 +3156,14 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3156
3156
|
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
3157
3157
|
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
|
|
3158
3158
|
if (bindingMetadata[node.content] === "setup-const") {
|
|
3159
|
-
node.constType = 1;
|
|
3159
|
+
node.constType = "1";
|
|
3160
3160
|
}
|
|
3161
3161
|
node.content = rewriteIdentifier(rawExp);
|
|
3162
3162
|
} else if (!isScopeVarReference) {
|
|
3163
3163
|
if (isLiteral) {
|
|
3164
|
-
node.constType = 3;
|
|
3164
|
+
node.constType = "3";
|
|
3165
3165
|
} else {
|
|
3166
|
-
node.constType = 2;
|
|
3166
|
+
node.constType = "2";
|
|
3167
3167
|
}
|
|
3168
3168
|
}
|
|
3169
3169
|
return node;
|
|
@@ -3177,7 +3177,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3177
3177
|
} catch (e) {
|
|
3178
3178
|
context.onError(
|
|
3179
3179
|
createCompilerError(
|
|
3180
|
-
45,
|
|
3180
|
+
"45",
|
|
3181
3181
|
node.loc,
|
|
3182
3182
|
void 0,
|
|
3183
3183
|
e.message
|
|
@@ -3236,7 +3236,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3236
3236
|
start: advancePositionWithClone(node.loc.start, source2, start),
|
|
3237
3237
|
end: advancePositionWithClone(node.loc.start, source2, end)
|
|
3238
3238
|
},
|
|
3239
|
-
id.isConstant ? 3 : 0
|
|
3239
|
+
id.isConstant ? "3" : 0
|
|
3240
3240
|
)
|
|
3241
3241
|
);
|
|
3242
3242
|
if (i === ids.length - 1 && end < rawExp.length) {
|
|
@@ -3248,7 +3248,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3248
3248
|
ret = createCompoundExpression(children, node.loc);
|
|
3249
3249
|
} else {
|
|
3250
3250
|
ret = node;
|
|
3251
|
-
ret.constType = bailConstant ? 0 : 3;
|
|
3251
|
+
ret.constType = bailConstant ? 0 : "3";
|
|
3252
3252
|
}
|
|
3253
3253
|
ret.identifiers = Object.keys(knownIds);
|
|
3254
3254
|
return ret;
|
|
@@ -3265,7 +3265,7 @@ function canPrefix(id) {
|
|
|
3265
3265
|
function stringifyExpression(exp) {
|
|
3266
3266
|
if (shared.isString(exp)) {
|
|
3267
3267
|
return exp;
|
|
3268
|
-
} else if (exp.type === 4) {
|
|
3268
|
+
} else if (exp.type === "4") {
|
|
3269
3269
|
return exp.content;
|
|
3270
3270
|
} else {
|
|
3271
3271
|
return exp.children.map(stringifyExpression).join("");
|
|
@@ -3281,7 +3281,7 @@ const transformIf = createStructuralDirectiveTransform(
|
|
|
3281
3281
|
let key = 0;
|
|
3282
3282
|
while (i-- >= 0) {
|
|
3283
3283
|
const sibling = siblings[i];
|
|
3284
|
-
if (sibling && sibling.type === 9) {
|
|
3284
|
+
if (sibling && sibling.type === "9") {
|
|
3285
3285
|
key += sibling.branches.length;
|
|
3286
3286
|
}
|
|
3287
3287
|
}
|
|
@@ -3308,7 +3308,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3308
3308
|
if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
|
3309
3309
|
const loc = dir.exp ? dir.exp.loc : node.loc;
|
|
3310
3310
|
context.onError(
|
|
3311
|
-
createCompilerError(28, dir.loc)
|
|
3311
|
+
createCompilerError("28", dir.loc)
|
|
3312
3312
|
);
|
|
3313
3313
|
dir.exp = createSimpleExpression(`true`, false, loc);
|
|
3314
3314
|
}
|
|
@@ -3318,7 +3318,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3318
3318
|
if (dir.name === "if") {
|
|
3319
3319
|
const branch = createIfBranch(node, dir);
|
|
3320
3320
|
const ifNode = {
|
|
3321
|
-
type: 9,
|
|
3321
|
+
type: "9",
|
|
3322
3322
|
loc: node.loc,
|
|
3323
3323
|
branches: [branch]
|
|
3324
3324
|
};
|
|
@@ -3332,25 +3332,25 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3332
3332
|
let i = siblings.indexOf(node);
|
|
3333
3333
|
while (i-- >= -1) {
|
|
3334
3334
|
const sibling = siblings[i];
|
|
3335
|
-
if (sibling && sibling.type === "
|
|
3335
|
+
if (sibling && sibling.type === "3") {
|
|
3336
3336
|
context.removeNode(sibling);
|
|
3337
3337
|
comments.unshift(sibling);
|
|
3338
3338
|
continue;
|
|
3339
3339
|
}
|
|
3340
|
-
if (sibling && sibling.type === "
|
|
3340
|
+
if (sibling && sibling.type === "2" && !sibling.content.trim().length) {
|
|
3341
3341
|
context.removeNode(sibling);
|
|
3342
3342
|
continue;
|
|
3343
3343
|
}
|
|
3344
|
-
if (sibling && sibling.type === 9) {
|
|
3344
|
+
if (sibling && sibling.type === "9") {
|
|
3345
3345
|
if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
3346
3346
|
context.onError(
|
|
3347
|
-
createCompilerError(30, node.loc)
|
|
3347
|
+
createCompilerError("30", node.loc)
|
|
3348
3348
|
);
|
|
3349
3349
|
}
|
|
3350
3350
|
context.removeNode();
|
|
3351
3351
|
const branch = createIfBranch(node, dir);
|
|
3352
3352
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
3353
|
-
!(context.parent && context.parent.type === "
|
|
3353
|
+
!(context.parent && context.parent.type === "1" && isBuiltInType(context.parent.tag, "transition"))) {
|
|
3354
3354
|
branch.children = [...comments, ...branch.children];
|
|
3355
3355
|
}
|
|
3356
3356
|
{
|
|
@@ -3360,7 +3360,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3360
3360
|
if (isSameKey(userKey, key)) {
|
|
3361
3361
|
context.onError(
|
|
3362
3362
|
createCompilerError(
|
|
3363
|
-
29,
|
|
3363
|
+
"29",
|
|
3364
3364
|
branch.userKey.loc
|
|
3365
3365
|
)
|
|
3366
3366
|
);
|
|
@@ -3376,7 +3376,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3376
3376
|
context.currentNode = null;
|
|
3377
3377
|
} else {
|
|
3378
3378
|
context.onError(
|
|
3379
|
-
createCompilerError(30, node.loc)
|
|
3379
|
+
createCompilerError("30", node.loc)
|
|
3380
3380
|
);
|
|
3381
3381
|
}
|
|
3382
3382
|
break;
|
|
@@ -3384,9 +3384,9 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3384
3384
|
}
|
|
3385
3385
|
}
|
|
3386
3386
|
function createIfBranch(node, dir) {
|
|
3387
|
-
const isTemplateIf = node.tagType === 3;
|
|
3387
|
+
const isTemplateIf = node.tagType === "3";
|
|
3388
3388
|
return {
|
|
3389
|
-
type: 10,
|
|
3389
|
+
type: "10",
|
|
3390
3390
|
loc: node.loc,
|
|
3391
3391
|
condition: dir.name === "else" ? void 0 : dir.exp,
|
|
3392
3392
|
children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
|
@@ -3418,21 +3418,21 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3418
3418
|
`${keyIndex}`,
|
|
3419
3419
|
false,
|
|
3420
3420
|
locStub,
|
|
3421
|
-
2
|
|
3421
|
+
"2"
|
|
3422
3422
|
)
|
|
3423
3423
|
);
|
|
3424
3424
|
const { children } = branch;
|
|
3425
3425
|
const firstChild = children[0];
|
|
3426
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !== "
|
|
3426
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== "1";
|
|
3427
3427
|
if (needFragmentWrapper) {
|
|
3428
|
-
if (children.length === 1 && firstChild.type === 11) {
|
|
3428
|
+
if (children.length === 1 && firstChild.type === "11") {
|
|
3429
3429
|
const vnodeCall = firstChild.codegenNode;
|
|
3430
3430
|
injectProp(vnodeCall, keyProperty, context);
|
|
3431
3431
|
return vnodeCall;
|
|
3432
3432
|
} else {
|
|
3433
3433
|
let patchFlag = 64;
|
|
3434
3434
|
let patchFlagText = shared.PatchFlagNames[64];
|
|
3435
|
-
if (!branch.isTemplateIf && children.filter((c) => c.type !== "
|
|
3435
|
+
if (!branch.isTemplateIf && children.filter((c) => c.type !== "3").length === 1) {
|
|
3436
3436
|
patchFlag |= 2048;
|
|
3437
3437
|
patchFlagText += `, ${shared.PatchFlagNames[2048]}`;
|
|
3438
3438
|
}
|
|
@@ -3453,7 +3453,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3453
3453
|
} else {
|
|
3454
3454
|
const ret = firstChild.codegenNode;
|
|
3455
3455
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3456
|
-
if (vnodeCall.type === 13) {
|
|
3456
|
+
if (vnodeCall.type === "13") {
|
|
3457
3457
|
makeBlock(vnodeCall, context);
|
|
3458
3458
|
}
|
|
3459
3459
|
injectProp(vnodeCall, keyProperty, context);
|
|
@@ -3464,7 +3464,7 @@ function isSameKey(a, b) {
|
|
|
3464
3464
|
if (!a || a.type !== b.type) {
|
|
3465
3465
|
return false;
|
|
3466
3466
|
}
|
|
3467
|
-
if (a.type === 6) {
|
|
3467
|
+
if (a.type === "6") {
|
|
3468
3468
|
if (a.value.content !== b.value.content) {
|
|
3469
3469
|
return false;
|
|
3470
3470
|
}
|
|
@@ -3474,7 +3474,7 @@ function isSameKey(a, b) {
|
|
|
3474
3474
|
if (exp.type !== branchExp.type) {
|
|
3475
3475
|
return false;
|
|
3476
3476
|
}
|
|
3477
|
-
if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
|
3477
|
+
if (exp.type !== "4" || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
|
3478
3478
|
return false;
|
|
3479
3479
|
}
|
|
3480
3480
|
}
|
|
@@ -3482,13 +3482,13 @@ function isSameKey(a, b) {
|
|
|
3482
3482
|
}
|
|
3483
3483
|
function getParentCondition(node) {
|
|
3484
3484
|
while (true) {
|
|
3485
|
-
if (node.type === 19) {
|
|
3486
|
-
if (node.alternate.type === 19) {
|
|
3485
|
+
if (node.type === "19") {
|
|
3486
|
+
if (node.alternate.type === "19") {
|
|
3487
3487
|
node = node.alternate;
|
|
3488
3488
|
} else {
|
|
3489
3489
|
return node;
|
|
3490
3490
|
}
|
|
3491
|
-
} else if (node.type === 20) {
|
|
3491
|
+
} else if (node.type === "20") {
|
|
3492
3492
|
node = node.value;
|
|
3493
3493
|
}
|
|
3494
3494
|
}
|
|
@@ -3505,7 +3505,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3505
3505
|
const isTemplate = isTemplateNode(node);
|
|
3506
3506
|
const memo = findDir(node, "memo");
|
|
3507
3507
|
const keyProp = findProp(node, `key`);
|
|
3508
|
-
const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
|
3508
|
+
const keyExp = keyProp && (keyProp.type === "6" ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
|
3509
3509
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3510
3510
|
if (isTemplate) {
|
|
3511
3511
|
if (memo) {
|
|
@@ -3514,14 +3514,14 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3514
3514
|
context
|
|
3515
3515
|
);
|
|
3516
3516
|
}
|
|
3517
|
-
if (keyProperty && keyProp.type !== 6) {
|
|
3517
|
+
if (keyProperty && keyProp.type !== "6") {
|
|
3518
3518
|
keyProperty.value = processExpression(
|
|
3519
3519
|
keyProperty.value,
|
|
3520
3520
|
context
|
|
3521
3521
|
);
|
|
3522
3522
|
}
|
|
3523
3523
|
}
|
|
3524
|
-
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
3524
|
+
const isStableFragment = forNode.source.type === "4" && forNode.source.constType > 0;
|
|
3525
3525
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
3526
3526
|
forNode.codegenNode = createVNodeCall(
|
|
3527
3527
|
context,
|
|
@@ -3541,12 +3541,12 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3541
3541
|
const { children } = forNode;
|
|
3542
3542
|
if (isTemplate) {
|
|
3543
3543
|
node.children.some((c) => {
|
|
3544
|
-
if (c.type === "
|
|
3544
|
+
if (c.type === "1") {
|
|
3545
3545
|
const key = findProp(c, "key");
|
|
3546
3546
|
if (key) {
|
|
3547
3547
|
context.onError(
|
|
3548
3548
|
createCompilerError(
|
|
3549
|
-
33,
|
|
3549
|
+
"33",
|
|
3550
3550
|
key.loc
|
|
3551
3551
|
)
|
|
3552
3552
|
);
|
|
@@ -3555,7 +3555,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3555
3555
|
}
|
|
3556
3556
|
});
|
|
3557
3557
|
}
|
|
3558
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !== "
|
|
3558
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== "1";
|
|
3559
3559
|
const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
|
3560
3560
|
if (slotOutlet) {
|
|
3561
3561
|
childBlock = slotOutlet.codegenNode;
|
|
@@ -3642,7 +3642,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3642
3642
|
function processFor(node, dir, context, processCodegen) {
|
|
3643
3643
|
if (!dir.exp) {
|
|
3644
3644
|
context.onError(
|
|
3645
|
-
createCompilerError(31, dir.loc)
|
|
3645
|
+
createCompilerError("31", dir.loc)
|
|
3646
3646
|
);
|
|
3647
3647
|
return;
|
|
3648
3648
|
}
|
|
@@ -3654,14 +3654,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3654
3654
|
);
|
|
3655
3655
|
if (!parseResult) {
|
|
3656
3656
|
context.onError(
|
|
3657
|
-
createCompilerError(32, dir.loc)
|
|
3657
|
+
createCompilerError("32", dir.loc)
|
|
3658
3658
|
);
|
|
3659
3659
|
return;
|
|
3660
3660
|
}
|
|
3661
3661
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3662
3662
|
const { source, value, key, index } = parseResult;
|
|
3663
3663
|
const forNode = {
|
|
3664
|
-
type: 11,
|
|
3664
|
+
type: "11",
|
|
3665
3665
|
loc: dir.loc,
|
|
3666
3666
|
source,
|
|
3667
3667
|
valueAlias: value,
|
|
@@ -3775,7 +3775,7 @@ function createParamsList(args) {
|
|
|
3775
3775
|
|
|
3776
3776
|
const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
3777
3777
|
const trackSlotScopes = (node, context) => {
|
|
3778
|
-
if (node.type === "
|
|
3778
|
+
if (node.type === "1" && (node.tagType === "1" || node.tagType === "3")) {
|
|
3779
3779
|
const vSlot = findDir(node, "slot");
|
|
3780
3780
|
if (vSlot) {
|
|
3781
3781
|
const slotProps = vSlot.exp;
|
|
@@ -3851,14 +3851,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3851
3851
|
const slotElement = children[i];
|
|
3852
3852
|
let slotDir;
|
|
3853
3853
|
if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
|
3854
|
-
if (slotElement.type !== "
|
|
3854
|
+
if (slotElement.type !== "3") {
|
|
3855
3855
|
implicitDefaultChildren.push(slotElement);
|
|
3856
3856
|
}
|
|
3857
3857
|
continue;
|
|
3858
3858
|
}
|
|
3859
3859
|
if (onComponentSlot) {
|
|
3860
3860
|
context.onError(
|
|
3861
|
-
createCompilerError(37, slotDir.loc)
|
|
3861
|
+
createCompilerError("37", slotDir.loc)
|
|
3862
3862
|
);
|
|
3863
3863
|
break;
|
|
3864
3864
|
}
|
|
@@ -3898,7 +3898,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3898
3898
|
let prev;
|
|
3899
3899
|
while (j--) {
|
|
3900
3900
|
prev = children[j];
|
|
3901
|
-
if (prev.type !== "
|
|
3901
|
+
if (prev.type !== "3") {
|
|
3902
3902
|
break;
|
|
3903
3903
|
}
|
|
3904
3904
|
}
|
|
@@ -3906,7 +3906,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3906
3906
|
children.splice(i, 1);
|
|
3907
3907
|
i--;
|
|
3908
3908
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
3909
|
-
while (conditional.alternate.type === 19) {
|
|
3909
|
+
while (conditional.alternate.type === "19") {
|
|
3910
3910
|
conditional = conditional.alternate;
|
|
3911
3911
|
}
|
|
3912
3912
|
conditional.alternate = vElse.exp ? createConditionalExpression(
|
|
@@ -3920,7 +3920,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3920
3920
|
) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
|
3921
3921
|
} else {
|
|
3922
3922
|
context.onError(
|
|
3923
|
-
createCompilerError(30, vElse.loc)
|
|
3923
|
+
createCompilerError("30", vElse.loc)
|
|
3924
3924
|
);
|
|
3925
3925
|
}
|
|
3926
3926
|
} else if (vFor = findDir(slotElement, "for")) {
|
|
@@ -3940,7 +3940,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3940
3940
|
);
|
|
3941
3941
|
} else {
|
|
3942
3942
|
context.onError(
|
|
3943
|
-
createCompilerError(32, vFor.loc)
|
|
3943
|
+
createCompilerError("32", vFor.loc)
|
|
3944
3944
|
);
|
|
3945
3945
|
}
|
|
3946
3946
|
} else {
|
|
@@ -3948,7 +3948,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3948
3948
|
if (seenSlotNames.has(staticSlotName)) {
|
|
3949
3949
|
context.onError(
|
|
3950
3950
|
createCompilerError(
|
|
3951
|
-
38,
|
|
3951
|
+
"38",
|
|
3952
3952
|
dirLoc
|
|
3953
3953
|
)
|
|
3954
3954
|
);
|
|
@@ -3979,7 +3979,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3979
3979
|
if (hasNamedDefaultSlot) {
|
|
3980
3980
|
context.onError(
|
|
3981
3981
|
createCompilerError(
|
|
3982
|
-
39,
|
|
3982
|
+
"39",
|
|
3983
3983
|
implicitDefaultChildren[0].loc
|
|
3984
3984
|
)
|
|
3985
3985
|
);
|
|
@@ -4032,17 +4032,17 @@ function hasForwardedSlots(children) {
|
|
|
4032
4032
|
for (let i = 0; i < children.length; i++) {
|
|
4033
4033
|
const child = children[i];
|
|
4034
4034
|
switch (child.type) {
|
|
4035
|
-
case "
|
|
4036
|
-
if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
|
4035
|
+
case "1":
|
|
4036
|
+
if (child.tagType === "2" || hasForwardedSlots(child.children)) {
|
|
4037
4037
|
return true;
|
|
4038
4038
|
}
|
|
4039
4039
|
break;
|
|
4040
|
-
case 9:
|
|
4040
|
+
case "9":
|
|
4041
4041
|
if (hasForwardedSlots(child.branches))
|
|
4042
4042
|
return true;
|
|
4043
4043
|
break;
|
|
4044
|
-
case 10:
|
|
4045
|
-
case 11:
|
|
4044
|
+
case "10":
|
|
4045
|
+
case "11":
|
|
4046
4046
|
if (hasForwardedSlots(child.children))
|
|
4047
4047
|
return true;
|
|
4048
4048
|
break;
|
|
@@ -4051,20 +4051,20 @@ function hasForwardedSlots(children) {
|
|
|
4051
4051
|
return false;
|
|
4052
4052
|
}
|
|
4053
4053
|
function isNonWhitespaceContent(node) {
|
|
4054
|
-
if (node.type !== "
|
|
4054
|
+
if (node.type !== "2" && node.type !== "12")
|
|
4055
4055
|
return true;
|
|
4056
|
-
return node.type === "
|
|
4056
|
+
return node.type === "2" ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
|
4057
4057
|
}
|
|
4058
4058
|
|
|
4059
4059
|
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
4060
4060
|
const transformElement = (node, context) => {
|
|
4061
4061
|
return function postTransformElement() {
|
|
4062
4062
|
node = context.currentNode;
|
|
4063
|
-
if (!(node.type === "
|
|
4063
|
+
if (!(node.type === "1" && (node.tagType === "0" || node.tagType === "1"))) {
|
|
4064
4064
|
return;
|
|
4065
4065
|
}
|
|
4066
4066
|
const { tag, props } = node;
|
|
4067
|
-
const isComponent = node.tagType === 1;
|
|
4067
|
+
const isComponent = node.tagType === "1";
|
|
4068
4068
|
let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
|
|
4069
4069
|
const isDynamicComponent = shared.isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
|
4070
4070
|
let vnodeProps;
|
|
@@ -4107,7 +4107,7 @@ const transformElement = (node, context) => {
|
|
|
4107
4107
|
patchFlag |= 1024;
|
|
4108
4108
|
if (node.children.length > 1) {
|
|
4109
4109
|
context.onError(
|
|
4110
|
-
createCompilerError(46, {
|
|
4110
|
+
createCompilerError("46", {
|
|
4111
4111
|
start: node.children[0].loc.start,
|
|
4112
4112
|
end: node.children[node.children.length - 1].loc.end,
|
|
4113
4113
|
source: ""
|
|
@@ -4127,11 +4127,11 @@ const transformElement = (node, context) => {
|
|
|
4127
4127
|
} else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
|
4128
4128
|
const child = node.children[0];
|
|
4129
4129
|
const type = child.type;
|
|
4130
|
-
const hasDynamicTextChild = type === 5 || type === 8;
|
|
4130
|
+
const hasDynamicTextChild = type === "5" || type === "8";
|
|
4131
4131
|
if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
|
4132
4132
|
patchFlag |= 1;
|
|
4133
4133
|
}
|
|
4134
|
-
if (hasDynamicTextChild || type === "
|
|
4134
|
+
if (hasDynamicTextChild || type === "2") {
|
|
4135
4135
|
vnodeChildren = child;
|
|
4136
4136
|
} else {
|
|
4137
4137
|
vnodeChildren = node.children;
|
|
@@ -4177,13 +4177,13 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4177
4177
|
"COMPILER_IS_ON_ELEMENT",
|
|
4178
4178
|
context
|
|
4179
4179
|
)) {
|
|
4180
|
-
const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
|
4180
|
+
const exp = isProp.type === "6" ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
|
4181
4181
|
if (exp) {
|
|
4182
4182
|
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
4183
4183
|
exp
|
|
4184
4184
|
]);
|
|
4185
4185
|
}
|
|
4186
|
-
} else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
|
|
4186
|
+
} else if (isProp.type === "6" && isProp.value.content.startsWith("vue:")) {
|
|
4187
4187
|
tag = isProp.value.content.slice(4);
|
|
4188
4188
|
}
|
|
4189
4189
|
}
|
|
@@ -4293,7 +4293,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4293
4293
|
if (isEventHandler && shared.isReservedProp(name)) {
|
|
4294
4294
|
hasVnodeHook = true;
|
|
4295
4295
|
}
|
|
4296
|
-
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
|
4296
|
+
if (value.type === "20" || (value.type === "4" || value.type === "8") && getConstantType(value, context) > 0) {
|
|
4297
4297
|
return;
|
|
4298
4298
|
}
|
|
4299
4299
|
if (name === "ref") {
|
|
@@ -4314,7 +4314,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4314
4314
|
};
|
|
4315
4315
|
for (let i = 0; i < props.length; i++) {
|
|
4316
4316
|
const prop = props[i];
|
|
4317
|
-
if (prop.type === 6) {
|
|
4317
|
+
if (prop.type === "6") {
|
|
4318
4318
|
const { loc, name, value } = prop;
|
|
4319
4319
|
let isStatic = true;
|
|
4320
4320
|
if (name === "ref") {
|
|
@@ -4367,7 +4367,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4367
4367
|
if (name === "slot") {
|
|
4368
4368
|
if (!isComponent) {
|
|
4369
4369
|
context.onError(
|
|
4370
|
-
createCompilerError(40, loc)
|
|
4370
|
+
createCompilerError("40", loc)
|
|
4371
4371
|
);
|
|
4372
4372
|
}
|
|
4373
4373
|
continue;
|
|
@@ -4408,9 +4408,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4408
4408
|
{
|
|
4409
4409
|
{
|
|
4410
4410
|
const hasOverridableKeys = mergeArgs.some((arg2) => {
|
|
4411
|
-
if (arg2.type === 15) {
|
|
4411
|
+
if (arg2.type === "15") {
|
|
4412
4412
|
return arg2.properties.some(({ key }) => {
|
|
4413
|
-
if (key.type !== 4 || !key.isStatic) {
|
|
4413
|
+
if (key.type !== "4" || !key.isStatic) {
|
|
4414
4414
|
return true;
|
|
4415
4415
|
}
|
|
4416
4416
|
return key.content !== "class" && key.content !== "style" && !shared.isOn(key.content);
|
|
@@ -4438,7 +4438,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4438
4438
|
mergeArgs.push(exp);
|
|
4439
4439
|
} else {
|
|
4440
4440
|
pushMergeArg({
|
|
4441
|
-
type: 14,
|
|
4441
|
+
type: "14",
|
|
4442
4442
|
loc,
|
|
4443
4443
|
callee: context.helper(TO_HANDLERS),
|
|
4444
4444
|
arguments: isComponent ? [exp] : [exp, `true`]
|
|
@@ -4447,7 +4447,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4447
4447
|
} else {
|
|
4448
4448
|
context.onError(
|
|
4449
4449
|
createCompilerError(
|
|
4450
|
-
isVBind ? 34 : 35,
|
|
4450
|
+
isVBind ? "34" : "35",
|
|
4451
4451
|
loc
|
|
4452
4452
|
)
|
|
4453
4453
|
);
|
|
@@ -4516,7 +4516,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4516
4516
|
}
|
|
4517
4517
|
if (!context.inSSR && propsExpression) {
|
|
4518
4518
|
switch (propsExpression.type) {
|
|
4519
|
-
case 15:
|
|
4519
|
+
case "15":
|
|
4520
4520
|
let classKeyIndex = -1;
|
|
4521
4521
|
let styleKeyIndex = -1;
|
|
4522
4522
|
let hasDynamicKey = false;
|
|
@@ -4543,9 +4543,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4543
4543
|
}
|
|
4544
4544
|
if (styleProp && // the static style is compiled into an object,
|
|
4545
4545
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4546
|
-
(hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
|
|
4546
|
+
(hasStyleBinding || styleProp.value.type === "4" && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
|
|
4547
4547
|
// v-bind:style with static literal object
|
|
4548
|
-
styleProp.value.type === 17)) {
|
|
4548
|
+
styleProp.value.type === "17")) {
|
|
4549
4549
|
styleProp.value = createCallExpression(
|
|
4550
4550
|
context.helper(NORMALIZE_STYLE),
|
|
4551
4551
|
[styleProp.value]
|
|
@@ -4558,7 +4558,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4558
4558
|
);
|
|
4559
4559
|
}
|
|
4560
4560
|
break;
|
|
4561
|
-
case 14:
|
|
4561
|
+
case "14":
|
|
4562
4562
|
break;
|
|
4563
4563
|
default:
|
|
4564
4564
|
propsExpression = createCallExpression(
|
|
@@ -4585,7 +4585,7 @@ function dedupeProperties(properties) {
|
|
|
4585
4585
|
const deduped = [];
|
|
4586
4586
|
for (let i = 0; i < properties.length; i++) {
|
|
4587
4587
|
const prop = properties[i];
|
|
4588
|
-
if (prop.key.type === 8 || !prop.key.isStatic) {
|
|
4588
|
+
if (prop.key.type === "8" || !prop.key.isStatic) {
|
|
4589
4589
|
deduped.push(prop);
|
|
4590
4590
|
continue;
|
|
4591
4591
|
}
|
|
@@ -4603,7 +4603,7 @@ function dedupeProperties(properties) {
|
|
|
4603
4603
|
return deduped;
|
|
4604
4604
|
}
|
|
4605
4605
|
function mergeAsArray(existing, incoming) {
|
|
4606
|
-
if (existing.value.type === 17) {
|
|
4606
|
+
if (existing.value.type === "17") {
|
|
4607
4607
|
existing.value.elements.push(incoming.value);
|
|
4608
4608
|
} else {
|
|
4609
4609
|
existing.value = createArrayExpression(
|
|
@@ -4705,7 +4705,7 @@ function processSlotOutlet(node, context) {
|
|
|
4705
4705
|
const nonNameProps = [];
|
|
4706
4706
|
for (let i = 0; i < node.props.length; i++) {
|
|
4707
4707
|
const p = node.props[i];
|
|
4708
|
-
if (p.type === 6) {
|
|
4708
|
+
if (p.type === "6") {
|
|
4709
4709
|
if (p.value) {
|
|
4710
4710
|
if (p.name === "name") {
|
|
4711
4711
|
slotName = JSON.stringify(p.value.content);
|
|
@@ -4738,7 +4738,7 @@ function processSlotOutlet(node, context) {
|
|
|
4738
4738
|
if (directives.length) {
|
|
4739
4739
|
context.onError(
|
|
4740
4740
|
createCompilerError(
|
|
4741
|
-
36,
|
|
4741
|
+
"36",
|
|
4742
4742
|
directives[0].loc
|
|
4743
4743
|
)
|
|
4744
4744
|
);
|
|
@@ -4754,16 +4754,16 @@ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+
|
|
|
4754
4754
|
const transformOn = (dir, node, context, augmentor) => {
|
|
4755
4755
|
const { loc, modifiers, arg } = dir;
|
|
4756
4756
|
if (!dir.exp && !modifiers.length) {
|
|
4757
|
-
context.onError(createCompilerError(35, loc));
|
|
4757
|
+
context.onError(createCompilerError("35", loc));
|
|
4758
4758
|
}
|
|
4759
4759
|
let eventName;
|
|
4760
|
-
if (arg.type === 4) {
|
|
4760
|
+
if (arg.type === "4") {
|
|
4761
4761
|
if (arg.isStatic) {
|
|
4762
4762
|
let rawName = arg.content;
|
|
4763
4763
|
if (rawName.startsWith("vue:")) {
|
|
4764
4764
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
4765
4765
|
}
|
|
4766
|
-
const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
|
4766
|
+
const eventString = node.tagType !== "0" || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
|
4767
4767
|
// for non-element and vnode lifecycle event listeners, auto convert
|
|
4768
4768
|
// it to camelCase. See issue #2249
|
|
4769
4769
|
shared.toHandlerKey(shared.camelize(rawName))
|
|
@@ -4806,16 +4806,16 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4806
4806
|
shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
|
|
4807
4807
|
!context.inVOnce && // runtime constants don't need to be cached
|
|
4808
4808
|
// (this is analyzed by compileScript in SFC <script setup>)
|
|
4809
|
-
!(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
|
|
4809
|
+
!(exp.type === "4" && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
|
|
4810
4810
|
// we need to use the original function to preserve arity,
|
|
4811
4811
|
// e.g. <transition> relies on checking cb.length to determine
|
|
4812
4812
|
// transition end handling. Inline function is ok since its arity
|
|
4813
4813
|
// is preserved even when cached.
|
|
4814
|
-
!(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
|
|
4814
|
+
!(isMemberExp && node.tagType === "1") && // bail if the function references closure variables (v-for, v-slot)
|
|
4815
4815
|
// it must be passed fresh to avoid stale values.
|
|
4816
4816
|
!hasScopeRef(exp, context.identifiers);
|
|
4817
4817
|
if (shouldCache && isMemberExp) {
|
|
4818
|
-
if (exp.type === 4) {
|
|
4818
|
+
if (exp.type === "4") {
|
|
4819
4819
|
exp.content = `${exp.content} && ${exp.content}(...args)`;
|
|
4820
4820
|
} else {
|
|
4821
4821
|
exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
|
|
@@ -4853,14 +4853,14 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4853
4853
|
const transformBind = (dir, _node, context) => {
|
|
4854
4854
|
const { exp, modifiers, loc } = dir;
|
|
4855
4855
|
const arg = dir.arg;
|
|
4856
|
-
if (arg.type !== 4) {
|
|
4856
|
+
if (arg.type !== "4") {
|
|
4857
4857
|
arg.children.unshift(`(`);
|
|
4858
4858
|
arg.children.push(`) || ""`);
|
|
4859
4859
|
} else if (!arg.isStatic) {
|
|
4860
4860
|
arg.content = `${arg.content} || ""`;
|
|
4861
4861
|
}
|
|
4862
4862
|
if (modifiers.includes("camel")) {
|
|
4863
|
-
if (arg.type === 4) {
|
|
4863
|
+
if (arg.type === "4") {
|
|
4864
4864
|
if (arg.isStatic) {
|
|
4865
4865
|
arg.content = shared.camelize(arg.content);
|
|
4866
4866
|
} else {
|
|
@@ -4879,8 +4879,8 @@ const transformBind = (dir, _node, context) => {
|
|
|
4879
4879
|
injectPrefix(arg, "^");
|
|
4880
4880
|
}
|
|
4881
4881
|
}
|
|
4882
|
-
if (!exp || exp.type === 4 && !exp.content.trim()) {
|
|
4883
|
-
context.onError(createCompilerError(34, loc));
|
|
4882
|
+
if (!exp || exp.type === "4" && !exp.content.trim()) {
|
|
4883
|
+
context.onError(createCompilerError("34", loc));
|
|
4884
4884
|
return {
|
|
4885
4885
|
props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
|
|
4886
4886
|
};
|
|
@@ -4890,7 +4890,7 @@ const transformBind = (dir, _node, context) => {
|
|
|
4890
4890
|
};
|
|
4891
4891
|
};
|
|
4892
4892
|
const injectPrefix = (arg, prefix) => {
|
|
4893
|
-
if (arg.type === 4) {
|
|
4893
|
+
if (arg.type === "4") {
|
|
4894
4894
|
if (arg.isStatic) {
|
|
4895
4895
|
arg.content = prefix + arg.content;
|
|
4896
4896
|
} else {
|
|
@@ -4903,7 +4903,7 @@ const injectPrefix = (arg, prefix) => {
|
|
|
4903
4903
|
};
|
|
4904
4904
|
|
|
4905
4905
|
const transformText = (node, context) => {
|
|
4906
|
-
if (node.type === 0 || node.type === "
|
|
4906
|
+
if (node.type === "0" || node.type === "1" || node.type === "11" || node.type === "10") {
|
|
4907
4907
|
return () => {
|
|
4908
4908
|
const children = node.children;
|
|
4909
4909
|
let currentContainer = void 0;
|
|
@@ -4935,13 +4935,13 @@ const transformText = (node, context) => {
|
|
|
4935
4935
|
// as-is since the runtime has dedicated fast path for this by directly
|
|
4936
4936
|
// setting textContent of the element.
|
|
4937
4937
|
// for component root it's always normalized anyway.
|
|
4938
|
-
children.length === 1 && (node.type === 0 || node.type === "
|
|
4938
|
+
children.length === 1 && (node.type === "0" || node.type === "1" && node.tagType === "0" && // #3756
|
|
4939
4939
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
4940
4940
|
// we need to avoid setting textContent of the element at runtime
|
|
4941
4941
|
// to avoid accidentally overwriting the DOM elements added
|
|
4942
4942
|
// by the user through custom directives.
|
|
4943
4943
|
!node.props.find(
|
|
4944
|
-
(p) => p.type === 7 && !context.directiveTransforms[p.name]
|
|
4944
|
+
(p) => p.type === "7" && !context.directiveTransforms[p.name]
|
|
4945
4945
|
) && // in compat mode, <template> tags with no special directives
|
|
4946
4946
|
// will be rendered as a fragment so its children must be
|
|
4947
4947
|
// converted into vnodes.
|
|
@@ -4950,9 +4950,9 @@ const transformText = (node, context) => {
|
|
|
4950
4950
|
}
|
|
4951
4951
|
for (let i = 0; i < children.length; i++) {
|
|
4952
4952
|
const child = children[i];
|
|
4953
|
-
if (isText$1(child) || child.type === 8) {
|
|
4953
|
+
if (isText$1(child) || child.type === "8") {
|
|
4954
4954
|
const callArgs = [];
|
|
4955
|
-
if (child.type !== "
|
|
4955
|
+
if (child.type !== "2" || child.content !== " ") {
|
|
4956
4956
|
callArgs.push(child);
|
|
4957
4957
|
}
|
|
4958
4958
|
if (!context.ssr && getConstantType(child, context) === 0) {
|
|
@@ -4961,7 +4961,7 @@ const transformText = (node, context) => {
|
|
|
4961
4961
|
);
|
|
4962
4962
|
}
|
|
4963
4963
|
children[i] = {
|
|
4964
|
-
type: 12,
|
|
4964
|
+
type: "12",
|
|
4965
4965
|
content: child,
|
|
4966
4966
|
loc: child.loc,
|
|
4967
4967
|
codegenNode: createCallExpression(
|
|
@@ -4977,7 +4977,7 @@ const transformText = (node, context) => {
|
|
|
4977
4977
|
|
|
4978
4978
|
const seen$1 = /* @__PURE__ */ new WeakSet();
|
|
4979
4979
|
const transformOnce = (node, context) => {
|
|
4980
|
-
if (node.type === "
|
|
4980
|
+
if (node.type === "1" && findDir(node, "once", true)) {
|
|
4981
4981
|
if (seen$1.has(node) || context.inVOnce) {
|
|
4982
4982
|
return;
|
|
4983
4983
|
}
|
|
@@ -5002,27 +5002,27 @@ const transformModel = (dir, node, context) => {
|
|
|
5002
5002
|
const { exp, arg } = dir;
|
|
5003
5003
|
if (!exp) {
|
|
5004
5004
|
context.onError(
|
|
5005
|
-
createCompilerError(41, dir.loc)
|
|
5005
|
+
createCompilerError("41", dir.loc)
|
|
5006
5006
|
);
|
|
5007
5007
|
return createTransformProps();
|
|
5008
5008
|
}
|
|
5009
5009
|
const rawExp = exp.loc.source;
|
|
5010
|
-
const expString = exp.type === 4 ? exp.content : rawExp;
|
|
5010
|
+
const expString = exp.type === "4" ? exp.content : rawExp;
|
|
5011
5011
|
const bindingType = context.bindingMetadata[rawExp];
|
|
5012
5012
|
if (bindingType === "props" || bindingType === "props-aliased") {
|
|
5013
|
-
context.onError(createCompilerError(44, exp.loc));
|
|
5013
|
+
context.onError(createCompilerError("44", exp.loc));
|
|
5014
5014
|
return createTransformProps();
|
|
5015
5015
|
}
|
|
5016
5016
|
const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
|
|
5017
5017
|
if (!expString.trim() || !isMemberExpression(expString, context) && !maybeRef) {
|
|
5018
5018
|
context.onError(
|
|
5019
|
-
createCompilerError(42, exp.loc)
|
|
5019
|
+
createCompilerError("42", exp.loc)
|
|
5020
5020
|
);
|
|
5021
5021
|
return createTransformProps();
|
|
5022
5022
|
}
|
|
5023
5023
|
if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
|
|
5024
5024
|
context.onError(
|
|
5025
|
-
createCompilerError(43, exp.loc)
|
|
5025
|
+
createCompilerError("43", exp.loc)
|
|
5026
5026
|
);
|
|
5027
5027
|
return createTransformProps();
|
|
5028
5028
|
}
|
|
@@ -5061,7 +5061,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5061
5061
|
if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
|
|
5062
5062
|
props[1].value = context.cache(props[1].value);
|
|
5063
5063
|
}
|
|
5064
|
-
if (dir.modifiers.length && node.tagType === 1) {
|
|
5064
|
+
if (dir.modifiers.length && node.tagType === "1") {
|
|
5065
5065
|
const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
|
5066
5066
|
const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
|
5067
5067
|
props.push(
|
|
@@ -5071,7 +5071,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5071
5071
|
`{ ${modifiers} }`,
|
|
5072
5072
|
false,
|
|
5073
5073
|
dir.loc,
|
|
5074
|
-
2
|
|
5074
|
+
"2"
|
|
5075
5075
|
)
|
|
5076
5076
|
)
|
|
5077
5077
|
);
|
|
@@ -5087,30 +5087,30 @@ const transformFilter = (node, context) => {
|
|
|
5087
5087
|
if (!isCompatEnabled("COMPILER_FILTER", context)) {
|
|
5088
5088
|
return;
|
|
5089
5089
|
}
|
|
5090
|
-
if (node.type === 5) {
|
|
5090
|
+
if (node.type === "5") {
|
|
5091
5091
|
rewriteFilter(node.content, context);
|
|
5092
5092
|
}
|
|
5093
|
-
if (node.type === "
|
|
5093
|
+
if (node.type === "1") {
|
|
5094
5094
|
node.props.forEach((prop) => {
|
|
5095
|
-
if (prop.type === 7 && prop.name !== "for" && prop.exp) {
|
|
5095
|
+
if (prop.type === "7" && prop.name !== "for" && prop.exp) {
|
|
5096
5096
|
rewriteFilter(prop.exp, context);
|
|
5097
5097
|
}
|
|
5098
5098
|
});
|
|
5099
5099
|
}
|
|
5100
5100
|
};
|
|
5101
5101
|
function rewriteFilter(node, context) {
|
|
5102
|
-
if (node.type === 4) {
|
|
5102
|
+
if (node.type === "4") {
|
|
5103
5103
|
parseFilter(node, context);
|
|
5104
5104
|
} else {
|
|
5105
5105
|
for (let i = 0; i < node.children.length; i++) {
|
|
5106
5106
|
const child = node.children[i];
|
|
5107
5107
|
if (typeof child !== "object")
|
|
5108
5108
|
continue;
|
|
5109
|
-
if (child.type === 4) {
|
|
5109
|
+
if (child.type === "4") {
|
|
5110
5110
|
parseFilter(child, context);
|
|
5111
|
-
} else if (child.type === 8) {
|
|
5111
|
+
} else if (child.type === "8") {
|
|
5112
5112
|
rewriteFilter(node, context);
|
|
5113
|
-
} else if (child.type === 5) {
|
|
5113
|
+
} else if (child.type === "5") {
|
|
5114
5114
|
rewriteFilter(child.content, context);
|
|
5115
5115
|
}
|
|
5116
5116
|
}
|
|
@@ -5231,7 +5231,7 @@ function wrapFilter(exp, filter, context) {
|
|
|
5231
5231
|
|
|
5232
5232
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
5233
5233
|
const transformMemo = (node, context) => {
|
|
5234
|
-
if (node.type === "
|
|
5234
|
+
if (node.type === "1") {
|
|
5235
5235
|
const dir = findDir(node, "memo");
|
|
5236
5236
|
if (!dir || seen.has(node)) {
|
|
5237
5237
|
return;
|
|
@@ -5239,8 +5239,8 @@ const transformMemo = (node, context) => {
|
|
|
5239
5239
|
seen.add(node);
|
|
5240
5240
|
return () => {
|
|
5241
5241
|
const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
|
5242
|
-
if (codegenNode && codegenNode.type === 13) {
|
|
5243
|
-
if (node.tagType !== 1) {
|
|
5242
|
+
if (codegenNode && codegenNode.type === "13") {
|
|
5243
|
+
if (node.tagType !== "1") {
|
|
5244
5244
|
makeBlock(codegenNode, context);
|
|
5245
5245
|
}
|
|
5246
5246
|
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
@@ -5284,10 +5284,10 @@ function baseCompile(template, options = {}) {
|
|
|
5284
5284
|
const isModuleMode = options.mode === "module";
|
|
5285
5285
|
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
5286
5286
|
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
5287
|
-
onError(createCompilerError(49));
|
|
5287
|
+
onError(createCompilerError("49"));
|
|
5288
5288
|
}
|
|
5289
5289
|
if (options.scopeId && !isModuleMode) {
|
|
5290
|
-
onError(createCompilerError(50));
|
|
5290
|
+
onError(createCompilerError("50"));
|
|
5291
5291
|
}
|
|
5292
5292
|
const ast = shared.isString(template) ? baseParse(template, options) : template;
|
|
5293
5293
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|