@vue/compiler-core 3.3.0-alpha.2 → 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 +366 -366
- package/package.json +2 -2
|
@@ -21,63 +21,63 @@ function createCompilerError(code, loc, messages, additionalMessage) {
|
|
|
21
21
|
}
|
|
22
22
|
const errorMessages = {
|
|
23
23
|
// parse errors
|
|
24
|
-
[0]: "Illegal comment.",
|
|
25
|
-
[1]: "CDATA section is allowed only in XML context.",
|
|
26
|
-
[2]: "Duplicate attribute.",
|
|
27
|
-
[3]: "End tag cannot have attributes.",
|
|
28
|
-
[4]: "Illegal '/' in tags.",
|
|
29
|
-
[5]: "Unexpected EOF in tag.",
|
|
30
|
-
[6]: "Unexpected EOF in CDATA section.",
|
|
31
|
-
[7]: "Unexpected EOF in comment.",
|
|
32
|
-
[8]: "Unexpected EOF in script.",
|
|
33
|
-
[9]: "Unexpected EOF in tag.",
|
|
34
|
-
[10]: "Incorrectly closed comment.",
|
|
35
|
-
[11]: "Incorrectly opened comment.",
|
|
36
|
-
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
37
|
-
[13]: "Attribute value was expected.",
|
|
38
|
-
[14]: "End tag name was expected.",
|
|
39
|
-
[15]: "Whitespace was expected.",
|
|
40
|
-
[16]: "Unexpected '<!--' in comment.",
|
|
41
|
-
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
42
|
-
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
43
|
-
[19]: "Attribute name cannot start with '='.",
|
|
44
|
-
[21]: "'<?' is allowed only in XML context.",
|
|
45
|
-
[20]: `Unexpected null character.`,
|
|
46
|
-
[22]: "Illegal '/' in tags.",
|
|
24
|
+
["0"]: "Illegal comment.",
|
|
25
|
+
["1"]: "CDATA section is allowed only in XML context.",
|
|
26
|
+
["2"]: "Duplicate attribute.",
|
|
27
|
+
["3"]: "End tag cannot have attributes.",
|
|
28
|
+
["4"]: "Illegal '/' in tags.",
|
|
29
|
+
["5"]: "Unexpected EOF in tag.",
|
|
30
|
+
["6"]: "Unexpected EOF in CDATA section.",
|
|
31
|
+
["7"]: "Unexpected EOF in comment.",
|
|
32
|
+
["8"]: "Unexpected EOF in script.",
|
|
33
|
+
["9"]: "Unexpected EOF in tag.",
|
|
34
|
+
["10"]: "Incorrectly closed comment.",
|
|
35
|
+
["11"]: "Incorrectly opened comment.",
|
|
36
|
+
["12"]: "Illegal tag name. Use '<' to print '<'.",
|
|
37
|
+
["13"]: "Attribute value was expected.",
|
|
38
|
+
["14"]: "End tag name was expected.",
|
|
39
|
+
["15"]: "Whitespace was expected.",
|
|
40
|
+
["16"]: "Unexpected '<!--' in comment.",
|
|
41
|
+
["17"]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
42
|
+
["18"]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
43
|
+
["19"]: "Attribute name cannot start with '='.",
|
|
44
|
+
["21"]: "'<?' is allowed only in XML context.",
|
|
45
|
+
["20"]: `Unexpected null character.`,
|
|
46
|
+
["22"]: "Illegal '/' in tags.",
|
|
47
47
|
// Vue-specific parse errors
|
|
48
|
-
[23]: "Invalid end tag.",
|
|
49
|
-
[24]: "Element is missing end tag.",
|
|
50
|
-
[25]: "Interpolation end sign was not found.",
|
|
51
|
-
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
52
|
-
[26]: "Legal directive name was expected.",
|
|
48
|
+
["23"]: "Invalid end tag.",
|
|
49
|
+
["24"]: "Element is missing end tag.",
|
|
50
|
+
["25"]: "Interpolation end sign was not found.",
|
|
51
|
+
["27"]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
52
|
+
["26"]: "Legal directive name was expected.",
|
|
53
53
|
// transform errors
|
|
54
|
-
[28]: `v-if/v-else-if is missing expression.`,
|
|
55
|
-
[29]: `v-if/else branches must use unique keys.`,
|
|
56
|
-
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
57
|
-
[31]: `v-for is missing expression.`,
|
|
58
|
-
[32]: `v-for has invalid expression.`,
|
|
59
|
-
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
60
|
-
[34]: `v-bind is missing expression.`,
|
|
61
|
-
[35]: `v-on is missing expression.`,
|
|
62
|
-
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
63
|
-
[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.`,
|
|
64
|
-
[38]: `Duplicate slot names found. `,
|
|
65
|
-
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
66
|
-
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
67
|
-
[41]: `v-model is missing expression.`,
|
|
68
|
-
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
69
|
-
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
70
|
-
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
54
|
+
["28"]: `v-if/v-else-if is missing expression.`,
|
|
55
|
+
["29"]: `v-if/else branches must use unique keys.`,
|
|
56
|
+
["30"]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
57
|
+
["31"]: `v-for is missing expression.`,
|
|
58
|
+
["32"]: `v-for has invalid expression.`,
|
|
59
|
+
["33"]: `<template v-for> key should be placed on the <template> tag.`,
|
|
60
|
+
["34"]: `v-bind is missing expression.`,
|
|
61
|
+
["35"]: `v-on is missing expression.`,
|
|
62
|
+
["36"]: `Unexpected custom directive on <slot> outlet.`,
|
|
63
|
+
["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.`,
|
|
64
|
+
["38"]: `Duplicate slot names found. `,
|
|
65
|
+
["39"]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
66
|
+
["40"]: `v-slot can only be used on components or <template> tags.`,
|
|
67
|
+
["41"]: `v-model is missing expression.`,
|
|
68
|
+
["42"]: `v-model value must be a valid JavaScript member expression.`,
|
|
69
|
+
["43"]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
70
|
+
["44"]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
71
71
|
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
72
|
-
[45]: `Error parsing JavaScript expression: `,
|
|
73
|
-
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
72
|
+
["45"]: `Error parsing JavaScript expression: `,
|
|
73
|
+
["46"]: `<KeepAlive> expects exactly one child component.`,
|
|
74
74
|
// generic errors
|
|
75
|
-
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
76
|
-
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
77
|
-
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
78
|
-
[50]: `"scopeId" option is only supported in module mode.`,
|
|
75
|
+
["47"]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
76
|
+
["48"]: `ES module mode is not supported in this build of compiler.`,
|
|
77
|
+
["49"]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
78
|
+
["50"]: `"scopeId" option is only supported in module mode.`,
|
|
79
79
|
// just to fulfill types
|
|
80
|
-
[51]: ``
|
|
80
|
+
["51"]: ``
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const FRAGMENT = Symbol(``);
|
|
@@ -175,7 +175,7 @@ const locStub = {
|
|
|
175
175
|
};
|
|
176
176
|
function createRoot(children, loc = locStub) {
|
|
177
177
|
return {
|
|
178
|
-
type: 0,
|
|
178
|
+
type: "0",
|
|
179
179
|
children,
|
|
180
180
|
helpers: /* @__PURE__ */ new Set(),
|
|
181
181
|
components: [],
|
|
@@ -201,7 +201,7 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
return {
|
|
204
|
-
type: 13,
|
|
204
|
+
type: "13",
|
|
205
205
|
tag,
|
|
206
206
|
props,
|
|
207
207
|
children,
|
|
@@ -216,21 +216,21 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
216
216
|
}
|
|
217
217
|
function createArrayExpression(elements, loc = locStub) {
|
|
218
218
|
return {
|
|
219
|
-
type: 17,
|
|
219
|
+
type: "17",
|
|
220
220
|
loc,
|
|
221
221
|
elements
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
function createObjectExpression(properties, loc = locStub) {
|
|
225
225
|
return {
|
|
226
|
-
type: 15,
|
|
226
|
+
type: "15",
|
|
227
227
|
loc,
|
|
228
228
|
properties
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
function createObjectProperty(key, value) {
|
|
232
232
|
return {
|
|
233
|
-
type: 16,
|
|
233
|
+
type: "16",
|
|
234
234
|
loc: locStub,
|
|
235
235
|
key: shared.isString(key) ? createSimpleExpression(key, true) : key,
|
|
236
236
|
value
|
|
@@ -238,30 +238,30 @@ function createObjectProperty(key, value) {
|
|
|
238
238
|
}
|
|
239
239
|
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0) {
|
|
240
240
|
return {
|
|
241
|
-
type: 4,
|
|
241
|
+
type: "4",
|
|
242
242
|
loc,
|
|
243
243
|
content,
|
|
244
244
|
isStatic,
|
|
245
|
-
constType: isStatic ? 3 : constType
|
|
245
|
+
constType: isStatic ? "3" : constType
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
function createInterpolation(content, loc) {
|
|
249
249
|
return {
|
|
250
|
-
type: 5,
|
|
250
|
+
type: "5",
|
|
251
251
|
loc,
|
|
252
252
|
content: shared.isString(content) ? createSimpleExpression(content, false, loc) : content
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
255
|
function createCompoundExpression(children, loc = locStub) {
|
|
256
256
|
return {
|
|
257
|
-
type: 8,
|
|
257
|
+
type: "8",
|
|
258
258
|
loc,
|
|
259
259
|
children
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
function createCallExpression(callee, args = [], loc = locStub) {
|
|
263
263
|
return {
|
|
264
|
-
type: 14,
|
|
264
|
+
type: "14",
|
|
265
265
|
loc,
|
|
266
266
|
callee,
|
|
267
267
|
arguments: args
|
|
@@ -269,7 +269,7 @@ function createCallExpression(callee, args = [], loc = locStub) {
|
|
|
269
269
|
}
|
|
270
270
|
function createFunctionExpression(params, returns = void 0, newline = false, isSlot = false, loc = locStub) {
|
|
271
271
|
return {
|
|
272
|
-
type: 18,
|
|
272
|
+
type: "18",
|
|
273
273
|
params,
|
|
274
274
|
returns,
|
|
275
275
|
newline,
|
|
@@ -279,7 +279,7 @@ function createFunctionExpression(params, returns = void 0, newline = false, isS
|
|
|
279
279
|
}
|
|
280
280
|
function createConditionalExpression(test, consequent, alternate, newline = true) {
|
|
281
281
|
return {
|
|
282
|
-
type: 19,
|
|
282
|
+
type: "19",
|
|
283
283
|
test,
|
|
284
284
|
consequent,
|
|
285
285
|
alternate,
|
|
@@ -289,7 +289,7 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
289
289
|
}
|
|
290
290
|
function createCacheExpression(index, value, isVNode = false) {
|
|
291
291
|
return {
|
|
292
|
-
type: 20,
|
|
292
|
+
type: "20",
|
|
293
293
|
index,
|
|
294
294
|
value,
|
|
295
295
|
isVNode,
|
|
@@ -298,21 +298,21 @@ function createCacheExpression(index, value, isVNode = false) {
|
|
|
298
298
|
}
|
|
299
299
|
function createBlockStatement(body) {
|
|
300
300
|
return {
|
|
301
|
-
type: 21,
|
|
301
|
+
type: "21",
|
|
302
302
|
body,
|
|
303
303
|
loc: locStub
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
function createTemplateLiteral(elements) {
|
|
307
307
|
return {
|
|
308
|
-
type: 22,
|
|
308
|
+
type: "22",
|
|
309
309
|
elements,
|
|
310
310
|
loc: locStub
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
function createIfStatement(test, consequent, alternate) {
|
|
314
314
|
return {
|
|
315
|
-
type: 23,
|
|
315
|
+
type: "23",
|
|
316
316
|
test,
|
|
317
317
|
consequent,
|
|
318
318
|
alternate,
|
|
@@ -321,7 +321,7 @@ function createIfStatement(test, consequent, alternate) {
|
|
|
321
321
|
}
|
|
322
322
|
function createAssignmentExpression(left, right) {
|
|
323
323
|
return {
|
|
324
|
-
type: 24,
|
|
324
|
+
type: "24",
|
|
325
325
|
left,
|
|
326
326
|
right,
|
|
327
327
|
loc: locStub
|
|
@@ -329,20 +329,20 @@ function createAssignmentExpression(left, right) {
|
|
|
329
329
|
}
|
|
330
330
|
function createSequenceExpression(expressions) {
|
|
331
331
|
return {
|
|
332
|
-
type: 25,
|
|
332
|
+
type: "25",
|
|
333
333
|
expressions,
|
|
334
334
|
loc: locStub
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
function createReturnStatement(returns) {
|
|
338
338
|
return {
|
|
339
|
-
type: 26,
|
|
339
|
+
type: "26",
|
|
340
340
|
returns,
|
|
341
341
|
loc: locStub
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
345
|
+
const isStaticExp = (p) => p.type === "4" && p.isStatic;
|
|
346
346
|
const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
|
|
347
347
|
function isCoreComponent(tag) {
|
|
348
348
|
if (isBuiltInType(tag, "Teleport")) {
|
|
@@ -481,7 +481,7 @@ function assert(condition, msg) {
|
|
|
481
481
|
function findDir(node, name, allowEmpty = false) {
|
|
482
482
|
for (let i = 0; i < node.props.length; i++) {
|
|
483
483
|
const p = node.props[i];
|
|
484
|
-
if (p.type === 7 && (allowEmpty || p.exp) && (shared.isString(name) ? p.name === name : name.test(p.name))) {
|
|
484
|
+
if (p.type === "7" && (allowEmpty || p.exp) && (shared.isString(name) ? p.name === name : name.test(p.name))) {
|
|
485
485
|
return p;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
@@ -489,7 +489,7 @@ function findDir(node, name, allowEmpty = false) {
|
|
|
489
489
|
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
490
490
|
for (let i = 0; i < node.props.length; i++) {
|
|
491
491
|
const p = node.props[i];
|
|
492
|
-
if (p.type === 6) {
|
|
492
|
+
if (p.type === "6") {
|
|
493
493
|
if (dynamicOnly)
|
|
494
494
|
continue;
|
|
495
495
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
@@ -505,23 +505,23 @@ function isStaticArgOf(arg, name) {
|
|
|
505
505
|
}
|
|
506
506
|
function hasDynamicKeyVBind(node) {
|
|
507
507
|
return node.props.some(
|
|
508
|
-
(p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
|
|
509
|
-
p.arg.type !== 4 || // v-bind:[_ctx.foo]
|
|
508
|
+
(p) => p.type === "7" && p.name === "bind" && (!p.arg || // v-bind="obj"
|
|
509
|
+
p.arg.type !== "4" || // v-bind:[_ctx.foo]
|
|
510
510
|
!p.arg.isStatic)
|
|
511
511
|
// v-bind:[foo]
|
|
512
512
|
);
|
|
513
513
|
}
|
|
514
514
|
function isText$1(node) {
|
|
515
|
-
return node.type === 5 || node.type === "
|
|
515
|
+
return node.type === "5" || node.type === "2";
|
|
516
516
|
}
|
|
517
517
|
function isVSlot(p) {
|
|
518
|
-
return p.type === 7 && p.name === "slot";
|
|
518
|
+
return p.type === "7" && p.name === "slot";
|
|
519
519
|
}
|
|
520
520
|
function isTemplateNode(node) {
|
|
521
|
-
return node.type === "
|
|
521
|
+
return node.type === "1" && node.tagType === "3";
|
|
522
522
|
}
|
|
523
523
|
function isSlotOutlet(node) {
|
|
524
|
-
return node.type === "
|
|
524
|
+
return node.type === "1" && node.tagType === "2";
|
|
525
525
|
}
|
|
526
526
|
function getVNodeHelper(ssr, isComponent) {
|
|
527
527
|
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
@@ -531,7 +531,7 @@ function getVNodeBlockHelper(ssr, isComponent) {
|
|
|
531
531
|
}
|
|
532
532
|
const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
533
533
|
function getUnnormalizedProps(props, callPath = []) {
|
|
534
|
-
if (props && !shared.isString(props) && props.type === 14) {
|
|
534
|
+
if (props && !shared.isString(props) && props.type === "14") {
|
|
535
535
|
const callee = props.callee;
|
|
536
536
|
if (!shared.isString(callee) && propsHelperSet.has(callee)) {
|
|
537
537
|
return getUnnormalizedProps(
|
|
@@ -544,10 +544,10 @@ function getUnnormalizedProps(props, callPath = []) {
|
|
|
544
544
|
}
|
|
545
545
|
function injectProp(node, prop, context) {
|
|
546
546
|
let propsWithInjection;
|
|
547
|
-
let props = node.type === 13 ? node.props : node.arguments[2];
|
|
547
|
+
let props = node.type === "13" ? node.props : node.arguments[2];
|
|
548
548
|
let callPath = [];
|
|
549
549
|
let parentCall;
|
|
550
|
-
if (props && !shared.isString(props) && props.type === 14) {
|
|
550
|
+
if (props && !shared.isString(props) && props.type === "14") {
|
|
551
551
|
const ret = getUnnormalizedProps(props);
|
|
552
552
|
props = ret[0];
|
|
553
553
|
callPath = ret[1];
|
|
@@ -555,9 +555,9 @@ function injectProp(node, prop, context) {
|
|
|
555
555
|
}
|
|
556
556
|
if (props == null || shared.isString(props)) {
|
|
557
557
|
propsWithInjection = createObjectExpression([prop]);
|
|
558
|
-
} else if (props.type === 14) {
|
|
558
|
+
} else if (props.type === "14") {
|
|
559
559
|
const first = props.arguments[0];
|
|
560
|
-
if (!shared.isString(first) && first.type === 15) {
|
|
560
|
+
if (!shared.isString(first) && first.type === "15") {
|
|
561
561
|
if (!hasProp(prop, first)) {
|
|
562
562
|
first.properties.unshift(prop);
|
|
563
563
|
}
|
|
@@ -572,7 +572,7 @@ function injectProp(node, prop, context) {
|
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
574
|
!propsWithInjection && (propsWithInjection = props);
|
|
575
|
-
} else if (props.type === 15) {
|
|
575
|
+
} else if (props.type === "15") {
|
|
576
576
|
if (!hasProp(prop, props)) {
|
|
577
577
|
props.properties.unshift(prop);
|
|
578
578
|
}
|
|
@@ -586,7 +586,7 @@ function injectProp(node, prop, context) {
|
|
|
586
586
|
parentCall = callPath[callPath.length - 2];
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
if (node.type === 13) {
|
|
589
|
+
if (node.type === "13") {
|
|
590
590
|
if (parentCall) {
|
|
591
591
|
parentCall.arguments[0] = propsWithInjection;
|
|
592
592
|
} else {
|
|
@@ -602,10 +602,10 @@ function injectProp(node, prop, context) {
|
|
|
602
602
|
}
|
|
603
603
|
function hasProp(prop, props) {
|
|
604
604
|
let result = false;
|
|
605
|
-
if (prop.key.type === 4) {
|
|
605
|
+
if (prop.key.type === "4") {
|
|
606
606
|
const propKeyName = prop.key.content;
|
|
607
607
|
result = props.properties.some(
|
|
608
|
-
(p) => p.key.type === 4 && p.key.content === propKeyName
|
|
608
|
+
(p) => p.key.type === "4" && p.key.content === propKeyName
|
|
609
609
|
);
|
|
610
610
|
}
|
|
611
611
|
return result;
|
|
@@ -620,42 +620,42 @@ function hasScopeRef(node, ids) {
|
|
|
620
620
|
return false;
|
|
621
621
|
}
|
|
622
622
|
switch (node.type) {
|
|
623
|
-
case "
|
|
623
|
+
case "1":
|
|
624
624
|
for (let i = 0; i < node.props.length; i++) {
|
|
625
625
|
const p = node.props[i];
|
|
626
|
-
if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
626
|
+
if (p.type === "7" && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
627
627
|
return true;
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
631
|
-
case 11:
|
|
631
|
+
case "11":
|
|
632
632
|
if (hasScopeRef(node.source, ids)) {
|
|
633
633
|
return true;
|
|
634
634
|
}
|
|
635
635
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
636
|
-
case 9:
|
|
636
|
+
case "9":
|
|
637
637
|
return node.branches.some((b) => hasScopeRef(b, ids));
|
|
638
|
-
case 10:
|
|
638
|
+
case "10":
|
|
639
639
|
if (hasScopeRef(node.condition, ids)) {
|
|
640
640
|
return true;
|
|
641
641
|
}
|
|
642
642
|
return node.children.some((c) => hasScopeRef(c, ids));
|
|
643
|
-
case 4:
|
|
643
|
+
case "4":
|
|
644
644
|
return !node.isStatic && isSimpleIdentifier(node.content) && !!ids[node.content];
|
|
645
|
-
case 8:
|
|
645
|
+
case "8":
|
|
646
646
|
return node.children.some((c) => shared.isObject(c) && hasScopeRef(c, ids));
|
|
647
|
-
case 5:
|
|
648
|
-
case 12:
|
|
647
|
+
case "5":
|
|
648
|
+
case "12":
|
|
649
649
|
return hasScopeRef(node.content, ids);
|
|
650
|
-
case "
|
|
651
|
-
case "
|
|
650
|
+
case "2":
|
|
651
|
+
case "3":
|
|
652
652
|
return false;
|
|
653
653
|
default:
|
|
654
654
|
return false;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
657
|
function getMemoedVNodeCall(node) {
|
|
658
|
-
if (node.type === 14 && node.callee === WITH_MEMO) {
|
|
658
|
+
if (node.type === "14" && node.callee === WITH_MEMO) {
|
|
659
659
|
return node.arguments[1].returns;
|
|
660
660
|
} else {
|
|
661
661
|
return node;
|
|
@@ -749,8 +749,8 @@ const decodeMap = {
|
|
|
749
749
|
};
|
|
750
750
|
const defaultParserOptions = {
|
|
751
751
|
delimiters: [`{{`, `}}`],
|
|
752
|
-
getNamespace: () => 0,
|
|
753
|
-
getTextMode: () => 0,
|
|
752
|
+
getNamespace: () => "0",
|
|
753
|
+
getTextMode: () => "0",
|
|
754
754
|
isVoidTag: shared.NO,
|
|
755
755
|
isPreTag: shared.NO,
|
|
756
756
|
isCustomElement: shared.NO,
|
|
@@ -763,7 +763,7 @@ function baseParse(content, options = {}) {
|
|
|
763
763
|
const context = createParserContext(content, options);
|
|
764
764
|
const start = getCursor(context);
|
|
765
765
|
return createRoot(
|
|
766
|
-
parseChildren(context, 0, []),
|
|
766
|
+
parseChildren(context, "0", []),
|
|
767
767
|
getSelection(context, start)
|
|
768
768
|
);
|
|
769
769
|
}
|
|
@@ -787,48 +787,48 @@ function createParserContext(content, rawOptions) {
|
|
|
787
787
|
}
|
|
788
788
|
function parseChildren(context, mode, ancestors) {
|
|
789
789
|
const parent = last(ancestors);
|
|
790
|
-
const ns = parent ? parent.ns : 0;
|
|
790
|
+
const ns = parent ? parent.ns : "0";
|
|
791
791
|
const nodes = [];
|
|
792
792
|
while (!isEnd(context, mode, ancestors)) {
|
|
793
793
|
const s = context.source;
|
|
794
794
|
let node = void 0;
|
|
795
|
-
if (mode === 0 || mode === 1) {
|
|
795
|
+
if (mode === "0" || mode === "1") {
|
|
796
796
|
if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
|
797
797
|
node = parseInterpolation(context, mode);
|
|
798
|
-
} else if (mode === 0 && s[0] === "<") {
|
|
798
|
+
} else if (mode === "0" && s[0] === "<") {
|
|
799
799
|
if (s.length === 1) {
|
|
800
|
-
emitError(context, 5, 1);
|
|
800
|
+
emitError(context, "5", 1);
|
|
801
801
|
} else if (s[1] === "!") {
|
|
802
802
|
if (startsWith(s, "<!--")) {
|
|
803
803
|
node = parseComment(context);
|
|
804
804
|
} else if (startsWith(s, "<!DOCTYPE")) {
|
|
805
805
|
node = parseBogusComment(context);
|
|
806
806
|
} else if (startsWith(s, "<![CDATA[")) {
|
|
807
|
-
if (ns !== 0) {
|
|
807
|
+
if (ns !== "0") {
|
|
808
808
|
node = parseCDATA(context, ancestors);
|
|
809
809
|
} else {
|
|
810
|
-
emitError(context, 1);
|
|
810
|
+
emitError(context, "1");
|
|
811
811
|
node = parseBogusComment(context);
|
|
812
812
|
}
|
|
813
813
|
} else {
|
|
814
|
-
emitError(context, 11);
|
|
814
|
+
emitError(context, "11");
|
|
815
815
|
node = parseBogusComment(context);
|
|
816
816
|
}
|
|
817
817
|
} else if (s[1] === "/") {
|
|
818
818
|
if (s.length === 2) {
|
|
819
|
-
emitError(context, 5, 2);
|
|
819
|
+
emitError(context, "5", 2);
|
|
820
820
|
} else if (s[2] === ">") {
|
|
821
|
-
emitError(context, 14, 2);
|
|
821
|
+
emitError(context, "14", 2);
|
|
822
822
|
advanceBy(context, 3);
|
|
823
823
|
continue;
|
|
824
824
|
} else if (/[a-z]/i.test(s[2])) {
|
|
825
|
-
emitError(context, 23);
|
|
825
|
+
emitError(context, "23");
|
|
826
826
|
parseTag(context, TagType.End, parent);
|
|
827
827
|
continue;
|
|
828
828
|
} else {
|
|
829
829
|
emitError(
|
|
830
830
|
context,
|
|
831
|
-
12,
|
|
831
|
+
"12",
|
|
832
832
|
2
|
|
833
833
|
);
|
|
834
834
|
node = parseBogusComment(context);
|
|
@@ -839,19 +839,19 @@ function parseChildren(context, mode, ancestors) {
|
|
|
839
839
|
"COMPILER_NATIVE_TEMPLATE",
|
|
840
840
|
context
|
|
841
841
|
) && node && node.tag === "template" && !node.props.some(
|
|
842
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
842
|
+
(p) => p.type === "7" && isSpecialTemplateDirective(p.name)
|
|
843
843
|
)) {
|
|
844
844
|
node = node.children;
|
|
845
845
|
}
|
|
846
846
|
} else if (s[1] === "?") {
|
|
847
847
|
emitError(
|
|
848
848
|
context,
|
|
849
|
-
21,
|
|
849
|
+
"21",
|
|
850
850
|
1
|
|
851
851
|
);
|
|
852
852
|
node = parseBogusComment(context);
|
|
853
853
|
} else {
|
|
854
|
-
emitError(context, 12, 1);
|
|
854
|
+
emitError(context, "12", 1);
|
|
855
855
|
}
|
|
856
856
|
}
|
|
857
857
|
}
|
|
@@ -867,16 +867,16 @@ function parseChildren(context, mode, ancestors) {
|
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
869
|
let removedWhitespace = false;
|
|
870
|
-
if (mode !== 2 && mode !== 1) {
|
|
870
|
+
if (mode !== "2" && mode !== "1") {
|
|
871
871
|
const shouldCondense = context.options.whitespace !== "preserve";
|
|
872
872
|
for (let i = 0; i < nodes.length; i++) {
|
|
873
873
|
const node = nodes[i];
|
|
874
|
-
if (node.type === "
|
|
874
|
+
if (node.type === "2") {
|
|
875
875
|
if (!context.inPre) {
|
|
876
876
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
877
877
|
const prev = nodes[i - 1];
|
|
878
878
|
const next = nodes[i + 1];
|
|
879
|
-
if (!prev || !next || shouldCondense && (prev.type === "
|
|
879
|
+
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))) {
|
|
880
880
|
removedWhitespace = true;
|
|
881
881
|
nodes[i] = null;
|
|
882
882
|
} else {
|
|
@@ -888,14 +888,14 @@ function parseChildren(context, mode, ancestors) {
|
|
|
888
888
|
} else {
|
|
889
889
|
node.content = node.content.replace(/\r\n/g, "\n");
|
|
890
890
|
}
|
|
891
|
-
} else if (node.type === "
|
|
891
|
+
} else if (node.type === "3" && !context.options.comments) {
|
|
892
892
|
removedWhitespace = true;
|
|
893
893
|
nodes[i] = null;
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
896
|
if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
|
897
897
|
const first = nodes[0];
|
|
898
|
-
if (first && first.type === "
|
|
898
|
+
if (first && first.type === "2") {
|
|
899
899
|
first.content = first.content.replace(/^\r?\n/, "");
|
|
900
900
|
}
|
|
901
901
|
}
|
|
@@ -903,9 +903,9 @@ function parseChildren(context, mode, ancestors) {
|
|
|
903
903
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
904
904
|
}
|
|
905
905
|
function pushNode(nodes, node) {
|
|
906
|
-
if (node.type === "
|
|
906
|
+
if (node.type === "2") {
|
|
907
907
|
const prev = last(nodes);
|
|
908
|
-
if (prev && prev.type === "
|
|
908
|
+
if (prev && prev.type === "2" && prev.loc.end.offset === node.loc.start.offset) {
|
|
909
909
|
prev.content += node.content;
|
|
910
910
|
prev.loc.end = node.loc.end;
|
|
911
911
|
prev.loc.source += node.loc.source;
|
|
@@ -916,9 +916,9 @@ function pushNode(nodes, node) {
|
|
|
916
916
|
}
|
|
917
917
|
function parseCDATA(context, ancestors) {
|
|
918
918
|
advanceBy(context, 9);
|
|
919
|
-
const nodes = parseChildren(context, 3, ancestors);
|
|
919
|
+
const nodes = parseChildren(context, "3", ancestors);
|
|
920
920
|
if (context.source.length === 0) {
|
|
921
|
-
emitError(context, 6);
|
|
921
|
+
emitError(context, "6");
|
|
922
922
|
} else {
|
|
923
923
|
advanceBy(context, 3);
|
|
924
924
|
}
|
|
@@ -931,13 +931,13 @@ function parseComment(context) {
|
|
|
931
931
|
if (!match) {
|
|
932
932
|
content = context.source.slice(4);
|
|
933
933
|
advanceBy(context, context.source.length);
|
|
934
|
-
emitError(context, 7);
|
|
934
|
+
emitError(context, "7");
|
|
935
935
|
} else {
|
|
936
936
|
if (match.index <= 3) {
|
|
937
|
-
emitError(context, 0);
|
|
937
|
+
emitError(context, "0");
|
|
938
938
|
}
|
|
939
939
|
if (match[1]) {
|
|
940
|
-
emitError(context, 10);
|
|
940
|
+
emitError(context, "10");
|
|
941
941
|
}
|
|
942
942
|
content = context.source.slice(4, match.index);
|
|
943
943
|
const s = context.source.slice(0, match.index);
|
|
@@ -945,14 +945,14 @@ function parseComment(context) {
|
|
|
945
945
|
while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
|
|
946
946
|
advanceBy(context, nestedIndex - prevIndex + 1);
|
|
947
947
|
if (nestedIndex + 4 < s.length) {
|
|
948
|
-
emitError(context, 16);
|
|
948
|
+
emitError(context, "16");
|
|
949
949
|
}
|
|
950
950
|
prevIndex = nestedIndex + 1;
|
|
951
951
|
}
|
|
952
952
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
953
953
|
}
|
|
954
954
|
return {
|
|
955
|
-
type: "
|
|
955
|
+
type: "3",
|
|
956
956
|
content,
|
|
957
957
|
loc: getSelection(context, start)
|
|
958
958
|
};
|
|
@@ -970,7 +970,7 @@ function parseBogusComment(context) {
|
|
|
970
970
|
advanceBy(context, closeIndex + 1);
|
|
971
971
|
}
|
|
972
972
|
return {
|
|
973
|
-
type: "
|
|
973
|
+
type: "3",
|
|
974
974
|
content,
|
|
975
975
|
loc: getSelection(context, start)
|
|
976
976
|
};
|
|
@@ -997,7 +997,7 @@ function parseElement(context, ancestors) {
|
|
|
997
997
|
ancestors.pop();
|
|
998
998
|
{
|
|
999
999
|
const inlineTemplateProp = element.props.find(
|
|
1000
|
-
(p) => p.type === 6 && p.name === "inline-template"
|
|
1000
|
+
(p) => p.type === "6" && p.name === "inline-template"
|
|
1001
1001
|
);
|
|
1002
1002
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1003
1003
|
"COMPILER_INLINE_TEMPLATE",
|
|
@@ -1006,7 +1006,7 @@ function parseElement(context, ancestors) {
|
|
|
1006
1006
|
)) {
|
|
1007
1007
|
const loc = getSelection(context, element.loc.end);
|
|
1008
1008
|
inlineTemplateProp.value = {
|
|
1009
|
-
type: "
|
|
1009
|
+
type: "2",
|
|
1010
1010
|
content: loc.source,
|
|
1011
1011
|
loc
|
|
1012
1012
|
};
|
|
@@ -1016,11 +1016,11 @@ function parseElement(context, ancestors) {
|
|
|
1016
1016
|
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1017
1017
|
parseTag(context, TagType.End, parent);
|
|
1018
1018
|
} else {
|
|
1019
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1019
|
+
emitError(context, "24", 0, element.loc.start);
|
|
1020
1020
|
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1021
1021
|
const first = children[0];
|
|
1022
1022
|
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1023
|
-
emitError(context, 8);
|
|
1023
|
+
emitError(context, "8");
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
@@ -1054,7 +1054,7 @@ function parseTag(context, type, parent) {
|
|
|
1054
1054
|
context.inPre = true;
|
|
1055
1055
|
}
|
|
1056
1056
|
let props = parseAttributes(context, type);
|
|
1057
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1057
|
+
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === "7" && p.name === "pre")) {
|
|
1058
1058
|
context.inVPre = true;
|
|
1059
1059
|
shared.extend(context, cursor);
|
|
1060
1060
|
context.source = currentSource;
|
|
@@ -1062,33 +1062,33 @@ function parseTag(context, type, parent) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
let isSelfClosing = false;
|
|
1064
1064
|
if (context.source.length === 0) {
|
|
1065
|
-
emitError(context, 9);
|
|
1065
|
+
emitError(context, "9");
|
|
1066
1066
|
} else {
|
|
1067
1067
|
isSelfClosing = startsWith(context.source, "/>");
|
|
1068
1068
|
if (type === 1 /* End */ && isSelfClosing) {
|
|
1069
|
-
emitError(context, 4);
|
|
1069
|
+
emitError(context, "4");
|
|
1070
1070
|
}
|
|
1071
1071
|
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1072
1072
|
}
|
|
1073
1073
|
if (type === 1 /* End */) {
|
|
1074
1074
|
return;
|
|
1075
1075
|
}
|
|
1076
|
-
let tagType = 0;
|
|
1076
|
+
let tagType = "0";
|
|
1077
1077
|
if (!context.inVPre) {
|
|
1078
1078
|
if (tag === "slot") {
|
|
1079
|
-
tagType = 2;
|
|
1079
|
+
tagType = "2";
|
|
1080
1080
|
} else if (tag === "template") {
|
|
1081
1081
|
if (props.some(
|
|
1082
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1082
|
+
(p) => p.type === "7" && isSpecialTemplateDirective(p.name)
|
|
1083
1083
|
)) {
|
|
1084
|
-
tagType = 3;
|
|
1084
|
+
tagType = "3";
|
|
1085
1085
|
}
|
|
1086
1086
|
} else if (isComponent(tag, props, context)) {
|
|
1087
|
-
tagType = 1;
|
|
1087
|
+
tagType = "1";
|
|
1088
1088
|
}
|
|
1089
1089
|
}
|
|
1090
1090
|
return {
|
|
1091
|
-
type: "
|
|
1091
|
+
type: "1",
|
|
1092
1092
|
ns,
|
|
1093
1093
|
tag,
|
|
1094
1094
|
tagType,
|
|
@@ -1110,7 +1110,7 @@ function isComponent(tag, props, context) {
|
|
|
1110
1110
|
}
|
|
1111
1111
|
for (let i = 0; i < props.length; i++) {
|
|
1112
1112
|
const p = props[i];
|
|
1113
|
-
if (p.type === 6) {
|
|
1113
|
+
if (p.type === "6") {
|
|
1114
1114
|
if (p.name === "is" && p.value) {
|
|
1115
1115
|
if (p.value.content.startsWith("vue:")) {
|
|
1116
1116
|
return true;
|
|
@@ -1143,23 +1143,23 @@ function parseAttributes(context, type) {
|
|
|
1143
1143
|
const attributeNames = /* @__PURE__ */ new Set();
|
|
1144
1144
|
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1145
1145
|
if (startsWith(context.source, "/")) {
|
|
1146
|
-
emitError(context, 22);
|
|
1146
|
+
emitError(context, "22");
|
|
1147
1147
|
advanceBy(context, 1);
|
|
1148
1148
|
advanceSpaces(context);
|
|
1149
1149
|
continue;
|
|
1150
1150
|
}
|
|
1151
1151
|
if (type === 1 /* End */) {
|
|
1152
|
-
emitError(context, 3);
|
|
1152
|
+
emitError(context, "3");
|
|
1153
1153
|
}
|
|
1154
1154
|
const attr = parseAttribute(context, attributeNames);
|
|
1155
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1155
|
+
if (attr.type === "6" && attr.value && attr.name === "class") {
|
|
1156
1156
|
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1157
1157
|
}
|
|
1158
1158
|
if (type === 0 /* Start */) {
|
|
1159
1159
|
props.push(attr);
|
|
1160
1160
|
}
|
|
1161
1161
|
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1162
|
-
emitError(context, 15);
|
|
1162
|
+
emitError(context, "15");
|
|
1163
1163
|
}
|
|
1164
1164
|
advanceSpaces(context);
|
|
1165
1165
|
}
|
|
@@ -1170,11 +1170,11 @@ function parseAttribute(context, nameSet) {
|
|
|
1170
1170
|
const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
|
1171
1171
|
const name = match[0];
|
|
1172
1172
|
if (nameSet.has(name)) {
|
|
1173
|
-
emitError(context, 2);
|
|
1173
|
+
emitError(context, "2");
|
|
1174
1174
|
}
|
|
1175
1175
|
nameSet.add(name);
|
|
1176
1176
|
if (name[0] === "=") {
|
|
1177
|
-
emitError(context, 19);
|
|
1177
|
+
emitError(context, "19");
|
|
1178
1178
|
}
|
|
1179
1179
|
{
|
|
1180
1180
|
const pattern = /["'<]/g;
|
|
@@ -1182,7 +1182,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1182
1182
|
while (m = pattern.exec(name)) {
|
|
1183
1183
|
emitError(
|
|
1184
1184
|
context,
|
|
1185
|
-
17,
|
|
1185
|
+
"17",
|
|
1186
1186
|
m.index
|
|
1187
1187
|
);
|
|
1188
1188
|
}
|
|
@@ -1195,7 +1195,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1195
1195
|
advanceSpaces(context);
|
|
1196
1196
|
value = parseAttributeValue(context);
|
|
1197
1197
|
if (!value) {
|
|
1198
|
-
emitError(context, 13);
|
|
1198
|
+
emitError(context, "13");
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
1201
|
const loc = getSelection(context, start);
|
|
@@ -1225,7 +1225,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1225
1225
|
if (!content.endsWith("]")) {
|
|
1226
1226
|
emitError(
|
|
1227
1227
|
context,
|
|
1228
|
-
27
|
|
1228
|
+
"27"
|
|
1229
1229
|
);
|
|
1230
1230
|
content = content.slice(1);
|
|
1231
1231
|
} else {
|
|
@@ -1235,10 +1235,10 @@ function parseAttribute(context, nameSet) {
|
|
|
1235
1235
|
content += match2[3] || "";
|
|
1236
1236
|
}
|
|
1237
1237
|
arg = {
|
|
1238
|
-
type: 4,
|
|
1238
|
+
type: "4",
|
|
1239
1239
|
content,
|
|
1240
1240
|
isStatic,
|
|
1241
|
-
constType: isStatic ? 3 : 0,
|
|
1241
|
+
constType: isStatic ? "3" : 0,
|
|
1242
1242
|
loc: loc2
|
|
1243
1243
|
};
|
|
1244
1244
|
}
|
|
@@ -1264,10 +1264,10 @@ function parseAttribute(context, nameSet) {
|
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
1266
|
return {
|
|
1267
|
-
type: 7,
|
|
1267
|
+
type: "7",
|
|
1268
1268
|
name: dirName,
|
|
1269
1269
|
exp: value && {
|
|
1270
|
-
type: 4,
|
|
1270
|
+
type: "4",
|
|
1271
1271
|
content: value.content,
|
|
1272
1272
|
isStatic: false,
|
|
1273
1273
|
// Treat as non-constant by default. This can be potentially set to
|
|
@@ -1281,13 +1281,13 @@ function parseAttribute(context, nameSet) {
|
|
|
1281
1281
|
};
|
|
1282
1282
|
}
|
|
1283
1283
|
if (!context.inVPre && startsWith(name, "v-")) {
|
|
1284
|
-
emitError(context, 26);
|
|
1284
|
+
emitError(context, "26");
|
|
1285
1285
|
}
|
|
1286
1286
|
return {
|
|
1287
|
-
type: 6,
|
|
1287
|
+
type: "6",
|
|
1288
1288
|
name,
|
|
1289
1289
|
value: value && {
|
|
1290
|
-
type: "
|
|
1290
|
+
type: "2",
|
|
1291
1291
|
content: value.content,
|
|
1292
1292
|
loc: value.loc
|
|
1293
1293
|
},
|
|
@@ -1306,10 +1306,10 @@ function parseAttributeValue(context) {
|
|
|
1306
1306
|
content = parseTextData(
|
|
1307
1307
|
context,
|
|
1308
1308
|
context.source.length,
|
|
1309
|
-
4
|
|
1309
|
+
"4"
|
|
1310
1310
|
);
|
|
1311
1311
|
} else {
|
|
1312
|
-
content = parseTextData(context, endIndex, 4);
|
|
1312
|
+
content = parseTextData(context, endIndex, "4");
|
|
1313
1313
|
advanceBy(context, 1);
|
|
1314
1314
|
}
|
|
1315
1315
|
} else {
|
|
@@ -1322,11 +1322,11 @@ function parseAttributeValue(context) {
|
|
|
1322
1322
|
while (m = unexpectedChars.exec(match[0])) {
|
|
1323
1323
|
emitError(
|
|
1324
1324
|
context,
|
|
1325
|
-
18,
|
|
1325
|
+
"18",
|
|
1326
1326
|
m.index
|
|
1327
1327
|
);
|
|
1328
1328
|
}
|
|
1329
|
-
content = parseTextData(context, match[0].length, 4);
|
|
1329
|
+
content = parseTextData(context, match[0].length, "4");
|
|
1330
1330
|
}
|
|
1331
1331
|
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1332
1332
|
}
|
|
@@ -1334,7 +1334,7 @@ function parseInterpolation(context, mode) {
|
|
|
1334
1334
|
const [open, close] = context.options.delimiters;
|
|
1335
1335
|
const closeIndex = context.source.indexOf(close, open.length);
|
|
1336
1336
|
if (closeIndex === -1) {
|
|
1337
|
-
emitError(context, 25);
|
|
1337
|
+
emitError(context, "25");
|
|
1338
1338
|
return void 0;
|
|
1339
1339
|
}
|
|
1340
1340
|
const start = getCursor(context);
|
|
@@ -1353,9 +1353,9 @@ function parseInterpolation(context, mode) {
|
|
|
1353
1353
|
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1354
1354
|
advanceBy(context, close.length);
|
|
1355
1355
|
return {
|
|
1356
|
-
type: 5,
|
|
1356
|
+
type: "5",
|
|
1357
1357
|
content: {
|
|
1358
|
-
type: 4,
|
|
1358
|
+
type: "4",
|
|
1359
1359
|
isStatic: false,
|
|
1360
1360
|
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1361
1361
|
constType: 0,
|
|
@@ -1366,7 +1366,7 @@ function parseInterpolation(context, mode) {
|
|
|
1366
1366
|
};
|
|
1367
1367
|
}
|
|
1368
1368
|
function parseText(context, mode) {
|
|
1369
|
-
const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
|
|
1369
|
+
const endTokens = mode === "3" ? ["]]>"] : ["<", context.options.delimiters[0]];
|
|
1370
1370
|
let endIndex = context.source.length;
|
|
1371
1371
|
for (let i = 0; i < endTokens.length; i++) {
|
|
1372
1372
|
const index = context.source.indexOf(endTokens[i], 1);
|
|
@@ -1377,7 +1377,7 @@ function parseText(context, mode) {
|
|
|
1377
1377
|
const start = getCursor(context);
|
|
1378
1378
|
const content = parseTextData(context, endIndex, mode);
|
|
1379
1379
|
return {
|
|
1380
|
-
type: "
|
|
1380
|
+
type: "2",
|
|
1381
1381
|
content,
|
|
1382
1382
|
loc: getSelection(context, start)
|
|
1383
1383
|
};
|
|
@@ -1385,12 +1385,12 @@ function parseText(context, mode) {
|
|
|
1385
1385
|
function parseTextData(context, length, mode) {
|
|
1386
1386
|
const rawText = context.source.slice(0, length);
|
|
1387
1387
|
advanceBy(context, length);
|
|
1388
|
-
if (mode === 2 || mode === 3 || !rawText.includes("&")) {
|
|
1388
|
+
if (mode === "2" || mode === "3" || !rawText.includes("&")) {
|
|
1389
1389
|
return rawText;
|
|
1390
1390
|
} else {
|
|
1391
1391
|
return context.options.decodeEntities(
|
|
1392
1392
|
rawText,
|
|
1393
|
-
mode === 4
|
|
1393
|
+
mode === "4"
|
|
1394
1394
|
);
|
|
1395
1395
|
}
|
|
1396
1396
|
}
|
|
@@ -1446,7 +1446,7 @@ function emitError(context, code, offset, loc = getCursor(context)) {
|
|
|
1446
1446
|
function isEnd(context, mode, ancestors) {
|
|
1447
1447
|
const s = context.source;
|
|
1448
1448
|
switch (mode) {
|
|
1449
|
-
case 0:
|
|
1449
|
+
case "0":
|
|
1450
1450
|
if (startsWith(s, "</")) {
|
|
1451
1451
|
for (let i = ancestors.length - 1; i >= 0; --i) {
|
|
1452
1452
|
if (startsWithEndTagOpen(s, ancestors[i].tag)) {
|
|
@@ -1455,15 +1455,15 @@ function isEnd(context, mode, ancestors) {
|
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
1457
|
break;
|
|
1458
|
-
case 1:
|
|
1459
|
-
case 2: {
|
|
1458
|
+
case "1":
|
|
1459
|
+
case "2": {
|
|
1460
1460
|
const parent = last(ancestors);
|
|
1461
1461
|
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1462
1462
|
return true;
|
|
1463
1463
|
}
|
|
1464
1464
|
break;
|
|
1465
1465
|
}
|
|
1466
|
-
case 3:
|
|
1466
|
+
case "3":
|
|
1467
1467
|
if (startsWith(s, "]]>")) {
|
|
1468
1468
|
return true;
|
|
1469
1469
|
}
|
|
@@ -1486,7 +1486,7 @@ function hoistStatic(root, context) {
|
|
|
1486
1486
|
}
|
|
1487
1487
|
function isSingleElementRoot(root, child) {
|
|
1488
1488
|
const { children } = root;
|
|
1489
|
-
return children.length === 1 && child.type === "
|
|
1489
|
+
return children.length === 1 && child.type === "1" && !isSlotOutlet(child);
|
|
1490
1490
|
}
|
|
1491
1491
|
function walk(node, context, doNotHoistNode = false) {
|
|
1492
1492
|
const { children } = node;
|
|
@@ -1494,10 +1494,10 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1494
1494
|
let hoistedCount = 0;
|
|
1495
1495
|
for (let i = 0; i < children.length; i++) {
|
|
1496
1496
|
const child = children[i];
|
|
1497
|
-
if (child.type === "
|
|
1497
|
+
if (child.type === "1" && child.tagType === "0") {
|
|
1498
1498
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
1499
1499
|
if (constantType > 0) {
|
|
1500
|
-
if (constantType >= 2) {
|
|
1500
|
+
if (constantType >= "2") {
|
|
1501
1501
|
child.codegenNode.patchFlag = -1 + (``);
|
|
1502
1502
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1503
1503
|
hoistedCount++;
|
|
@@ -1505,9 +1505,9 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
} else {
|
|
1507
1507
|
const codegenNode = child.codegenNode;
|
|
1508
|
-
if (codegenNode.type === 13) {
|
|
1508
|
+
if (codegenNode.type === "13") {
|
|
1509
1509
|
const flag = getPatchFlag(codegenNode);
|
|
1510
|
-
if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
|
|
1510
|
+
if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= "2") {
|
|
1511
1511
|
const props = getNodeProps(child);
|
|
1512
1512
|
if (props) {
|
|
1513
1513
|
codegenNode.props = context.hoist(props);
|
|
@@ -1519,8 +1519,8 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
|
-
if (child.type === "
|
|
1523
|
-
const isComponent = child.tagType === 1;
|
|
1522
|
+
if (child.type === "1") {
|
|
1523
|
+
const isComponent = child.tagType === "1";
|
|
1524
1524
|
if (isComponent) {
|
|
1525
1525
|
context.scopes.vSlot++;
|
|
1526
1526
|
}
|
|
@@ -1528,9 +1528,9 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1528
1528
|
if (isComponent) {
|
|
1529
1529
|
context.scopes.vSlot--;
|
|
1530
1530
|
}
|
|
1531
|
-
} else if (child.type === 11) {
|
|
1531
|
+
} else if (child.type === "11") {
|
|
1532
1532
|
walk(child, context, child.children.length === 1);
|
|
1533
|
-
} else if (child.type === 9) {
|
|
1533
|
+
} else if (child.type === "9") {
|
|
1534
1534
|
for (let i2 = 0; i2 < child.branches.length; i2++) {
|
|
1535
1535
|
walk(
|
|
1536
1536
|
child.branches[i2],
|
|
@@ -1543,7 +1543,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1543
1543
|
if (hoistedCount && context.transformHoist) {
|
|
1544
1544
|
context.transformHoist(children, context, node);
|
|
1545
1545
|
}
|
|
1546
|
-
if (hoistedCount && hoistedCount === originalCount && node.type === "
|
|
1546
|
+
if (hoistedCount && hoistedCount === originalCount && node.type === "1" && node.tagType === "0" && node.codegenNode && node.codegenNode.type === "13" && shared.isArray(node.codegenNode.children)) {
|
|
1547
1547
|
node.codegenNode.children = context.hoist(
|
|
1548
1548
|
createArrayExpression(node.codegenNode.children)
|
|
1549
1549
|
);
|
|
@@ -1552,8 +1552,8 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1552
1552
|
function getConstantType(node, context) {
|
|
1553
1553
|
const { constantCache } = context;
|
|
1554
1554
|
switch (node.type) {
|
|
1555
|
-
case "
|
|
1556
|
-
if (node.tagType !== 0) {
|
|
1555
|
+
case "1":
|
|
1556
|
+
if (node.tagType !== "0") {
|
|
1557
1557
|
return 0;
|
|
1558
1558
|
}
|
|
1559
1559
|
const cached = constantCache.get(node);
|
|
@@ -1561,7 +1561,7 @@ function getConstantType(node, context) {
|
|
|
1561
1561
|
return cached;
|
|
1562
1562
|
}
|
|
1563
1563
|
const codegenNode = node.codegenNode;
|
|
1564
|
-
if (codegenNode.type !== 13) {
|
|
1564
|
+
if (codegenNode.type !== "13") {
|
|
1565
1565
|
return 0;
|
|
1566
1566
|
}
|
|
1567
1567
|
if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
|
|
@@ -1569,7 +1569,7 @@ function getConstantType(node, context) {
|
|
|
1569
1569
|
}
|
|
1570
1570
|
const flag = getPatchFlag(codegenNode);
|
|
1571
1571
|
if (!flag) {
|
|
1572
|
-
let returnType2 = 3;
|
|
1572
|
+
let returnType2 = "3";
|
|
1573
1573
|
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
1574
1574
|
if (generatedPropsType === 0) {
|
|
1575
1575
|
constantCache.set(node, 0);
|
|
@@ -1588,10 +1588,10 @@ function getConstantType(node, context) {
|
|
|
1588
1588
|
returnType2 = childType;
|
|
1589
1589
|
}
|
|
1590
1590
|
}
|
|
1591
|
-
if (returnType2 > 1) {
|
|
1591
|
+
if (returnType2 > "1") {
|
|
1592
1592
|
for (let i = 0; i < node.props.length; i++) {
|
|
1593
1593
|
const p = node.props[i];
|
|
1594
|
-
if (p.type === 7 && p.name === "bind" && p.exp) {
|
|
1594
|
+
if (p.type === "7" && p.name === "bind" && p.exp) {
|
|
1595
1595
|
const expType = getConstantType(p.exp, context);
|
|
1596
1596
|
if (expType === 0) {
|
|
1597
1597
|
constantCache.set(node, 0);
|
|
@@ -1606,7 +1606,7 @@ function getConstantType(node, context) {
|
|
|
1606
1606
|
if (codegenNode.isBlock) {
|
|
1607
1607
|
for (let i = 0; i < node.props.length; i++) {
|
|
1608
1608
|
const p = node.props[i];
|
|
1609
|
-
if (p.type === 7) {
|
|
1609
|
+
if (p.type === "7") {
|
|
1610
1610
|
constantCache.set(node, 0);
|
|
1611
1611
|
return 0;
|
|
1612
1612
|
}
|
|
@@ -1624,20 +1624,20 @@ function getConstantType(node, context) {
|
|
|
1624
1624
|
constantCache.set(node, 0);
|
|
1625
1625
|
return 0;
|
|
1626
1626
|
}
|
|
1627
|
-
case "
|
|
1628
|
-
case "
|
|
1629
|
-
return 3;
|
|
1630
|
-
case 9:
|
|
1631
|
-
case 11:
|
|
1632
|
-
case 10:
|
|
1627
|
+
case "2":
|
|
1628
|
+
case "3":
|
|
1629
|
+
return "3";
|
|
1630
|
+
case "9":
|
|
1631
|
+
case "11":
|
|
1632
|
+
case "10":
|
|
1633
1633
|
return 0;
|
|
1634
|
-
case 5:
|
|
1635
|
-
case 12:
|
|
1634
|
+
case "5":
|
|
1635
|
+
case "12":
|
|
1636
1636
|
return getConstantType(node.content, context);
|
|
1637
|
-
case 4:
|
|
1637
|
+
case "4":
|
|
1638
1638
|
return node.constType;
|
|
1639
|
-
case 8:
|
|
1640
|
-
let returnType = 3;
|
|
1639
|
+
case "8":
|
|
1640
|
+
let returnType = "3";
|
|
1641
1641
|
for (let i = 0; i < node.children.length; i++) {
|
|
1642
1642
|
const child = node.children[i];
|
|
1643
1643
|
if (shared.isString(child) || shared.isSymbol(child)) {
|
|
@@ -1662,20 +1662,20 @@ const allowHoistedHelperSet = /* @__PURE__ */ new Set([
|
|
|
1662
1662
|
GUARD_REACTIVE_PROPS
|
|
1663
1663
|
]);
|
|
1664
1664
|
function getConstantTypeOfHelperCall(value, context) {
|
|
1665
|
-
if (value.type === 14 && !shared.isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
|
1665
|
+
if (value.type === "14" && !shared.isString(value.callee) && allowHoistedHelperSet.has(value.callee)) {
|
|
1666
1666
|
const arg = value.arguments[0];
|
|
1667
|
-
if (arg.type === 4) {
|
|
1667
|
+
if (arg.type === "4") {
|
|
1668
1668
|
return getConstantType(arg, context);
|
|
1669
|
-
} else if (arg.type === 14) {
|
|
1669
|
+
} else if (arg.type === "14") {
|
|
1670
1670
|
return getConstantTypeOfHelperCall(arg, context);
|
|
1671
1671
|
}
|
|
1672
1672
|
}
|
|
1673
1673
|
return 0;
|
|
1674
1674
|
}
|
|
1675
1675
|
function getGeneratedPropsConstantType(node, context) {
|
|
1676
|
-
let returnType = 3;
|
|
1676
|
+
let returnType = "3";
|
|
1677
1677
|
const props = getNodeProps(node);
|
|
1678
|
-
if (props && props.type === 15) {
|
|
1678
|
+
if (props && props.type === "15") {
|
|
1679
1679
|
const { properties } = props;
|
|
1680
1680
|
for (let i = 0; i < properties.length; i++) {
|
|
1681
1681
|
const { key, value } = properties[i];
|
|
@@ -1687,9 +1687,9 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
1687
1687
|
returnType = keyType;
|
|
1688
1688
|
}
|
|
1689
1689
|
let valueType;
|
|
1690
|
-
if (value.type === 4) {
|
|
1690
|
+
if (value.type === "4") {
|
|
1691
1691
|
valueType = getConstantType(value, context);
|
|
1692
|
-
} else if (value.type === 14) {
|
|
1692
|
+
} else if (value.type === "14") {
|
|
1693
1693
|
valueType = getConstantTypeOfHelperCall(value, context);
|
|
1694
1694
|
} else {
|
|
1695
1695
|
valueType = 0;
|
|
@@ -1706,7 +1706,7 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
function getNodeProps(node) {
|
|
1708
1708
|
const codegenNode = node.codegenNode;
|
|
1709
|
-
if (codegenNode.type === 13) {
|
|
1709
|
+
if (codegenNode.type === "13") {
|
|
1710
1710
|
return codegenNode.props;
|
|
1711
1711
|
}
|
|
1712
1712
|
}
|
|
@@ -1828,7 +1828,7 @@ function createTransformContext(root, {
|
|
|
1828
1828
|
addId(exp);
|
|
1829
1829
|
} else if (exp.identifiers) {
|
|
1830
1830
|
exp.identifiers.forEach(addId);
|
|
1831
|
-
} else if (exp.type === 4) {
|
|
1831
|
+
} else if (exp.type === "4") {
|
|
1832
1832
|
addId(exp.content);
|
|
1833
1833
|
}
|
|
1834
1834
|
}
|
|
@@ -1839,7 +1839,7 @@ function createTransformContext(root, {
|
|
|
1839
1839
|
removeId(exp);
|
|
1840
1840
|
} else if (exp.identifiers) {
|
|
1841
1841
|
exp.identifiers.forEach(removeId);
|
|
1842
|
-
} else if (exp.type === 4) {
|
|
1842
|
+
} else if (exp.type === "4") {
|
|
1843
1843
|
removeId(exp.content);
|
|
1844
1844
|
}
|
|
1845
1845
|
}
|
|
@@ -1852,7 +1852,7 @@ function createTransformContext(root, {
|
|
|
1852
1852
|
`_hoisted_${context.hoists.length}`,
|
|
1853
1853
|
false,
|
|
1854
1854
|
exp.loc,
|
|
1855
|
-
2
|
|
1855
|
+
"2"
|
|
1856
1856
|
);
|
|
1857
1857
|
identifier.hoisted = exp;
|
|
1858
1858
|
return identifier;
|
|
@@ -1903,7 +1903,7 @@ function createRootCodegen(root, context) {
|
|
|
1903
1903
|
const child = children[0];
|
|
1904
1904
|
if (isSingleElementRoot(root, child) && child.codegenNode) {
|
|
1905
1905
|
const codegenNode = child.codegenNode;
|
|
1906
|
-
if (codegenNode.type === 13) {
|
|
1906
|
+
if (codegenNode.type === "13") {
|
|
1907
1907
|
makeBlock(codegenNode, context);
|
|
1908
1908
|
}
|
|
1909
1909
|
root.codegenNode = codegenNode;
|
|
@@ -1963,25 +1963,25 @@ function traverseNode(node, context) {
|
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
1965
|
switch (node.type) {
|
|
1966
|
-
case "
|
|
1966
|
+
case "3":
|
|
1967
1967
|
if (!context.ssr) {
|
|
1968
1968
|
context.helper(CREATE_COMMENT);
|
|
1969
1969
|
}
|
|
1970
1970
|
break;
|
|
1971
|
-
case 5:
|
|
1971
|
+
case "5":
|
|
1972
1972
|
if (!context.ssr) {
|
|
1973
1973
|
context.helper(TO_DISPLAY_STRING);
|
|
1974
1974
|
}
|
|
1975
1975
|
break;
|
|
1976
|
-
case 9:
|
|
1976
|
+
case "9":
|
|
1977
1977
|
for (let i2 = 0; i2 < node.branches.length; i2++) {
|
|
1978
1978
|
traverseNode(node.branches[i2], context);
|
|
1979
1979
|
}
|
|
1980
1980
|
break;
|
|
1981
|
-
case 10:
|
|
1982
|
-
case 11:
|
|
1983
|
-
case "
|
|
1984
|
-
case 0:
|
|
1981
|
+
case "10":
|
|
1982
|
+
case "11":
|
|
1983
|
+
case "1":
|
|
1984
|
+
case "0":
|
|
1985
1985
|
traverseChildren(node, context);
|
|
1986
1986
|
break;
|
|
1987
1987
|
}
|
|
@@ -1994,15 +1994,15 @@ function traverseNode(node, context) {
|
|
|
1994
1994
|
function createStructuralDirectiveTransform(name, fn) {
|
|
1995
1995
|
const matches = shared.isString(name) ? (n) => n === name : (n) => name.test(n);
|
|
1996
1996
|
return (node, context) => {
|
|
1997
|
-
if (node.type === "
|
|
1997
|
+
if (node.type === "1") {
|
|
1998
1998
|
const { props } = node;
|
|
1999
|
-
if (node.tagType === 3 && props.some(isVSlot)) {
|
|
1999
|
+
if (node.tagType === "3" && props.some(isVSlot)) {
|
|
2000
2000
|
return;
|
|
2001
2001
|
}
|
|
2002
2002
|
const exitFns = [];
|
|
2003
2003
|
for (let i = 0; i < props.length; i++) {
|
|
2004
2004
|
const prop = props[i];
|
|
2005
|
-
if (prop.type === 7 && matches(prop.name)) {
|
|
2005
|
+
if (prop.type === "7" && matches(prop.name)) {
|
|
2006
2006
|
props.splice(i, 1);
|
|
2007
2007
|
i--;
|
|
2008
2008
|
const onExit = fn(node, prop, context);
|
|
@@ -2060,7 +2060,7 @@ function createCodegenContext(ast, {
|
|
|
2060
2060
|
if (context.map) {
|
|
2061
2061
|
if (node) {
|
|
2062
2062
|
let name;
|
|
2063
|
-
if (node.type === 4 && !node.isStatic) {
|
|
2063
|
+
if (node.type === "4" && !node.isStatic) {
|
|
2064
2064
|
const content = node.content.replace(/^_ctx\./, "");
|
|
2065
2065
|
if (content !== node.content && isSimpleIdentifier(content)) {
|
|
2066
2066
|
name = content;
|
|
@@ -2336,7 +2336,7 @@ function genHoists(hoists, context) {
|
|
|
2336
2336
|
for (let i = 0; i < hoists.length; i++) {
|
|
2337
2337
|
const exp = hoists[i];
|
|
2338
2338
|
if (exp) {
|
|
2339
|
-
const needScopeIdWrapper = genScopeId && exp.type === 13;
|
|
2339
|
+
const needScopeIdWrapper = genScopeId && exp.type === "13";
|
|
2340
2340
|
push(
|
|
2341
2341
|
`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
|
|
2342
2342
|
);
|
|
@@ -2361,7 +2361,7 @@ function genImports(importsOptions, context) {
|
|
|
2361
2361
|
});
|
|
2362
2362
|
}
|
|
2363
2363
|
function isText(n) {
|
|
2364
|
-
return shared.isString(n) || n.type === 4 || n.type === "
|
|
2364
|
+
return shared.isString(n) || n.type === "4" || n.type === "2" || n.type === "5" || n.type === "8";
|
|
2365
2365
|
}
|
|
2366
2366
|
function genNodeListAsArray(nodes, context) {
|
|
2367
2367
|
const multilines = nodes.length > 3 || nodes.some((n) => shared.isArray(n) || !isText(n));
|
|
@@ -2402,66 +2402,66 @@ function genNode(node, context) {
|
|
|
2402
2402
|
return;
|
|
2403
2403
|
}
|
|
2404
2404
|
switch (node.type) {
|
|
2405
|
-
case "
|
|
2406
|
-
case 9:
|
|
2407
|
-
case 11:
|
|
2405
|
+
case "1":
|
|
2406
|
+
case "9":
|
|
2407
|
+
case "11":
|
|
2408
2408
|
genNode(node.codegenNode, context);
|
|
2409
2409
|
break;
|
|
2410
|
-
case "
|
|
2410
|
+
case "2":
|
|
2411
2411
|
genText(node, context);
|
|
2412
2412
|
break;
|
|
2413
|
-
case 4:
|
|
2413
|
+
case "4":
|
|
2414
2414
|
genExpression(node, context);
|
|
2415
2415
|
break;
|
|
2416
|
-
case 5:
|
|
2416
|
+
case "5":
|
|
2417
2417
|
genInterpolation(node, context);
|
|
2418
2418
|
break;
|
|
2419
|
-
case 12:
|
|
2419
|
+
case "12":
|
|
2420
2420
|
genNode(node.codegenNode, context);
|
|
2421
2421
|
break;
|
|
2422
|
-
case 8:
|
|
2422
|
+
case "8":
|
|
2423
2423
|
genCompoundExpression(node, context);
|
|
2424
2424
|
break;
|
|
2425
|
-
case "
|
|
2425
|
+
case "3":
|
|
2426
2426
|
genComment(node, context);
|
|
2427
2427
|
break;
|
|
2428
|
-
case 13:
|
|
2428
|
+
case "13":
|
|
2429
2429
|
genVNodeCall(node, context);
|
|
2430
2430
|
break;
|
|
2431
|
-
case 14:
|
|
2431
|
+
case "14":
|
|
2432
2432
|
genCallExpression(node, context);
|
|
2433
2433
|
break;
|
|
2434
|
-
case 15:
|
|
2434
|
+
case "15":
|
|
2435
2435
|
genObjectExpression(node, context);
|
|
2436
2436
|
break;
|
|
2437
|
-
case 17:
|
|
2437
|
+
case "17":
|
|
2438
2438
|
genArrayExpression(node, context);
|
|
2439
2439
|
break;
|
|
2440
|
-
case 18:
|
|
2440
|
+
case "18":
|
|
2441
2441
|
genFunctionExpression(node, context);
|
|
2442
2442
|
break;
|
|
2443
|
-
case 19:
|
|
2443
|
+
case "19":
|
|
2444
2444
|
genConditionalExpression(node, context);
|
|
2445
2445
|
break;
|
|
2446
|
-
case 20:
|
|
2446
|
+
case "20":
|
|
2447
2447
|
genCacheExpression(node, context);
|
|
2448
2448
|
break;
|
|
2449
|
-
case 21:
|
|
2449
|
+
case "21":
|
|
2450
2450
|
genNodeList(node.body, context, true, false);
|
|
2451
2451
|
break;
|
|
2452
|
-
case 22:
|
|
2452
|
+
case "22":
|
|
2453
2453
|
genTemplateLiteral(node, context);
|
|
2454
2454
|
break;
|
|
2455
|
-
case 23:
|
|
2455
|
+
case "23":
|
|
2456
2456
|
genIfStatement(node, context);
|
|
2457
2457
|
break;
|
|
2458
|
-
case 24:
|
|
2458
|
+
case "24":
|
|
2459
2459
|
genAssignmentExpression(node, context);
|
|
2460
2460
|
break;
|
|
2461
|
-
case 25:
|
|
2461
|
+
case "25":
|
|
2462
2462
|
genSequenceExpression(node, context);
|
|
2463
2463
|
break;
|
|
2464
|
-
case 26:
|
|
2464
|
+
case "26":
|
|
2465
2465
|
genReturnStatement(node, context);
|
|
2466
2466
|
break;
|
|
2467
2467
|
}
|
|
@@ -2493,7 +2493,7 @@ function genCompoundExpression(node, context) {
|
|
|
2493
2493
|
}
|
|
2494
2494
|
function genExpressionAsPropertyKey(node, context) {
|
|
2495
2495
|
const { push } = context;
|
|
2496
|
-
if (node.type === 8) {
|
|
2496
|
+
if (node.type === "8") {
|
|
2497
2497
|
push(`[`);
|
|
2498
2498
|
genCompoundExpression(node, context);
|
|
2499
2499
|
push(`]`);
|
|
@@ -2574,7 +2574,7 @@ function genObjectExpression(node, context) {
|
|
|
2574
2574
|
push(`{}`, node);
|
|
2575
2575
|
return;
|
|
2576
2576
|
}
|
|
2577
|
-
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
2577
|
+
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== "4");
|
|
2578
2578
|
push(multilines ? `{` : `{ `);
|
|
2579
2579
|
multilines && indent();
|
|
2580
2580
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2636,7 +2636,7 @@ function genFunctionExpression(node, context) {
|
|
|
2636
2636
|
function genConditionalExpression(node, context) {
|
|
2637
2637
|
const { test, consequent, alternate, newline: needNewline } = node;
|
|
2638
2638
|
const { push, indent, deindent, newline } = context;
|
|
2639
|
-
if (test.type === 4) {
|
|
2639
|
+
if (test.type === "4") {
|
|
2640
2640
|
const needsParens = !isSimpleIdentifier(test.content);
|
|
2641
2641
|
needsParens && push(`(`);
|
|
2642
2642
|
genExpression(test, context);
|
|
@@ -2655,7 +2655,7 @@ function genConditionalExpression(node, context) {
|
|
|
2655
2655
|
needNewline && newline();
|
|
2656
2656
|
needNewline || push(` `);
|
|
2657
2657
|
push(`: `);
|
|
2658
|
-
const isNested = alternate.type === 19;
|
|
2658
|
+
const isNested = alternate.type === "19";
|
|
2659
2659
|
if (!isNested) {
|
|
2660
2660
|
context.indentLevel++;
|
|
2661
2661
|
}
|
|
@@ -2721,7 +2721,7 @@ function genIfStatement(node, context) {
|
|
|
2721
2721
|
push(`}`);
|
|
2722
2722
|
if (alternate) {
|
|
2723
2723
|
push(` else `);
|
|
2724
|
-
if (alternate.type === 23) {
|
|
2724
|
+
if (alternate.type === "23") {
|
|
2725
2725
|
genIfStatement(alternate, context);
|
|
2726
2726
|
} else {
|
|
2727
2727
|
push(`{`);
|
|
@@ -2990,18 +2990,18 @@ function isReferenced(node, parent, grandparent) {
|
|
|
2990
2990
|
|
|
2991
2991
|
const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
|
|
2992
2992
|
const transformExpression = (node, context) => {
|
|
2993
|
-
if (node.type === 5) {
|
|
2993
|
+
if (node.type === "5") {
|
|
2994
2994
|
node.content = processExpression(
|
|
2995
2995
|
node.content,
|
|
2996
2996
|
context
|
|
2997
2997
|
);
|
|
2998
|
-
} else if (node.type === "
|
|
2998
|
+
} else if (node.type === "1") {
|
|
2999
2999
|
for (let i = 0; i < node.props.length; i++) {
|
|
3000
3000
|
const dir = node.props[i];
|
|
3001
|
-
if (dir.type === 7 && dir.name !== "for") {
|
|
3001
|
+
if (dir.type === "7" && dir.name !== "for") {
|
|
3002
3002
|
const exp = dir.exp;
|
|
3003
3003
|
const arg = dir.arg;
|
|
3004
|
-
if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
|
|
3004
|
+
if (exp && exp.type === "4" && !(dir.name === "on" && arg)) {
|
|
3005
3005
|
dir.exp = processExpression(
|
|
3006
3006
|
exp,
|
|
3007
3007
|
context,
|
|
@@ -3009,7 +3009,7 @@ const transformExpression = (node, context) => {
|
|
|
3009
3009
|
dir.name === "slot"
|
|
3010
3010
|
);
|
|
3011
3011
|
}
|
|
3012
|
-
if (arg && arg.type === 4 && !arg.isStatic) {
|
|
3012
|
+
if (arg && arg.type === "4" && !arg.isStatic) {
|
|
3013
3013
|
dir.arg = processExpression(arg, context);
|
|
3014
3014
|
}
|
|
3015
3015
|
}
|
|
@@ -3085,14 +3085,14 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3085
3085
|
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
3086
3086
|
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
|
|
3087
3087
|
if (bindingMetadata[node.content] === "setup-const") {
|
|
3088
|
-
node.constType = 1;
|
|
3088
|
+
node.constType = "1";
|
|
3089
3089
|
}
|
|
3090
3090
|
node.content = rewriteIdentifier(rawExp);
|
|
3091
3091
|
} else if (!isScopeVarReference) {
|
|
3092
3092
|
if (isLiteral) {
|
|
3093
|
-
node.constType = 3;
|
|
3093
|
+
node.constType = "3";
|
|
3094
3094
|
} else {
|
|
3095
|
-
node.constType = 2;
|
|
3095
|
+
node.constType = "2";
|
|
3096
3096
|
}
|
|
3097
3097
|
}
|
|
3098
3098
|
return node;
|
|
@@ -3106,7 +3106,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3106
3106
|
} catch (e) {
|
|
3107
3107
|
context.onError(
|
|
3108
3108
|
createCompilerError(
|
|
3109
|
-
45,
|
|
3109
|
+
"45",
|
|
3110
3110
|
node.loc,
|
|
3111
3111
|
void 0,
|
|
3112
3112
|
e.message
|
|
@@ -3165,7 +3165,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3165
3165
|
start: advancePositionWithClone(node.loc.start, source2, start),
|
|
3166
3166
|
end: advancePositionWithClone(node.loc.start, source2, end)
|
|
3167
3167
|
},
|
|
3168
|
-
id.isConstant ? 3 : 0
|
|
3168
|
+
id.isConstant ? "3" : 0
|
|
3169
3169
|
)
|
|
3170
3170
|
);
|
|
3171
3171
|
if (i === ids.length - 1 && end < rawExp.length) {
|
|
@@ -3177,7 +3177,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3177
3177
|
ret = createCompoundExpression(children, node.loc);
|
|
3178
3178
|
} else {
|
|
3179
3179
|
ret = node;
|
|
3180
|
-
ret.constType = bailConstant ? 0 : 3;
|
|
3180
|
+
ret.constType = bailConstant ? 0 : "3";
|
|
3181
3181
|
}
|
|
3182
3182
|
ret.identifiers = Object.keys(knownIds);
|
|
3183
3183
|
return ret;
|
|
@@ -3194,7 +3194,7 @@ function canPrefix(id) {
|
|
|
3194
3194
|
function stringifyExpression(exp) {
|
|
3195
3195
|
if (shared.isString(exp)) {
|
|
3196
3196
|
return exp;
|
|
3197
|
-
} else if (exp.type === 4) {
|
|
3197
|
+
} else if (exp.type === "4") {
|
|
3198
3198
|
return exp.content;
|
|
3199
3199
|
} else {
|
|
3200
3200
|
return exp.children.map(stringifyExpression).join("");
|
|
@@ -3210,7 +3210,7 @@ const transformIf = createStructuralDirectiveTransform(
|
|
|
3210
3210
|
let key = 0;
|
|
3211
3211
|
while (i-- >= 0) {
|
|
3212
3212
|
const sibling = siblings[i];
|
|
3213
|
-
if (sibling && sibling.type === 9) {
|
|
3213
|
+
if (sibling && sibling.type === "9") {
|
|
3214
3214
|
key += sibling.branches.length;
|
|
3215
3215
|
}
|
|
3216
3216
|
}
|
|
@@ -3237,7 +3237,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3237
3237
|
if (dir.name !== "else" && (!dir.exp || !dir.exp.content.trim())) {
|
|
3238
3238
|
const loc = dir.exp ? dir.exp.loc : node.loc;
|
|
3239
3239
|
context.onError(
|
|
3240
|
-
createCompilerError(28, dir.loc)
|
|
3240
|
+
createCompilerError("28", dir.loc)
|
|
3241
3241
|
);
|
|
3242
3242
|
dir.exp = createSimpleExpression(`true`, false, loc);
|
|
3243
3243
|
}
|
|
@@ -3247,7 +3247,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3247
3247
|
if (dir.name === "if") {
|
|
3248
3248
|
const branch = createIfBranch(node, dir);
|
|
3249
3249
|
const ifNode = {
|
|
3250
|
-
type: 9,
|
|
3250
|
+
type: "9",
|
|
3251
3251
|
loc: node.loc,
|
|
3252
3252
|
branches: [branch]
|
|
3253
3253
|
};
|
|
@@ -3260,18 +3260,18 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3260
3260
|
let i = siblings.indexOf(node);
|
|
3261
3261
|
while (i-- >= -1) {
|
|
3262
3262
|
const sibling = siblings[i];
|
|
3263
|
-
if (sibling && sibling.type === "
|
|
3263
|
+
if (sibling && sibling.type === "3") {
|
|
3264
3264
|
context.removeNode(sibling);
|
|
3265
3265
|
continue;
|
|
3266
3266
|
}
|
|
3267
|
-
if (sibling && sibling.type === "
|
|
3267
|
+
if (sibling && sibling.type === "2" && !sibling.content.trim().length) {
|
|
3268
3268
|
context.removeNode(sibling);
|
|
3269
3269
|
continue;
|
|
3270
3270
|
}
|
|
3271
|
-
if (sibling && sibling.type === 9) {
|
|
3271
|
+
if (sibling && sibling.type === "9") {
|
|
3272
3272
|
if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
|
|
3273
3273
|
context.onError(
|
|
3274
|
-
createCompilerError(30, node.loc)
|
|
3274
|
+
createCompilerError("30", node.loc)
|
|
3275
3275
|
);
|
|
3276
3276
|
}
|
|
3277
3277
|
context.removeNode();
|
|
@@ -3283,7 +3283,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3283
3283
|
if (isSameKey(userKey, key)) {
|
|
3284
3284
|
context.onError(
|
|
3285
3285
|
createCompilerError(
|
|
3286
|
-
29,
|
|
3286
|
+
"29",
|
|
3287
3287
|
branch.userKey.loc
|
|
3288
3288
|
)
|
|
3289
3289
|
);
|
|
@@ -3299,7 +3299,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3299
3299
|
context.currentNode = null;
|
|
3300
3300
|
} else {
|
|
3301
3301
|
context.onError(
|
|
3302
|
-
createCompilerError(30, node.loc)
|
|
3302
|
+
createCompilerError("30", node.loc)
|
|
3303
3303
|
);
|
|
3304
3304
|
}
|
|
3305
3305
|
break;
|
|
@@ -3307,9 +3307,9 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3307
3307
|
}
|
|
3308
3308
|
}
|
|
3309
3309
|
function createIfBranch(node, dir) {
|
|
3310
|
-
const isTemplateIf = node.tagType === 3;
|
|
3310
|
+
const isTemplateIf = node.tagType === "3";
|
|
3311
3311
|
return {
|
|
3312
|
-
type: 10,
|
|
3312
|
+
type: "10",
|
|
3313
3313
|
loc: node.loc,
|
|
3314
3314
|
condition: dir.name === "else" ? void 0 : dir.exp,
|
|
3315
3315
|
children: isTemplateIf && !findDir(node, "for") ? node.children : [node],
|
|
@@ -3341,14 +3341,14 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3341
3341
|
`${keyIndex}`,
|
|
3342
3342
|
false,
|
|
3343
3343
|
locStub,
|
|
3344
|
-
2
|
|
3344
|
+
"2"
|
|
3345
3345
|
)
|
|
3346
3346
|
);
|
|
3347
3347
|
const { children } = branch;
|
|
3348
3348
|
const firstChild = children[0];
|
|
3349
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !== "
|
|
3349
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== "1";
|
|
3350
3350
|
if (needFragmentWrapper) {
|
|
3351
|
-
if (children.length === 1 && firstChild.type === 11) {
|
|
3351
|
+
if (children.length === 1 && firstChild.type === "11") {
|
|
3352
3352
|
const vnodeCall = firstChild.codegenNode;
|
|
3353
3353
|
injectProp(vnodeCall, keyProperty, context);
|
|
3354
3354
|
return vnodeCall;
|
|
@@ -3372,7 +3372,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3372
3372
|
} else {
|
|
3373
3373
|
const ret = firstChild.codegenNode;
|
|
3374
3374
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3375
|
-
if (vnodeCall.type === 13) {
|
|
3375
|
+
if (vnodeCall.type === "13") {
|
|
3376
3376
|
makeBlock(vnodeCall, context);
|
|
3377
3377
|
}
|
|
3378
3378
|
injectProp(vnodeCall, keyProperty, context);
|
|
@@ -3383,7 +3383,7 @@ function isSameKey(a, b) {
|
|
|
3383
3383
|
if (!a || a.type !== b.type) {
|
|
3384
3384
|
return false;
|
|
3385
3385
|
}
|
|
3386
|
-
if (a.type === 6) {
|
|
3386
|
+
if (a.type === "6") {
|
|
3387
3387
|
if (a.value.content !== b.value.content) {
|
|
3388
3388
|
return false;
|
|
3389
3389
|
}
|
|
@@ -3393,7 +3393,7 @@ function isSameKey(a, b) {
|
|
|
3393
3393
|
if (exp.type !== branchExp.type) {
|
|
3394
3394
|
return false;
|
|
3395
3395
|
}
|
|
3396
|
-
if (exp.type !== 4 || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
|
3396
|
+
if (exp.type !== "4" || exp.isStatic !== branchExp.isStatic || exp.content !== branchExp.content) {
|
|
3397
3397
|
return false;
|
|
3398
3398
|
}
|
|
3399
3399
|
}
|
|
@@ -3401,13 +3401,13 @@ function isSameKey(a, b) {
|
|
|
3401
3401
|
}
|
|
3402
3402
|
function getParentCondition(node) {
|
|
3403
3403
|
while (true) {
|
|
3404
|
-
if (node.type === 19) {
|
|
3405
|
-
if (node.alternate.type === 19) {
|
|
3404
|
+
if (node.type === "19") {
|
|
3405
|
+
if (node.alternate.type === "19") {
|
|
3406
3406
|
node = node.alternate;
|
|
3407
3407
|
} else {
|
|
3408
3408
|
return node;
|
|
3409
3409
|
}
|
|
3410
|
-
} else if (node.type === 20) {
|
|
3410
|
+
} else if (node.type === "20") {
|
|
3411
3411
|
node = node.value;
|
|
3412
3412
|
}
|
|
3413
3413
|
}
|
|
@@ -3424,7 +3424,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3424
3424
|
const isTemplate = isTemplateNode(node);
|
|
3425
3425
|
const memo = findDir(node, "memo");
|
|
3426
3426
|
const keyProp = findProp(node, `key`);
|
|
3427
|
-
const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
|
3427
|
+
const keyExp = keyProp && (keyProp.type === "6" ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
|
|
3428
3428
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3429
3429
|
if (isTemplate) {
|
|
3430
3430
|
if (memo) {
|
|
@@ -3433,14 +3433,14 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3433
3433
|
context
|
|
3434
3434
|
);
|
|
3435
3435
|
}
|
|
3436
|
-
if (keyProperty && keyProp.type !== 6) {
|
|
3436
|
+
if (keyProperty && keyProp.type !== "6") {
|
|
3437
3437
|
keyProperty.value = processExpression(
|
|
3438
3438
|
keyProperty.value,
|
|
3439
3439
|
context
|
|
3440
3440
|
);
|
|
3441
3441
|
}
|
|
3442
3442
|
}
|
|
3443
|
-
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
3443
|
+
const isStableFragment = forNode.source.type === "4" && forNode.source.constType > 0;
|
|
3444
3444
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
3445
3445
|
forNode.codegenNode = createVNodeCall(
|
|
3446
3446
|
context,
|
|
@@ -3460,12 +3460,12 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3460
3460
|
const { children } = forNode;
|
|
3461
3461
|
if (isTemplate) {
|
|
3462
3462
|
node.children.some((c) => {
|
|
3463
|
-
if (c.type === "
|
|
3463
|
+
if (c.type === "1") {
|
|
3464
3464
|
const key = findProp(c, "key");
|
|
3465
3465
|
if (key) {
|
|
3466
3466
|
context.onError(
|
|
3467
3467
|
createCompilerError(
|
|
3468
|
-
33,
|
|
3468
|
+
"33",
|
|
3469
3469
|
key.loc
|
|
3470
3470
|
)
|
|
3471
3471
|
);
|
|
@@ -3474,7 +3474,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3474
3474
|
}
|
|
3475
3475
|
});
|
|
3476
3476
|
}
|
|
3477
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !== "
|
|
3477
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== "1";
|
|
3478
3478
|
const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
|
3479
3479
|
if (slotOutlet) {
|
|
3480
3480
|
childBlock = slotOutlet.codegenNode;
|
|
@@ -3561,7 +3561,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3561
3561
|
function processFor(node, dir, context, processCodegen) {
|
|
3562
3562
|
if (!dir.exp) {
|
|
3563
3563
|
context.onError(
|
|
3564
|
-
createCompilerError(31, dir.loc)
|
|
3564
|
+
createCompilerError("31", dir.loc)
|
|
3565
3565
|
);
|
|
3566
3566
|
return;
|
|
3567
3567
|
}
|
|
@@ -3573,14 +3573,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3573
3573
|
);
|
|
3574
3574
|
if (!parseResult) {
|
|
3575
3575
|
context.onError(
|
|
3576
|
-
createCompilerError(32, dir.loc)
|
|
3576
|
+
createCompilerError("32", dir.loc)
|
|
3577
3577
|
);
|
|
3578
3578
|
return;
|
|
3579
3579
|
}
|
|
3580
3580
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3581
3581
|
const { source, value, key, index } = parseResult;
|
|
3582
3582
|
const forNode = {
|
|
3583
|
-
type: 11,
|
|
3583
|
+
type: "11",
|
|
3584
3584
|
loc: dir.loc,
|
|
3585
3585
|
source,
|
|
3586
3586
|
valueAlias: value,
|
|
@@ -3694,7 +3694,7 @@ function createParamsList(args) {
|
|
|
3694
3694
|
|
|
3695
3695
|
const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
3696
3696
|
const trackSlotScopes = (node, context) => {
|
|
3697
|
-
if (node.type === "
|
|
3697
|
+
if (node.type === "1" && (node.tagType === "1" || node.tagType === "3")) {
|
|
3698
3698
|
const vSlot = findDir(node, "slot");
|
|
3699
3699
|
if (vSlot) {
|
|
3700
3700
|
const slotProps = vSlot.exp;
|
|
@@ -3770,14 +3770,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3770
3770
|
const slotElement = children[i];
|
|
3771
3771
|
let slotDir;
|
|
3772
3772
|
if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
|
3773
|
-
if (slotElement.type !== "
|
|
3773
|
+
if (slotElement.type !== "3") {
|
|
3774
3774
|
implicitDefaultChildren.push(slotElement);
|
|
3775
3775
|
}
|
|
3776
3776
|
continue;
|
|
3777
3777
|
}
|
|
3778
3778
|
if (onComponentSlot) {
|
|
3779
3779
|
context.onError(
|
|
3780
|
-
createCompilerError(37, slotDir.loc)
|
|
3780
|
+
createCompilerError("37", slotDir.loc)
|
|
3781
3781
|
);
|
|
3782
3782
|
break;
|
|
3783
3783
|
}
|
|
@@ -3817,7 +3817,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3817
3817
|
let prev;
|
|
3818
3818
|
while (j--) {
|
|
3819
3819
|
prev = children[j];
|
|
3820
|
-
if (prev.type !== "
|
|
3820
|
+
if (prev.type !== "3") {
|
|
3821
3821
|
break;
|
|
3822
3822
|
}
|
|
3823
3823
|
}
|
|
@@ -3825,7 +3825,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3825
3825
|
children.splice(i, 1);
|
|
3826
3826
|
i--;
|
|
3827
3827
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
3828
|
-
while (conditional.alternate.type === 19) {
|
|
3828
|
+
while (conditional.alternate.type === "19") {
|
|
3829
3829
|
conditional = conditional.alternate;
|
|
3830
3830
|
}
|
|
3831
3831
|
conditional.alternate = vElse.exp ? createConditionalExpression(
|
|
@@ -3839,7 +3839,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3839
3839
|
) : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
|
3840
3840
|
} else {
|
|
3841
3841
|
context.onError(
|
|
3842
|
-
createCompilerError(30, vElse.loc)
|
|
3842
|
+
createCompilerError("30", vElse.loc)
|
|
3843
3843
|
);
|
|
3844
3844
|
}
|
|
3845
3845
|
} else if (vFor = findDir(slotElement, "for")) {
|
|
@@ -3859,7 +3859,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3859
3859
|
);
|
|
3860
3860
|
} else {
|
|
3861
3861
|
context.onError(
|
|
3862
|
-
createCompilerError(32, vFor.loc)
|
|
3862
|
+
createCompilerError("32", vFor.loc)
|
|
3863
3863
|
);
|
|
3864
3864
|
}
|
|
3865
3865
|
} else {
|
|
@@ -3867,7 +3867,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3867
3867
|
if (seenSlotNames.has(staticSlotName)) {
|
|
3868
3868
|
context.onError(
|
|
3869
3869
|
createCompilerError(
|
|
3870
|
-
38,
|
|
3870
|
+
"38",
|
|
3871
3871
|
dirLoc
|
|
3872
3872
|
)
|
|
3873
3873
|
);
|
|
@@ -3898,7 +3898,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3898
3898
|
if (hasNamedDefaultSlot) {
|
|
3899
3899
|
context.onError(
|
|
3900
3900
|
createCompilerError(
|
|
3901
|
-
39,
|
|
3901
|
+
"39",
|
|
3902
3902
|
implicitDefaultChildren[0].loc
|
|
3903
3903
|
)
|
|
3904
3904
|
);
|
|
@@ -3951,17 +3951,17 @@ function hasForwardedSlots(children) {
|
|
|
3951
3951
|
for (let i = 0; i < children.length; i++) {
|
|
3952
3952
|
const child = children[i];
|
|
3953
3953
|
switch (child.type) {
|
|
3954
|
-
case "
|
|
3955
|
-
if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
|
3954
|
+
case "1":
|
|
3955
|
+
if (child.tagType === "2" || hasForwardedSlots(child.children)) {
|
|
3956
3956
|
return true;
|
|
3957
3957
|
}
|
|
3958
3958
|
break;
|
|
3959
|
-
case 9:
|
|
3959
|
+
case "9":
|
|
3960
3960
|
if (hasForwardedSlots(child.branches))
|
|
3961
3961
|
return true;
|
|
3962
3962
|
break;
|
|
3963
|
-
case 10:
|
|
3964
|
-
case 11:
|
|
3963
|
+
case "10":
|
|
3964
|
+
case "11":
|
|
3965
3965
|
if (hasForwardedSlots(child.children))
|
|
3966
3966
|
return true;
|
|
3967
3967
|
break;
|
|
@@ -3970,20 +3970,20 @@ function hasForwardedSlots(children) {
|
|
|
3970
3970
|
return false;
|
|
3971
3971
|
}
|
|
3972
3972
|
function isNonWhitespaceContent(node) {
|
|
3973
|
-
if (node.type !== "
|
|
3973
|
+
if (node.type !== "2" && node.type !== "12")
|
|
3974
3974
|
return true;
|
|
3975
|
-
return node.type === "
|
|
3975
|
+
return node.type === "2" ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
|
3976
3976
|
}
|
|
3977
3977
|
|
|
3978
3978
|
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
3979
3979
|
const transformElement = (node, context) => {
|
|
3980
3980
|
return function postTransformElement() {
|
|
3981
3981
|
node = context.currentNode;
|
|
3982
|
-
if (!(node.type === "
|
|
3982
|
+
if (!(node.type === "1" && (node.tagType === "0" || node.tagType === "1"))) {
|
|
3983
3983
|
return;
|
|
3984
3984
|
}
|
|
3985
3985
|
const { tag, props } = node;
|
|
3986
|
-
const isComponent = node.tagType === 1;
|
|
3986
|
+
const isComponent = node.tagType === "1";
|
|
3987
3987
|
let vnodeTag = isComponent ? resolveComponentType(node, context) : `"${tag}"`;
|
|
3988
3988
|
const isDynamicComponent = shared.isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
|
|
3989
3989
|
let vnodeProps;
|
|
@@ -4037,11 +4037,11 @@ const transformElement = (node, context) => {
|
|
|
4037
4037
|
} else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
|
4038
4038
|
const child = node.children[0];
|
|
4039
4039
|
const type = child.type;
|
|
4040
|
-
const hasDynamicTextChild = type === 5 || type === 8;
|
|
4040
|
+
const hasDynamicTextChild = type === "5" || type === "8";
|
|
4041
4041
|
if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
|
4042
4042
|
patchFlag |= 1;
|
|
4043
4043
|
}
|
|
4044
|
-
if (hasDynamicTextChild || type === "
|
|
4044
|
+
if (hasDynamicTextChild || type === "2") {
|
|
4045
4045
|
vnodeChildren = child;
|
|
4046
4046
|
} else {
|
|
4047
4047
|
vnodeChildren = node.children;
|
|
@@ -4082,13 +4082,13 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4082
4082
|
"COMPILER_IS_ON_ELEMENT",
|
|
4083
4083
|
context
|
|
4084
4084
|
)) {
|
|
4085
|
-
const exp = isProp.type === 6 ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
|
4085
|
+
const exp = isProp.type === "6" ? isProp.value && createSimpleExpression(isProp.value.content, true) : isProp.exp;
|
|
4086
4086
|
if (exp) {
|
|
4087
4087
|
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
4088
4088
|
exp
|
|
4089
4089
|
]);
|
|
4090
4090
|
}
|
|
4091
|
-
} else if (isProp.type === 6 && isProp.value.content.startsWith("vue:")) {
|
|
4091
|
+
} else if (isProp.type === "6" && isProp.value.content.startsWith("vue:")) {
|
|
4092
4092
|
tag = isProp.value.content.slice(4);
|
|
4093
4093
|
}
|
|
4094
4094
|
}
|
|
@@ -4198,7 +4198,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4198
4198
|
if (isEventHandler && shared.isReservedProp(name)) {
|
|
4199
4199
|
hasVnodeHook = true;
|
|
4200
4200
|
}
|
|
4201
|
-
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
|
4201
|
+
if (value.type === "20" || (value.type === "4" || value.type === "8") && getConstantType(value, context) > 0) {
|
|
4202
4202
|
return;
|
|
4203
4203
|
}
|
|
4204
4204
|
if (name === "ref") {
|
|
@@ -4219,7 +4219,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4219
4219
|
};
|
|
4220
4220
|
for (let i = 0; i < props.length; i++) {
|
|
4221
4221
|
const prop = props[i];
|
|
4222
|
-
if (prop.type === 6) {
|
|
4222
|
+
if (prop.type === "6") {
|
|
4223
4223
|
const { loc, name, value } = prop;
|
|
4224
4224
|
let isStatic = true;
|
|
4225
4225
|
if (name === "ref") {
|
|
@@ -4272,7 +4272,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4272
4272
|
if (name === "slot") {
|
|
4273
4273
|
if (!isComponent) {
|
|
4274
4274
|
context.onError(
|
|
4275
|
-
createCompilerError(40, loc)
|
|
4275
|
+
createCompilerError("40", loc)
|
|
4276
4276
|
);
|
|
4277
4277
|
}
|
|
4278
4278
|
continue;
|
|
@@ -4322,7 +4322,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4322
4322
|
mergeArgs.push(exp);
|
|
4323
4323
|
} else {
|
|
4324
4324
|
pushMergeArg({
|
|
4325
|
-
type: 14,
|
|
4325
|
+
type: "14",
|
|
4326
4326
|
loc,
|
|
4327
4327
|
callee: context.helper(TO_HANDLERS),
|
|
4328
4328
|
arguments: isComponent ? [exp] : [exp, `true`]
|
|
@@ -4331,7 +4331,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4331
4331
|
} else {
|
|
4332
4332
|
context.onError(
|
|
4333
4333
|
createCompilerError(
|
|
4334
|
-
isVBind ? 34 : 35,
|
|
4334
|
+
isVBind ? "34" : "35",
|
|
4335
4335
|
loc
|
|
4336
4336
|
)
|
|
4337
4337
|
);
|
|
@@ -4400,7 +4400,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4400
4400
|
}
|
|
4401
4401
|
if (!context.inSSR && propsExpression) {
|
|
4402
4402
|
switch (propsExpression.type) {
|
|
4403
|
-
case 15:
|
|
4403
|
+
case "15":
|
|
4404
4404
|
let classKeyIndex = -1;
|
|
4405
4405
|
let styleKeyIndex = -1;
|
|
4406
4406
|
let hasDynamicKey = false;
|
|
@@ -4427,9 +4427,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4427
4427
|
}
|
|
4428
4428
|
if (styleProp && // the static style is compiled into an object,
|
|
4429
4429
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4430
|
-
(hasStyleBinding || styleProp.value.type === 4 && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
|
|
4430
|
+
(hasStyleBinding || styleProp.value.type === "4" && styleProp.value.content.trim()[0] === `[` || // v-bind:style and style both exist,
|
|
4431
4431
|
// v-bind:style with static literal object
|
|
4432
|
-
styleProp.value.type === 17)) {
|
|
4432
|
+
styleProp.value.type === "17")) {
|
|
4433
4433
|
styleProp.value = createCallExpression(
|
|
4434
4434
|
context.helper(NORMALIZE_STYLE),
|
|
4435
4435
|
[styleProp.value]
|
|
@@ -4442,7 +4442,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4442
4442
|
);
|
|
4443
4443
|
}
|
|
4444
4444
|
break;
|
|
4445
|
-
case 14:
|
|
4445
|
+
case "14":
|
|
4446
4446
|
break;
|
|
4447
4447
|
default:
|
|
4448
4448
|
propsExpression = createCallExpression(
|
|
@@ -4469,7 +4469,7 @@ function dedupeProperties(properties) {
|
|
|
4469
4469
|
const deduped = [];
|
|
4470
4470
|
for (let i = 0; i < properties.length; i++) {
|
|
4471
4471
|
const prop = properties[i];
|
|
4472
|
-
if (prop.key.type === 8 || !prop.key.isStatic) {
|
|
4472
|
+
if (prop.key.type === "8" || !prop.key.isStatic) {
|
|
4473
4473
|
deduped.push(prop);
|
|
4474
4474
|
continue;
|
|
4475
4475
|
}
|
|
@@ -4487,7 +4487,7 @@ function dedupeProperties(properties) {
|
|
|
4487
4487
|
return deduped;
|
|
4488
4488
|
}
|
|
4489
4489
|
function mergeAsArray(existing, incoming) {
|
|
4490
|
-
if (existing.value.type === 17) {
|
|
4490
|
+
if (existing.value.type === "17") {
|
|
4491
4491
|
existing.value.elements.push(incoming.value);
|
|
4492
4492
|
} else {
|
|
4493
4493
|
existing.value = createArrayExpression(
|
|
@@ -4589,7 +4589,7 @@ function processSlotOutlet(node, context) {
|
|
|
4589
4589
|
const nonNameProps = [];
|
|
4590
4590
|
for (let i = 0; i < node.props.length; i++) {
|
|
4591
4591
|
const p = node.props[i];
|
|
4592
|
-
if (p.type === 6) {
|
|
4592
|
+
if (p.type === "6") {
|
|
4593
4593
|
if (p.value) {
|
|
4594
4594
|
if (p.name === "name") {
|
|
4595
4595
|
slotName = JSON.stringify(p.value.content);
|
|
@@ -4622,7 +4622,7 @@ function processSlotOutlet(node, context) {
|
|
|
4622
4622
|
if (directives.length) {
|
|
4623
4623
|
context.onError(
|
|
4624
4624
|
createCompilerError(
|
|
4625
|
-
36,
|
|
4625
|
+
"36",
|
|
4626
4626
|
directives[0].loc
|
|
4627
4627
|
)
|
|
4628
4628
|
);
|
|
@@ -4638,16 +4638,16 @@ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+
|
|
|
4638
4638
|
const transformOn = (dir, node, context, augmentor) => {
|
|
4639
4639
|
const { loc, modifiers, arg } = dir;
|
|
4640
4640
|
if (!dir.exp && !modifiers.length) {
|
|
4641
|
-
context.onError(createCompilerError(35, loc));
|
|
4641
|
+
context.onError(createCompilerError("35", loc));
|
|
4642
4642
|
}
|
|
4643
4643
|
let eventName;
|
|
4644
|
-
if (arg.type === 4) {
|
|
4644
|
+
if (arg.type === "4") {
|
|
4645
4645
|
if (arg.isStatic) {
|
|
4646
4646
|
let rawName = arg.content;
|
|
4647
4647
|
if (rawName.startsWith("vue:")) {
|
|
4648
4648
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
4649
4649
|
}
|
|
4650
|
-
const eventString = node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
|
4650
|
+
const eventString = node.tagType !== "0" || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? (
|
|
4651
4651
|
// for non-element and vnode lifecycle event listeners, auto convert
|
|
4652
4652
|
// it to camelCase. See issue #2249
|
|
4653
4653
|
shared.toHandlerKey(shared.camelize(rawName))
|
|
@@ -4690,16 +4690,16 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4690
4690
|
shouldCache = context.cacheHandlers && // unnecessary to cache inside v-once
|
|
4691
4691
|
!context.inVOnce && // runtime constants don't need to be cached
|
|
4692
4692
|
// (this is analyzed by compileScript in SFC <script setup>)
|
|
4693
|
-
!(exp.type === 4 && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
|
|
4693
|
+
!(exp.type === "4" && exp.constType > 0) && // #1541 bail if this is a member exp handler passed to a component -
|
|
4694
4694
|
// we need to use the original function to preserve arity,
|
|
4695
4695
|
// e.g. <transition> relies on checking cb.length to determine
|
|
4696
4696
|
// transition end handling. Inline function is ok since its arity
|
|
4697
4697
|
// is preserved even when cached.
|
|
4698
|
-
!(isMemberExp && node.tagType === 1) && // bail if the function references closure variables (v-for, v-slot)
|
|
4698
|
+
!(isMemberExp && node.tagType === "1") && // bail if the function references closure variables (v-for, v-slot)
|
|
4699
4699
|
// it must be passed fresh to avoid stale values.
|
|
4700
4700
|
!hasScopeRef(exp, context.identifiers);
|
|
4701
4701
|
if (shouldCache && isMemberExp) {
|
|
4702
|
-
if (exp.type === 4) {
|
|
4702
|
+
if (exp.type === "4") {
|
|
4703
4703
|
exp.content = `${exp.content} && ${exp.content}(...args)`;
|
|
4704
4704
|
} else {
|
|
4705
4705
|
exp.children = [...exp.children, ` && `, ...exp.children, `(...args)`];
|
|
@@ -4737,14 +4737,14 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4737
4737
|
const transformBind = (dir, _node, context) => {
|
|
4738
4738
|
const { exp, modifiers, loc } = dir;
|
|
4739
4739
|
const arg = dir.arg;
|
|
4740
|
-
if (arg.type !== 4) {
|
|
4740
|
+
if (arg.type !== "4") {
|
|
4741
4741
|
arg.children.unshift(`(`);
|
|
4742
4742
|
arg.children.push(`) || ""`);
|
|
4743
4743
|
} else if (!arg.isStatic) {
|
|
4744
4744
|
arg.content = `${arg.content} || ""`;
|
|
4745
4745
|
}
|
|
4746
4746
|
if (modifiers.includes("camel")) {
|
|
4747
|
-
if (arg.type === 4) {
|
|
4747
|
+
if (arg.type === "4") {
|
|
4748
4748
|
if (arg.isStatic) {
|
|
4749
4749
|
arg.content = shared.camelize(arg.content);
|
|
4750
4750
|
} else {
|
|
@@ -4763,8 +4763,8 @@ const transformBind = (dir, _node, context) => {
|
|
|
4763
4763
|
injectPrefix(arg, "^");
|
|
4764
4764
|
}
|
|
4765
4765
|
}
|
|
4766
|
-
if (!exp || exp.type === 4 && !exp.content.trim()) {
|
|
4767
|
-
context.onError(createCompilerError(34, loc));
|
|
4766
|
+
if (!exp || exp.type === "4" && !exp.content.trim()) {
|
|
4767
|
+
context.onError(createCompilerError("34", loc));
|
|
4768
4768
|
return {
|
|
4769
4769
|
props: [createObjectProperty(arg, createSimpleExpression("", true, loc))]
|
|
4770
4770
|
};
|
|
@@ -4774,7 +4774,7 @@ const transformBind = (dir, _node, context) => {
|
|
|
4774
4774
|
};
|
|
4775
4775
|
};
|
|
4776
4776
|
const injectPrefix = (arg, prefix) => {
|
|
4777
|
-
if (arg.type === 4) {
|
|
4777
|
+
if (arg.type === "4") {
|
|
4778
4778
|
if (arg.isStatic) {
|
|
4779
4779
|
arg.content = prefix + arg.content;
|
|
4780
4780
|
} else {
|
|
@@ -4787,7 +4787,7 @@ const injectPrefix = (arg, prefix) => {
|
|
|
4787
4787
|
};
|
|
4788
4788
|
|
|
4789
4789
|
const transformText = (node, context) => {
|
|
4790
|
-
if (node.type === 0 || node.type === "
|
|
4790
|
+
if (node.type === "0" || node.type === "1" || node.type === "11" || node.type === "10") {
|
|
4791
4791
|
return () => {
|
|
4792
4792
|
const children = node.children;
|
|
4793
4793
|
let currentContainer = void 0;
|
|
@@ -4819,13 +4819,13 @@ const transformText = (node, context) => {
|
|
|
4819
4819
|
// as-is since the runtime has dedicated fast path for this by directly
|
|
4820
4820
|
// setting textContent of the element.
|
|
4821
4821
|
// for component root it's always normalized anyway.
|
|
4822
|
-
children.length === 1 && (node.type === 0 || node.type === "
|
|
4822
|
+
children.length === 1 && (node.type === "0" || node.type === "1" && node.tagType === "0" && // #3756
|
|
4823
4823
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
4824
4824
|
// we need to avoid setting textContent of the element at runtime
|
|
4825
4825
|
// to avoid accidentally overwriting the DOM elements added
|
|
4826
4826
|
// by the user through custom directives.
|
|
4827
4827
|
!node.props.find(
|
|
4828
|
-
(p) => p.type === 7 && !context.directiveTransforms[p.name]
|
|
4828
|
+
(p) => p.type === "7" && !context.directiveTransforms[p.name]
|
|
4829
4829
|
) && // in compat mode, <template> tags with no special directives
|
|
4830
4830
|
// will be rendered as a fragment so its children must be
|
|
4831
4831
|
// converted into vnodes.
|
|
@@ -4834,9 +4834,9 @@ const transformText = (node, context) => {
|
|
|
4834
4834
|
}
|
|
4835
4835
|
for (let i = 0; i < children.length; i++) {
|
|
4836
4836
|
const child = children[i];
|
|
4837
|
-
if (isText$1(child) || child.type === 8) {
|
|
4837
|
+
if (isText$1(child) || child.type === "8") {
|
|
4838
4838
|
const callArgs = [];
|
|
4839
|
-
if (child.type !== "
|
|
4839
|
+
if (child.type !== "2" || child.content !== " ") {
|
|
4840
4840
|
callArgs.push(child);
|
|
4841
4841
|
}
|
|
4842
4842
|
if (!context.ssr && getConstantType(child, context) === 0) {
|
|
@@ -4845,7 +4845,7 @@ const transformText = (node, context) => {
|
|
|
4845
4845
|
);
|
|
4846
4846
|
}
|
|
4847
4847
|
children[i] = {
|
|
4848
|
-
type: 12,
|
|
4848
|
+
type: "12",
|
|
4849
4849
|
content: child,
|
|
4850
4850
|
loc: child.loc,
|
|
4851
4851
|
codegenNode: createCallExpression(
|
|
@@ -4861,7 +4861,7 @@ const transformText = (node, context) => {
|
|
|
4861
4861
|
|
|
4862
4862
|
const seen$1 = /* @__PURE__ */ new WeakSet();
|
|
4863
4863
|
const transformOnce = (node, context) => {
|
|
4864
|
-
if (node.type === "
|
|
4864
|
+
if (node.type === "1" && findDir(node, "once", true)) {
|
|
4865
4865
|
if (seen$1.has(node) || context.inVOnce) {
|
|
4866
4866
|
return;
|
|
4867
4867
|
}
|
|
@@ -4886,27 +4886,27 @@ const transformModel = (dir, node, context) => {
|
|
|
4886
4886
|
const { exp, arg } = dir;
|
|
4887
4887
|
if (!exp) {
|
|
4888
4888
|
context.onError(
|
|
4889
|
-
createCompilerError(41, dir.loc)
|
|
4889
|
+
createCompilerError("41", dir.loc)
|
|
4890
4890
|
);
|
|
4891
4891
|
return createTransformProps();
|
|
4892
4892
|
}
|
|
4893
4893
|
const rawExp = exp.loc.source;
|
|
4894
|
-
const expString = exp.type === 4 ? exp.content : rawExp;
|
|
4894
|
+
const expString = exp.type === "4" ? exp.content : rawExp;
|
|
4895
4895
|
const bindingType = context.bindingMetadata[rawExp];
|
|
4896
4896
|
if (bindingType === "props" || bindingType === "props-aliased") {
|
|
4897
|
-
context.onError(createCompilerError(44, exp.loc));
|
|
4897
|
+
context.onError(createCompilerError("44", exp.loc));
|
|
4898
4898
|
return createTransformProps();
|
|
4899
4899
|
}
|
|
4900
4900
|
const maybeRef = context.inline && (bindingType === "setup-let" || bindingType === "setup-ref" || bindingType === "setup-maybe-ref");
|
|
4901
4901
|
if (!expString.trim() || !isMemberExpression(expString, context) && !maybeRef) {
|
|
4902
4902
|
context.onError(
|
|
4903
|
-
createCompilerError(42, exp.loc)
|
|
4903
|
+
createCompilerError("42", exp.loc)
|
|
4904
4904
|
);
|
|
4905
4905
|
return createTransformProps();
|
|
4906
4906
|
}
|
|
4907
4907
|
if (context.prefixIdentifiers && isSimpleIdentifier(expString) && context.identifiers[expString]) {
|
|
4908
4908
|
context.onError(
|
|
4909
|
-
createCompilerError(43, exp.loc)
|
|
4909
|
+
createCompilerError("43", exp.loc)
|
|
4910
4910
|
);
|
|
4911
4911
|
return createTransformProps();
|
|
4912
4912
|
}
|
|
@@ -4945,7 +4945,7 @@ const transformModel = (dir, node, context) => {
|
|
|
4945
4945
|
if (context.prefixIdentifiers && !context.inVOnce && context.cacheHandlers && !hasScopeRef(exp, context.identifiers)) {
|
|
4946
4946
|
props[1].value = context.cache(props[1].value);
|
|
4947
4947
|
}
|
|
4948
|
-
if (dir.modifiers.length && node.tagType === 1) {
|
|
4948
|
+
if (dir.modifiers.length && node.tagType === "1") {
|
|
4949
4949
|
const modifiers = dir.modifiers.map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
|
|
4950
4950
|
const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
|
|
4951
4951
|
props.push(
|
|
@@ -4955,7 +4955,7 @@ const transformModel = (dir, node, context) => {
|
|
|
4955
4955
|
`{ ${modifiers} }`,
|
|
4956
4956
|
false,
|
|
4957
4957
|
dir.loc,
|
|
4958
|
-
2
|
|
4958
|
+
"2"
|
|
4959
4959
|
)
|
|
4960
4960
|
)
|
|
4961
4961
|
);
|
|
@@ -4971,30 +4971,30 @@ const transformFilter = (node, context) => {
|
|
|
4971
4971
|
if (!isCompatEnabled("COMPILER_FILTER", context)) {
|
|
4972
4972
|
return;
|
|
4973
4973
|
}
|
|
4974
|
-
if (node.type === 5) {
|
|
4974
|
+
if (node.type === "5") {
|
|
4975
4975
|
rewriteFilter(node.content, context);
|
|
4976
4976
|
}
|
|
4977
|
-
if (node.type === "
|
|
4977
|
+
if (node.type === "1") {
|
|
4978
4978
|
node.props.forEach((prop) => {
|
|
4979
|
-
if (prop.type === 7 && prop.name !== "for" && prop.exp) {
|
|
4979
|
+
if (prop.type === "7" && prop.name !== "for" && prop.exp) {
|
|
4980
4980
|
rewriteFilter(prop.exp, context);
|
|
4981
4981
|
}
|
|
4982
4982
|
});
|
|
4983
4983
|
}
|
|
4984
4984
|
};
|
|
4985
4985
|
function rewriteFilter(node, context) {
|
|
4986
|
-
if (node.type === 4) {
|
|
4986
|
+
if (node.type === "4") {
|
|
4987
4987
|
parseFilter(node, context);
|
|
4988
4988
|
} else {
|
|
4989
4989
|
for (let i = 0; i < node.children.length; i++) {
|
|
4990
4990
|
const child = node.children[i];
|
|
4991
4991
|
if (typeof child !== "object")
|
|
4992
4992
|
continue;
|
|
4993
|
-
if (child.type === 4) {
|
|
4993
|
+
if (child.type === "4") {
|
|
4994
4994
|
parseFilter(child, context);
|
|
4995
|
-
} else if (child.type === 8) {
|
|
4995
|
+
} else if (child.type === "8") {
|
|
4996
4996
|
rewriteFilter(node, context);
|
|
4997
|
-
} else if (child.type === 5) {
|
|
4997
|
+
} else if (child.type === "5") {
|
|
4998
4998
|
rewriteFilter(child.content, context);
|
|
4999
4999
|
}
|
|
5000
5000
|
}
|
|
@@ -5110,7 +5110,7 @@ function wrapFilter(exp, filter, context) {
|
|
|
5110
5110
|
|
|
5111
5111
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
5112
5112
|
const transformMemo = (node, context) => {
|
|
5113
|
-
if (node.type === "
|
|
5113
|
+
if (node.type === "1") {
|
|
5114
5114
|
const dir = findDir(node, "memo");
|
|
5115
5115
|
if (!dir || seen.has(node)) {
|
|
5116
5116
|
return;
|
|
@@ -5118,8 +5118,8 @@ const transformMemo = (node, context) => {
|
|
|
5118
5118
|
seen.add(node);
|
|
5119
5119
|
return () => {
|
|
5120
5120
|
const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
|
5121
|
-
if (codegenNode && codegenNode.type === 13) {
|
|
5122
|
-
if (node.tagType !== 1) {
|
|
5121
|
+
if (codegenNode && codegenNode.type === "13") {
|
|
5122
|
+
if (node.tagType !== "1") {
|
|
5123
5123
|
makeBlock(codegenNode, context);
|
|
5124
5124
|
}
|
|
5125
5125
|
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
@@ -5163,10 +5163,10 @@ function baseCompile(template, options = {}) {
|
|
|
5163
5163
|
const isModuleMode = options.mode === "module";
|
|
5164
5164
|
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
5165
5165
|
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
5166
|
-
onError(createCompilerError(49));
|
|
5166
|
+
onError(createCompilerError("49"));
|
|
5167
5167
|
}
|
|
5168
5168
|
if (options.scopeId && !isModuleMode) {
|
|
5169
|
-
onError(createCompilerError(50));
|
|
5169
|
+
onError(createCompilerError("50"));
|
|
5170
5170
|
}
|
|
5171
5171
|
const ast = shared.isString(template) ? baseParse(template, options) : template;
|
|
5172
5172
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|