@vue/compiler-core 3.2.37 → 3.2.38
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 +548 -535
- package/dist/compiler-core.cjs.prod.js +527 -514
- package/dist/compiler-core.esm-bundler.js +517 -504
- package/package.json +2 -2
|
@@ -23,65 +23,65 @@ function createCompilerError(code, loc, messages, additionalMessage) {
|
|
|
23
23
|
}
|
|
24
24
|
const errorMessages = {
|
|
25
25
|
// parse errors
|
|
26
|
-
[0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
|
|
27
|
-
[1 /* CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
|
|
28
|
-
[2 /* DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
|
|
29
|
-
[3 /* END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
|
|
30
|
-
[4 /* END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
|
|
31
|
-
[5 /* EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
|
|
32
|
-
[6 /* EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
|
|
33
|
-
[7 /* EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
|
|
34
|
-
[8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
|
|
35
|
-
[9 /* EOF_IN_TAG */]: 'Unexpected EOF in tag.',
|
|
36
|
-
[10 /* INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
|
|
37
|
-
[11 /* INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
|
|
38
|
-
[12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '<' to print '<'.",
|
|
39
|
-
[13 /* MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
|
|
40
|
-
[14 /* MISSING_END_TAG_NAME */]: 'End tag name was expected.',
|
|
41
|
-
[15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
|
|
42
|
-
[16 /* NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
|
|
43
|
-
[17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
|
44
|
-
[18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
|
45
|
-
[19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
|
|
46
|
-
[21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
|
|
47
|
-
[20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
|
|
48
|
-
[22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
|
|
26
|
+
[0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
|
|
27
|
+
[1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
|
|
28
|
+
[2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
|
|
29
|
+
[3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
|
|
30
|
+
[4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
|
|
31
|
+
[5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
|
|
32
|
+
[6 /* ErrorCodes.EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
|
|
33
|
+
[7 /* ErrorCodes.EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
|
|
34
|
+
[8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
|
|
35
|
+
[9 /* ErrorCodes.EOF_IN_TAG */]: 'Unexpected EOF in tag.',
|
|
36
|
+
[10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
|
|
37
|
+
[11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
|
|
38
|
+
[12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '<' to print '<'.",
|
|
39
|
+
[13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
|
|
40
|
+
[14 /* ErrorCodes.MISSING_END_TAG_NAME */]: 'End tag name was expected.',
|
|
41
|
+
[15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
|
|
42
|
+
[16 /* ErrorCodes.NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
|
|
43
|
+
[17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
|
44
|
+
[18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
|
45
|
+
[19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
|
|
46
|
+
[21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
|
|
47
|
+
[20 /* ErrorCodes.UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
|
|
48
|
+
[22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
|
|
49
49
|
// Vue-specific parse errors
|
|
50
|
-
[23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
|
|
51
|
-
[24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
|
|
52
|
-
[25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
|
|
53
|
-
[27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
|
|
50
|
+
[23 /* ErrorCodes.X_INVALID_END_TAG */]: 'Invalid end tag.',
|
|
51
|
+
[24 /* ErrorCodes.X_MISSING_END_TAG */]: 'Element is missing end tag.',
|
|
52
|
+
[25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
|
|
53
|
+
[27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
|
|
54
54
|
'Note that dynamic directive argument cannot contain spaces.',
|
|
55
|
-
[26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
|
|
55
|
+
[26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
|
|
56
56
|
// transform errors
|
|
57
|
-
[28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
|
|
58
|
-
[29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
|
|
59
|
-
[30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
60
|
-
[31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
|
|
61
|
-
[32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
|
|
62
|
-
[33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
|
|
63
|
-
[34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
|
|
64
|
-
[35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
|
|
65
|
-
[36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
|
|
66
|
-
[37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
|
|
57
|
+
[28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
|
|
58
|
+
[29 /* ErrorCodes.X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
|
|
59
|
+
[30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
60
|
+
[31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
|
|
61
|
+
[32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
|
|
62
|
+
[33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
|
|
63
|
+
[34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
|
|
64
|
+
[35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
|
|
65
|
+
[36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
|
|
66
|
+
[37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
|
|
67
67
|
`When there are multiple named slots, all slots should use <template> ` +
|
|
68
68
|
`syntax to avoid scope ambiguity.`,
|
|
69
|
-
[38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
|
|
70
|
-
[39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
|
|
69
|
+
[38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
|
|
70
|
+
[39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
|
|
71
71
|
`default slot. These children will be ignored.`,
|
|
72
|
-
[40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
|
|
73
|
-
[41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
|
|
74
|
-
[42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
|
|
75
|
-
[43 /* X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
76
|
-
[44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
|
|
77
|
-
[45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
|
|
72
|
+
[40 /* ErrorCodes.X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
|
|
73
|
+
[41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
|
|
74
|
+
[42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
|
|
75
|
+
[43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
76
|
+
[44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
|
|
77
|
+
[45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
|
|
78
78
|
// generic errors
|
|
79
|
-
[46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
80
|
-
[47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
|
|
81
|
-
[48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
82
|
-
[49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
|
|
79
|
+
[46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
80
|
+
[47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
|
|
81
|
+
[48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
82
|
+
[49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
|
|
83
83
|
// just to fulfill types
|
|
84
|
-
[50 /* __EXTEND_POINT__ */]: ``
|
|
84
|
+
[50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
const FRAGMENT = Symbol(`Fragment` );
|
|
@@ -184,7 +184,7 @@ const locStub = {
|
|
|
184
184
|
};
|
|
185
185
|
function createRoot(children, loc = locStub) {
|
|
186
186
|
return {
|
|
187
|
-
type: 0 /* ROOT */,
|
|
187
|
+
type: 0 /* NodeTypes.ROOT */,
|
|
188
188
|
children,
|
|
189
189
|
helpers: [],
|
|
190
190
|
components: [],
|
|
@@ -211,7 +211,7 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
return {
|
|
214
|
-
type: 13 /* VNODE_CALL */,
|
|
214
|
+
type: 13 /* NodeTypes.VNODE_CALL */,
|
|
215
215
|
tag,
|
|
216
216
|
props,
|
|
217
217
|
children,
|
|
@@ -226,38 +226,38 @@ function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps,
|
|
|
226
226
|
}
|
|
227
227
|
function createArrayExpression(elements, loc = locStub) {
|
|
228
228
|
return {
|
|
229
|
-
type: 17 /* JS_ARRAY_EXPRESSION */,
|
|
229
|
+
type: 17 /* NodeTypes.JS_ARRAY_EXPRESSION */,
|
|
230
230
|
loc,
|
|
231
231
|
elements
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
function createObjectExpression(properties, loc = locStub) {
|
|
235
235
|
return {
|
|
236
|
-
type: 15 /* JS_OBJECT_EXPRESSION */,
|
|
236
|
+
type: 15 /* NodeTypes.JS_OBJECT_EXPRESSION */,
|
|
237
237
|
loc,
|
|
238
238
|
properties
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
function createObjectProperty(key, value) {
|
|
242
242
|
return {
|
|
243
|
-
type: 16 /* JS_PROPERTY */,
|
|
243
|
+
type: 16 /* NodeTypes.JS_PROPERTY */,
|
|
244
244
|
loc: locStub,
|
|
245
245
|
key: shared.isString(key) ? createSimpleExpression(key, true) : key,
|
|
246
246
|
value
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
|
-
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
|
|
249
|
+
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
250
250
|
return {
|
|
251
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
251
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
252
252
|
loc,
|
|
253
253
|
content,
|
|
254
254
|
isStatic,
|
|
255
|
-
constType: isStatic ? 3 /* CAN_STRINGIFY */ : constType
|
|
255
|
+
constType: isStatic ? 3 /* ConstantTypes.CAN_STRINGIFY */ : constType
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
258
|
function createInterpolation(content, loc) {
|
|
259
259
|
return {
|
|
260
|
-
type: 5 /* INTERPOLATION */,
|
|
260
|
+
type: 5 /* NodeTypes.INTERPOLATION */,
|
|
261
261
|
loc,
|
|
262
262
|
content: shared.isString(content)
|
|
263
263
|
? createSimpleExpression(content, false, loc)
|
|
@@ -266,14 +266,14 @@ function createInterpolation(content, loc) {
|
|
|
266
266
|
}
|
|
267
267
|
function createCompoundExpression(children, loc = locStub) {
|
|
268
268
|
return {
|
|
269
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
269
|
+
type: 8 /* NodeTypes.COMPOUND_EXPRESSION */,
|
|
270
270
|
loc,
|
|
271
271
|
children
|
|
272
272
|
};
|
|
273
273
|
}
|
|
274
274
|
function createCallExpression(callee, args = [], loc = locStub) {
|
|
275
275
|
return {
|
|
276
|
-
type: 14 /* JS_CALL_EXPRESSION */,
|
|
276
|
+
type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
|
|
277
277
|
loc,
|
|
278
278
|
callee,
|
|
279
279
|
arguments: args
|
|
@@ -281,7 +281,7 @@ function createCallExpression(callee, args = [], loc = locStub) {
|
|
|
281
281
|
}
|
|
282
282
|
function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
|
|
283
283
|
return {
|
|
284
|
-
type: 18 /* JS_FUNCTION_EXPRESSION */,
|
|
284
|
+
type: 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */,
|
|
285
285
|
params,
|
|
286
286
|
returns,
|
|
287
287
|
newline,
|
|
@@ -291,7 +291,7 @@ function createFunctionExpression(params, returns = undefined, newline = false,
|
|
|
291
291
|
}
|
|
292
292
|
function createConditionalExpression(test, consequent, alternate, newline = true) {
|
|
293
293
|
return {
|
|
294
|
-
type: 19 /* JS_CONDITIONAL_EXPRESSION */,
|
|
294
|
+
type: 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */,
|
|
295
295
|
test,
|
|
296
296
|
consequent,
|
|
297
297
|
alternate,
|
|
@@ -301,7 +301,7 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
301
301
|
}
|
|
302
302
|
function createCacheExpression(index, value, isVNode = false) {
|
|
303
303
|
return {
|
|
304
|
-
type: 20 /* JS_CACHE_EXPRESSION */,
|
|
304
|
+
type: 20 /* NodeTypes.JS_CACHE_EXPRESSION */,
|
|
305
305
|
index,
|
|
306
306
|
value,
|
|
307
307
|
isVNode,
|
|
@@ -310,21 +310,21 @@ function createCacheExpression(index, value, isVNode = false) {
|
|
|
310
310
|
}
|
|
311
311
|
function createBlockStatement(body) {
|
|
312
312
|
return {
|
|
313
|
-
type: 21 /* JS_BLOCK_STATEMENT */,
|
|
313
|
+
type: 21 /* NodeTypes.JS_BLOCK_STATEMENT */,
|
|
314
314
|
body,
|
|
315
315
|
loc: locStub
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
318
|
function createTemplateLiteral(elements) {
|
|
319
319
|
return {
|
|
320
|
-
type: 22 /* JS_TEMPLATE_LITERAL */,
|
|
320
|
+
type: 22 /* NodeTypes.JS_TEMPLATE_LITERAL */,
|
|
321
321
|
elements,
|
|
322
322
|
loc: locStub
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
function createIfStatement(test, consequent, alternate) {
|
|
326
326
|
return {
|
|
327
|
-
type: 23 /* JS_IF_STATEMENT */,
|
|
327
|
+
type: 23 /* NodeTypes.JS_IF_STATEMENT */,
|
|
328
328
|
test,
|
|
329
329
|
consequent,
|
|
330
330
|
alternate,
|
|
@@ -333,7 +333,7 @@ function createIfStatement(test, consequent, alternate) {
|
|
|
333
333
|
}
|
|
334
334
|
function createAssignmentExpression(left, right) {
|
|
335
335
|
return {
|
|
336
|
-
type: 24 /* JS_ASSIGNMENT_EXPRESSION */,
|
|
336
|
+
type: 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */,
|
|
337
337
|
left,
|
|
338
338
|
right,
|
|
339
339
|
loc: locStub
|
|
@@ -341,20 +341,20 @@ function createAssignmentExpression(left, right) {
|
|
|
341
341
|
}
|
|
342
342
|
function createSequenceExpression(expressions) {
|
|
343
343
|
return {
|
|
344
|
-
type: 25 /* JS_SEQUENCE_EXPRESSION */,
|
|
344
|
+
type: 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */,
|
|
345
345
|
expressions,
|
|
346
346
|
loc: locStub
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
349
|
function createReturnStatement(returns) {
|
|
350
350
|
return {
|
|
351
|
-
type: 26 /* JS_RETURN_STATEMENT */,
|
|
351
|
+
type: 26 /* NodeTypes.JS_RETURN_STATEMENT */,
|
|
352
352
|
returns,
|
|
353
353
|
loc: locStub
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
const isStaticExp = (p) => p.type === 4 /* SIMPLE_EXPRESSION */ && p.isStatic;
|
|
357
|
+
const isStaticExp = (p) => p.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && p.isStatic;
|
|
358
358
|
const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
|
|
359
359
|
function isCoreComponent(tag) {
|
|
360
360
|
if (isBuiltInType(tag, 'Teleport')) {
|
|
@@ -384,7 +384,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
|
|
384
384
|
const isMemberExpressionBrowser = (path) => {
|
|
385
385
|
// remove whitespaces around . or [ first
|
|
386
386
|
path = path.trim().replace(whitespaceRE, s => s.trim());
|
|
387
|
-
let state = 0 /* inMemberExp */;
|
|
387
|
+
let state = 0 /* MemberExpLexState.inMemberExp */;
|
|
388
388
|
let stateStack = [];
|
|
389
389
|
let currentOpenBracketCount = 0;
|
|
390
390
|
let currentOpenParensCount = 0;
|
|
@@ -392,25 +392,25 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
392
392
|
for (let i = 0; i < path.length; i++) {
|
|
393
393
|
const char = path.charAt(i);
|
|
394
394
|
switch (state) {
|
|
395
|
-
case 0 /* inMemberExp */:
|
|
395
|
+
case 0 /* MemberExpLexState.inMemberExp */:
|
|
396
396
|
if (char === '[') {
|
|
397
397
|
stateStack.push(state);
|
|
398
|
-
state = 1 /* inBrackets */;
|
|
398
|
+
state = 1 /* MemberExpLexState.inBrackets */;
|
|
399
399
|
currentOpenBracketCount++;
|
|
400
400
|
}
|
|
401
401
|
else if (char === '(') {
|
|
402
402
|
stateStack.push(state);
|
|
403
|
-
state = 2 /* inParens */;
|
|
403
|
+
state = 2 /* MemberExpLexState.inParens */;
|
|
404
404
|
currentOpenParensCount++;
|
|
405
405
|
}
|
|
406
406
|
else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
|
407
407
|
return false;
|
|
408
408
|
}
|
|
409
409
|
break;
|
|
410
|
-
case 1 /* inBrackets */:
|
|
410
|
+
case 1 /* MemberExpLexState.inBrackets */:
|
|
411
411
|
if (char === `'` || char === `"` || char === '`') {
|
|
412
412
|
stateStack.push(state);
|
|
413
|
-
state = 3 /* inString */;
|
|
413
|
+
state = 3 /* MemberExpLexState.inString */;
|
|
414
414
|
currentStringType = char;
|
|
415
415
|
}
|
|
416
416
|
else if (char === `[`) {
|
|
@@ -422,10 +422,10 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
break;
|
|
425
|
-
case 2 /* inParens */:
|
|
425
|
+
case 2 /* MemberExpLexState.inParens */:
|
|
426
426
|
if (char === `'` || char === `"` || char === '`') {
|
|
427
427
|
stateStack.push(state);
|
|
428
|
-
state = 3 /* inString */;
|
|
428
|
+
state = 3 /* MemberExpLexState.inString */;
|
|
429
429
|
currentStringType = char;
|
|
430
430
|
}
|
|
431
431
|
else if (char === `(`) {
|
|
@@ -441,7 +441,7 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
break;
|
|
444
|
-
case 3 /* inString */:
|
|
444
|
+
case 3 /* MemberExpLexState.inString */:
|
|
445
445
|
if (char === currentStringType) {
|
|
446
446
|
state = stateStack.pop();
|
|
447
447
|
currentStringType = null;
|
|
@@ -511,7 +511,7 @@ function assert(condition, msg) {
|
|
|
511
511
|
function findDir(node, name, allowEmpty = false) {
|
|
512
512
|
for (let i = 0; i < node.props.length; i++) {
|
|
513
513
|
const p = node.props[i];
|
|
514
|
-
if (p.type === 7 /* DIRECTIVE */ &&
|
|
514
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
515
515
|
(allowEmpty || p.exp) &&
|
|
516
516
|
(shared.isString(name) ? p.name === name : name.test(p.name))) {
|
|
517
517
|
return p;
|
|
@@ -521,7 +521,7 @@ function findDir(node, name, allowEmpty = false) {
|
|
|
521
521
|
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
522
522
|
for (let i = 0; i < node.props.length; i++) {
|
|
523
523
|
const p = node.props[i];
|
|
524
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
524
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
525
525
|
if (dynamicOnly)
|
|
526
526
|
continue;
|
|
527
527
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
@@ -539,24 +539,24 @@ function isStaticArgOf(arg, name) {
|
|
|
539
539
|
return !!(arg && isStaticExp(arg) && arg.content === name);
|
|
540
540
|
}
|
|
541
541
|
function hasDynamicKeyVBind(node) {
|
|
542
|
-
return node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
|
|
542
|
+
return node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
543
543
|
p.name === 'bind' &&
|
|
544
544
|
(!p.arg || // v-bind="obj"
|
|
545
|
-
p.arg.type !== 4 /* SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
|
|
545
|
+
p.arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
|
|
546
546
|
!p.arg.isStatic) // v-bind:[foo]
|
|
547
547
|
);
|
|
548
548
|
}
|
|
549
549
|
function isText(node) {
|
|
550
|
-
return node.type === 5 /* INTERPOLATION */ || node.type === 2 /* TEXT */;
|
|
550
|
+
return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
|
|
551
551
|
}
|
|
552
552
|
function isVSlot(p) {
|
|
553
|
-
return p.type === 7 /* DIRECTIVE */ && p.name === 'slot';
|
|
553
|
+
return p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'slot';
|
|
554
554
|
}
|
|
555
555
|
function isTemplateNode(node) {
|
|
556
|
-
return (node.type === 1 /* ELEMENT */ && node.tagType === 3 /* TEMPLATE */);
|
|
556
|
+
return (node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 3 /* ElementTypes.TEMPLATE */);
|
|
557
557
|
}
|
|
558
558
|
function isSlotOutlet(node) {
|
|
559
|
-
return node.type === 1 /* ELEMENT */ && node.tagType === 2 /* SLOT */;
|
|
559
|
+
return node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 2 /* ElementTypes.SLOT */;
|
|
560
560
|
}
|
|
561
561
|
function getVNodeHelper(ssr, isComponent) {
|
|
562
562
|
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
@@ -568,7 +568,7 @@ const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
|
568
568
|
function getUnnormalizedProps(props, callPath = []) {
|
|
569
569
|
if (props &&
|
|
570
570
|
!shared.isString(props) &&
|
|
571
|
-
props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
571
|
+
props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
572
572
|
const callee = props.callee;
|
|
573
573
|
if (!shared.isString(callee) && propsHelperSet.has(callee)) {
|
|
574
574
|
return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
|
|
@@ -586,12 +586,12 @@ function injectProp(node, prop, context) {
|
|
|
586
586
|
*
|
|
587
587
|
* we need to get the real props before normalization
|
|
588
588
|
*/
|
|
589
|
-
let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
|
|
589
|
+
let props = node.type === 13 /* NodeTypes.VNODE_CALL */ ? node.props : node.arguments[2];
|
|
590
590
|
let callPath = [];
|
|
591
591
|
let parentCall;
|
|
592
592
|
if (props &&
|
|
593
593
|
!shared.isString(props) &&
|
|
594
|
-
props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
594
|
+
props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
595
595
|
const ret = getUnnormalizedProps(props);
|
|
596
596
|
props = ret[0];
|
|
597
597
|
callPath = ret[1];
|
|
@@ -600,12 +600,12 @@ function injectProp(node, prop, context) {
|
|
|
600
600
|
if (props == null || shared.isString(props)) {
|
|
601
601
|
propsWithInjection = createObjectExpression([prop]);
|
|
602
602
|
}
|
|
603
|
-
else if (props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
603
|
+
else if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
604
604
|
// merged props... add ours
|
|
605
605
|
// only inject key to object literal if it's the first argument so that
|
|
606
606
|
// if doesn't override user provided keys
|
|
607
607
|
const first = props.arguments[0];
|
|
608
|
-
if (!shared.isString(first) && first.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
608
|
+
if (!shared.isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
609
609
|
first.properties.unshift(prop);
|
|
610
610
|
}
|
|
611
611
|
else {
|
|
@@ -622,12 +622,12 @@ function injectProp(node, prop, context) {
|
|
|
622
622
|
}
|
|
623
623
|
!propsWithInjection && (propsWithInjection = props);
|
|
624
624
|
}
|
|
625
|
-
else if (props.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
625
|
+
else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
626
626
|
let alreadyExists = false;
|
|
627
627
|
// check existing key to avoid overriding user provided keys
|
|
628
|
-
if (prop.key.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
628
|
+
if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
629
629
|
const propKeyName = prop.key.content;
|
|
630
|
-
alreadyExists = props.properties.some(p => p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
630
|
+
alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
631
631
|
p.key.content === propKeyName);
|
|
632
632
|
}
|
|
633
633
|
if (!alreadyExists) {
|
|
@@ -648,7 +648,7 @@ function injectProp(node, prop, context) {
|
|
|
648
648
|
parentCall = callPath[callPath.length - 2];
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
if (node.type === 13 /* VNODE_CALL */) {
|
|
651
|
+
if (node.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
652
652
|
if (parentCall) {
|
|
653
653
|
parentCall.arguments[0] = propsWithInjection;
|
|
654
654
|
}
|
|
@@ -677,45 +677,45 @@ function hasScopeRef(node, ids) {
|
|
|
677
677
|
return false;
|
|
678
678
|
}
|
|
679
679
|
switch (node.type) {
|
|
680
|
-
case 1 /* ELEMENT */:
|
|
680
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
681
681
|
for (let i = 0; i < node.props.length; i++) {
|
|
682
682
|
const p = node.props[i];
|
|
683
|
-
if (p.type === 7 /* DIRECTIVE */ &&
|
|
683
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
684
684
|
(hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
685
685
|
return true;
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
689
|
-
case 11 /* FOR */:
|
|
689
|
+
case 11 /* NodeTypes.FOR */:
|
|
690
690
|
if (hasScopeRef(node.source, ids)) {
|
|
691
691
|
return true;
|
|
692
692
|
}
|
|
693
693
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
694
|
-
case 9 /* IF */:
|
|
694
|
+
case 9 /* NodeTypes.IF */:
|
|
695
695
|
return node.branches.some(b => hasScopeRef(b, ids));
|
|
696
|
-
case 10 /* IF_BRANCH */:
|
|
696
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
697
697
|
if (hasScopeRef(node.condition, ids)) {
|
|
698
698
|
return true;
|
|
699
699
|
}
|
|
700
700
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
701
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
701
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
702
702
|
return (!node.isStatic &&
|
|
703
703
|
isSimpleIdentifier(node.content) &&
|
|
704
704
|
!!ids[node.content]);
|
|
705
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
705
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
706
706
|
return node.children.some(c => shared.isObject(c) && hasScopeRef(c, ids));
|
|
707
|
-
case 5 /* INTERPOLATION */:
|
|
708
|
-
case 12 /* TEXT_CALL */:
|
|
707
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
708
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
709
709
|
return hasScopeRef(node.content, ids);
|
|
710
|
-
case 2 /* TEXT */:
|
|
711
|
-
case 3 /* COMMENT */:
|
|
710
|
+
case 2 /* NodeTypes.TEXT */:
|
|
711
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
712
712
|
return false;
|
|
713
713
|
default:
|
|
714
714
|
return false;
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
717
|
function getMemoedVNodeCall(node) {
|
|
718
|
-
if (node.type === 14 /* JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
|
|
718
|
+
if (node.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
|
|
719
719
|
return node.arguments[1].returns;
|
|
720
720
|
}
|
|
721
721
|
else {
|
|
@@ -732,23 +732,23 @@ function makeBlock(node, { helper, removeHelper, inSSR }) {
|
|
|
732
732
|
}
|
|
733
733
|
|
|
734
734
|
const deprecationData = {
|
|
735
|
-
["COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */]: {
|
|
735
|
+
["COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */]: {
|
|
736
736
|
message: `Platform-native elements with "is" prop will no longer be ` +
|
|
737
737
|
`treated as components in Vue 3 unless the "is" value is explicitly ` +
|
|
738
738
|
`prefixed with "vue:".`,
|
|
739
739
|
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
740
740
|
},
|
|
741
|
-
["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
|
|
741
|
+
["COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */]: {
|
|
742
742
|
message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
|
|
743
743
|
`argument instead. \`v-bind:${key}.sync\` should be changed to ` +
|
|
744
744
|
`\`v-model:${key}\`.`,
|
|
745
745
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
746
746
|
},
|
|
747
|
-
["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
|
|
747
|
+
["COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */]: {
|
|
748
748
|
message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
|
|
749
749
|
`Vue 3 will automatically set a binding as DOM property when appropriate.`
|
|
750
750
|
},
|
|
751
|
-
["COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */]: {
|
|
751
|
+
["COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */]: {
|
|
752
752
|
message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
|
|
753
753
|
`object spread: it will now overwrite an existing non-mergeable attribute ` +
|
|
754
754
|
`that appears before v-bind in the case of conflict. ` +
|
|
@@ -756,11 +756,11 @@ const deprecationData = {
|
|
|
756
756
|
`You can also suppress this warning if the usage is intended.`,
|
|
757
757
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
758
758
|
},
|
|
759
|
-
["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
|
|
759
|
+
["COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */]: {
|
|
760
760
|
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
761
761
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
762
762
|
},
|
|
763
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
|
|
763
|
+
["COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
|
|
764
764
|
message: `v-if / v-for precedence when used on the same element has changed ` +
|
|
765
765
|
`in Vue 3: v-if now takes higher precedence and will no longer have ` +
|
|
766
766
|
`access to v-for scope variables. It is best to avoid the ambiguity ` +
|
|
@@ -768,15 +768,15 @@ const deprecationData = {
|
|
|
768
768
|
`data source.`,
|
|
769
769
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
770
770
|
},
|
|
771
|
-
["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
|
|
771
|
+
["COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */]: {
|
|
772
772
|
message: `<template> with no special directives will render as a native template ` +
|
|
773
773
|
`element instead of its inner content in Vue 3.`
|
|
774
774
|
},
|
|
775
|
-
["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
|
|
775
|
+
["COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */]: {
|
|
776
776
|
message: `"inline-template" has been removed in Vue 3.`,
|
|
777
777
|
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
778
778
|
},
|
|
779
|
-
["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
|
|
779
|
+
["COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */]: {
|
|
780
780
|
message: `filters have been removed in Vue 3. ` +
|
|
781
781
|
`The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
|
782
782
|
`Use method calls or computed properties instead.`,
|
|
@@ -836,8 +836,8 @@ const decodeMap = {
|
|
|
836
836
|
};
|
|
837
837
|
const defaultParserOptions = {
|
|
838
838
|
delimiters: [`{{`, `}}`],
|
|
839
|
-
getNamespace: () => 0 /* HTML */,
|
|
840
|
-
getTextMode: () => 0 /* DATA */,
|
|
839
|
+
getNamespace: () => 0 /* Namespaces.HTML */,
|
|
840
|
+
getTextMode: () => 0 /* TextModes.DATA */,
|
|
841
841
|
isVoidTag: shared.NO,
|
|
842
842
|
isPreTag: shared.NO,
|
|
843
843
|
isCustomElement: shared.NO,
|
|
@@ -849,7 +849,7 @@ const defaultParserOptions = {
|
|
|
849
849
|
function baseParse(content, options = {}) {
|
|
850
850
|
const context = createParserContext(content, options);
|
|
851
851
|
const start = getCursor(context);
|
|
852
|
-
return createRoot(parseChildren(context, 0 /* DATA */, []), getSelection(context, start));
|
|
852
|
+
return createRoot(parseChildren(context, 0 /* TextModes.DATA */, []), getSelection(context, start));
|
|
853
853
|
}
|
|
854
854
|
function createParserContext(content, rawOptions) {
|
|
855
855
|
const options = shared.extend({}, defaultParserOptions);
|
|
@@ -875,20 +875,20 @@ function createParserContext(content, rawOptions) {
|
|
|
875
875
|
}
|
|
876
876
|
function parseChildren(context, mode, ancestors) {
|
|
877
877
|
const parent = last(ancestors);
|
|
878
|
-
const ns = parent ? parent.ns : 0 /* HTML */;
|
|
878
|
+
const ns = parent ? parent.ns : 0 /* Namespaces.HTML */;
|
|
879
879
|
const nodes = [];
|
|
880
880
|
while (!isEnd(context, mode, ancestors)) {
|
|
881
881
|
const s = context.source;
|
|
882
882
|
let node = undefined;
|
|
883
|
-
if (mode === 0 /* DATA */ || mode === 1 /* RCDATA */) {
|
|
883
|
+
if (mode === 0 /* TextModes.DATA */ || mode === 1 /* TextModes.RCDATA */) {
|
|
884
884
|
if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
|
885
885
|
// '{{'
|
|
886
886
|
node = parseInterpolation(context, mode);
|
|
887
887
|
}
|
|
888
|
-
else if (mode === 0 /* DATA */ && s[0] === '<') {
|
|
888
|
+
else if (mode === 0 /* TextModes.DATA */ && s[0] === '<') {
|
|
889
889
|
// https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
|
|
890
890
|
if (s.length === 1) {
|
|
891
|
-
emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 1);
|
|
891
|
+
emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 1);
|
|
892
892
|
}
|
|
893
893
|
else if (s[1] === '!') {
|
|
894
894
|
// https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
|
|
@@ -900,57 +900,57 @@ function parseChildren(context, mode, ancestors) {
|
|
|
900
900
|
node = parseBogusComment(context);
|
|
901
901
|
}
|
|
902
902
|
else if (startsWith(s, '<![CDATA[')) {
|
|
903
|
-
if (ns !== 0 /* HTML */) {
|
|
903
|
+
if (ns !== 0 /* Namespaces.HTML */) {
|
|
904
904
|
node = parseCDATA(context, ancestors);
|
|
905
905
|
}
|
|
906
906
|
else {
|
|
907
|
-
emitError(context, 1 /* CDATA_IN_HTML_CONTENT */);
|
|
907
|
+
emitError(context, 1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */);
|
|
908
908
|
node = parseBogusComment(context);
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
911
|
else {
|
|
912
|
-
emitError(context, 11 /* INCORRECTLY_OPENED_COMMENT */);
|
|
912
|
+
emitError(context, 11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */);
|
|
913
913
|
node = parseBogusComment(context);
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
916
|
else if (s[1] === '/') {
|
|
917
917
|
// https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
|
|
918
918
|
if (s.length === 2) {
|
|
919
|
-
emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 2);
|
|
919
|
+
emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 2);
|
|
920
920
|
}
|
|
921
921
|
else if (s[2] === '>') {
|
|
922
|
-
emitError(context, 14 /* MISSING_END_TAG_NAME */, 2);
|
|
922
|
+
emitError(context, 14 /* ErrorCodes.MISSING_END_TAG_NAME */, 2);
|
|
923
923
|
advanceBy(context, 3);
|
|
924
924
|
continue;
|
|
925
925
|
}
|
|
926
926
|
else if (/[a-z]/i.test(s[2])) {
|
|
927
|
-
emitError(context, 23 /* X_INVALID_END_TAG */);
|
|
928
|
-
parseTag(context, 1 /* End */, parent);
|
|
927
|
+
emitError(context, 23 /* ErrorCodes.X_INVALID_END_TAG */);
|
|
928
|
+
parseTag(context, 1 /* TagType.End */, parent);
|
|
929
929
|
continue;
|
|
930
930
|
}
|
|
931
931
|
else {
|
|
932
|
-
emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
|
|
932
|
+
emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
|
|
933
933
|
node = parseBogusComment(context);
|
|
934
934
|
}
|
|
935
935
|
}
|
|
936
936
|
else if (/[a-z]/i.test(s[1])) {
|
|
937
937
|
node = parseElement(context, ancestors);
|
|
938
938
|
// 2.x <template> with no directive compat
|
|
939
|
-
if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context) &&
|
|
939
|
+
if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context) &&
|
|
940
940
|
node &&
|
|
941
941
|
node.tag === 'template' &&
|
|
942
|
-
!node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
|
|
942
|
+
!node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
943
943
|
isSpecialTemplateDirective(p.name))) {
|
|
944
|
-
warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context, node.loc);
|
|
944
|
+
warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context, node.loc);
|
|
945
945
|
node = node.children;
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
948
|
else if (s[1] === '?') {
|
|
949
|
-
emitError(context, 21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
|
|
949
|
+
emitError(context, 21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
|
|
950
950
|
node = parseBogusComment(context);
|
|
951
951
|
}
|
|
952
952
|
else {
|
|
953
|
-
emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
|
|
953
|
+
emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
|
|
954
954
|
}
|
|
955
955
|
}
|
|
956
956
|
}
|
|
@@ -968,11 +968,11 @@ function parseChildren(context, mode, ancestors) {
|
|
|
968
968
|
}
|
|
969
969
|
// Whitespace handling strategy like v2
|
|
970
970
|
let removedWhitespace = false;
|
|
971
|
-
if (mode !== 2 /* RAWTEXT */ && mode !== 1 /* RCDATA */) {
|
|
971
|
+
if (mode !== 2 /* TextModes.RAWTEXT */ && mode !== 1 /* TextModes.RCDATA */) {
|
|
972
972
|
const shouldCondense = context.options.whitespace !== 'preserve';
|
|
973
973
|
for (let i = 0; i < nodes.length; i++) {
|
|
974
974
|
const node = nodes[i];
|
|
975
|
-
if (!context.inPre && node.type === 2 /* TEXT */) {
|
|
975
|
+
if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
|
|
976
976
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
977
977
|
const prev = nodes[i - 1];
|
|
978
978
|
const next = nodes[i + 1];
|
|
@@ -983,10 +983,10 @@ function parseChildren(context, mode, ancestors) {
|
|
|
983
983
|
if (!prev ||
|
|
984
984
|
!next ||
|
|
985
985
|
(shouldCondense &&
|
|
986
|
-
(prev.type === 3 /* COMMENT */ ||
|
|
987
|
-
next.type === 3 /* COMMENT */ ||
|
|
988
|
-
(prev.type === 1 /* ELEMENT */ &&
|
|
989
|
-
next.type === 1 /* ELEMENT */ &&
|
|
986
|
+
(prev.type === 3 /* NodeTypes.COMMENT */ ||
|
|
987
|
+
next.type === 3 /* NodeTypes.COMMENT */ ||
|
|
988
|
+
(prev.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
989
|
+
next.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
990
990
|
/[\r\n]/.test(node.content))))) {
|
|
991
991
|
removedWhitespace = true;
|
|
992
992
|
nodes[i] = null;
|
|
@@ -1003,7 +1003,7 @@ function parseChildren(context, mode, ancestors) {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
1005
|
// Remove comment nodes if desired by configuration.
|
|
1006
|
-
else if (node.type === 3 /* COMMENT */ && !context.options.comments) {
|
|
1006
|
+
else if (node.type === 3 /* NodeTypes.COMMENT */ && !context.options.comments) {
|
|
1007
1007
|
removedWhitespace = true;
|
|
1008
1008
|
nodes[i] = null;
|
|
1009
1009
|
}
|
|
@@ -1012,7 +1012,7 @@ function parseChildren(context, mode, ancestors) {
|
|
|
1012
1012
|
// remove leading newline per html spec
|
|
1013
1013
|
// https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
|
|
1014
1014
|
const first = nodes[0];
|
|
1015
|
-
if (first && first.type === 2 /* TEXT */) {
|
|
1015
|
+
if (first && first.type === 2 /* NodeTypes.TEXT */) {
|
|
1016
1016
|
first.content = first.content.replace(/^\r?\n/, '');
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
@@ -1020,12 +1020,12 @@ function parseChildren(context, mode, ancestors) {
|
|
|
1020
1020
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1021
1021
|
}
|
|
1022
1022
|
function pushNode(nodes, node) {
|
|
1023
|
-
if (node.type === 2 /* TEXT */) {
|
|
1023
|
+
if (node.type === 2 /* NodeTypes.TEXT */) {
|
|
1024
1024
|
const prev = last(nodes);
|
|
1025
1025
|
// Merge if both this and the previous node are text and those are
|
|
1026
1026
|
// consecutive. This happens for cases like "a < b".
|
|
1027
1027
|
if (prev &&
|
|
1028
|
-
prev.type === 2 /* TEXT */ &&
|
|
1028
|
+
prev.type === 2 /* NodeTypes.TEXT */ &&
|
|
1029
1029
|
prev.loc.end.offset === node.loc.start.offset) {
|
|
1030
1030
|
prev.content += node.content;
|
|
1031
1031
|
prev.loc.end = node.loc.end;
|
|
@@ -1037,9 +1037,9 @@ function pushNode(nodes, node) {
|
|
|
1037
1037
|
}
|
|
1038
1038
|
function parseCDATA(context, ancestors) {
|
|
1039
1039
|
advanceBy(context, 9);
|
|
1040
|
-
const nodes = parseChildren(context, 3 /* CDATA */, ancestors);
|
|
1040
|
+
const nodes = parseChildren(context, 3 /* TextModes.CDATA */, ancestors);
|
|
1041
1041
|
if (context.source.length === 0) {
|
|
1042
|
-
emitError(context, 6 /* EOF_IN_CDATA */);
|
|
1042
|
+
emitError(context, 6 /* ErrorCodes.EOF_IN_CDATA */);
|
|
1043
1043
|
}
|
|
1044
1044
|
else {
|
|
1045
1045
|
advanceBy(context, 3);
|
|
@@ -1054,14 +1054,14 @@ function parseComment(context) {
|
|
|
1054
1054
|
if (!match) {
|
|
1055
1055
|
content = context.source.slice(4);
|
|
1056
1056
|
advanceBy(context, context.source.length);
|
|
1057
|
-
emitError(context, 7 /* EOF_IN_COMMENT */);
|
|
1057
|
+
emitError(context, 7 /* ErrorCodes.EOF_IN_COMMENT */);
|
|
1058
1058
|
}
|
|
1059
1059
|
else {
|
|
1060
1060
|
if (match.index <= 3) {
|
|
1061
|
-
emitError(context, 0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
|
|
1061
|
+
emitError(context, 0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
|
|
1062
1062
|
}
|
|
1063
1063
|
if (match[1]) {
|
|
1064
|
-
emitError(context, 10 /* INCORRECTLY_CLOSED_COMMENT */);
|
|
1064
|
+
emitError(context, 10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */);
|
|
1065
1065
|
}
|
|
1066
1066
|
content = context.source.slice(4, match.index);
|
|
1067
1067
|
// Advancing with reporting nested comments.
|
|
@@ -1070,14 +1070,14 @@ function parseComment(context) {
|
|
|
1070
1070
|
while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
|
|
1071
1071
|
advanceBy(context, nestedIndex - prevIndex + 1);
|
|
1072
1072
|
if (nestedIndex + 4 < s.length) {
|
|
1073
|
-
emitError(context, 16 /* NESTED_COMMENT */);
|
|
1073
|
+
emitError(context, 16 /* ErrorCodes.NESTED_COMMENT */);
|
|
1074
1074
|
}
|
|
1075
1075
|
prevIndex = nestedIndex + 1;
|
|
1076
1076
|
}
|
|
1077
1077
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1078
1078
|
}
|
|
1079
1079
|
return {
|
|
1080
|
-
type: 3 /* COMMENT */,
|
|
1080
|
+
type: 3 /* NodeTypes.COMMENT */,
|
|
1081
1081
|
content,
|
|
1082
1082
|
loc: getSelection(context, start)
|
|
1083
1083
|
};
|
|
@@ -1096,7 +1096,7 @@ function parseBogusComment(context) {
|
|
|
1096
1096
|
advanceBy(context, closeIndex + 1);
|
|
1097
1097
|
}
|
|
1098
1098
|
return {
|
|
1099
|
-
type: 3 /* COMMENT */,
|
|
1099
|
+
type: 3 /* NodeTypes.COMMENT */,
|
|
1100
1100
|
content,
|
|
1101
1101
|
loc: getSelection(context, start)
|
|
1102
1102
|
};
|
|
@@ -1106,7 +1106,7 @@ function parseElement(context, ancestors) {
|
|
|
1106
1106
|
const wasInPre = context.inPre;
|
|
1107
1107
|
const wasInVPre = context.inVPre;
|
|
1108
1108
|
const parent = last(ancestors);
|
|
1109
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
1109
|
+
const element = parseTag(context, 0 /* TagType.Start */, parent);
|
|
1110
1110
|
const isPreBoundary = context.inPre && !wasInPre;
|
|
1111
1111
|
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
1112
1112
|
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
@@ -1126,12 +1126,12 @@ function parseElement(context, ancestors) {
|
|
|
1126
1126
|
ancestors.pop();
|
|
1127
1127
|
// 2.x inline-template compat
|
|
1128
1128
|
{
|
|
1129
|
-
const inlineTemplateProp = element.props.find(p => p.type === 6 /* ATTRIBUTE */ && p.name === 'inline-template');
|
|
1129
|
+
const inlineTemplateProp = element.props.find(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'inline-template');
|
|
1130
1130
|
if (inlineTemplateProp &&
|
|
1131
|
-
checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
|
|
1131
|
+
checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
|
|
1132
1132
|
const loc = getSelection(context, element.loc.end);
|
|
1133
1133
|
inlineTemplateProp.value = {
|
|
1134
|
-
type: 2 /* TEXT */,
|
|
1134
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1135
1135
|
content: loc.source,
|
|
1136
1136
|
loc
|
|
1137
1137
|
};
|
|
@@ -1140,14 +1140,14 @@ function parseElement(context, ancestors) {
|
|
|
1140
1140
|
element.children = children;
|
|
1141
1141
|
// End tag.
|
|
1142
1142
|
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1143
|
-
parseTag(context, 1 /* End */, parent);
|
|
1143
|
+
parseTag(context, 1 /* TagType.End */, parent);
|
|
1144
1144
|
}
|
|
1145
1145
|
else {
|
|
1146
|
-
emitError(context, 24 /* X_MISSING_END_TAG */, 0, element.loc.start);
|
|
1146
|
+
emitError(context, 24 /* ErrorCodes.X_MISSING_END_TAG */, 0, element.loc.start);
|
|
1147
1147
|
if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
|
|
1148
1148
|
const first = children[0];
|
|
1149
1149
|
if (first && startsWith(first.loc.source, '<!--')) {
|
|
1150
|
-
emitError(context, 8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
|
|
1150
|
+
emitError(context, 8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
@@ -1179,9 +1179,9 @@ function parseTag(context, type, parent) {
|
|
|
1179
1179
|
// Attributes.
|
|
1180
1180
|
let props = parseAttributes(context, type);
|
|
1181
1181
|
// check v-pre
|
|
1182
|
-
if (type === 0 /* Start */ &&
|
|
1182
|
+
if (type === 0 /* TagType.Start */ &&
|
|
1183
1183
|
!context.inVPre &&
|
|
1184
|
-
props.some(p => p.type === 7 /* DIRECTIVE */ && p.name === 'pre')) {
|
|
1184
|
+
props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'pre')) {
|
|
1185
1185
|
context.inVPre = true;
|
|
1186
1186
|
// reset context
|
|
1187
1187
|
shared.extend(context, cursor);
|
|
@@ -1192,25 +1192,25 @@ function parseTag(context, type, parent) {
|
|
|
1192
1192
|
// Tag close.
|
|
1193
1193
|
let isSelfClosing = false;
|
|
1194
1194
|
if (context.source.length === 0) {
|
|
1195
|
-
emitError(context, 9 /* EOF_IN_TAG */);
|
|
1195
|
+
emitError(context, 9 /* ErrorCodes.EOF_IN_TAG */);
|
|
1196
1196
|
}
|
|
1197
1197
|
else {
|
|
1198
1198
|
isSelfClosing = startsWith(context.source, '/>');
|
|
1199
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1200
|
-
emitError(context, 4 /* END_TAG_WITH_TRAILING_SOLIDUS */);
|
|
1199
|
+
if (type === 1 /* TagType.End */ && isSelfClosing) {
|
|
1200
|
+
emitError(context, 4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */);
|
|
1201
1201
|
}
|
|
1202
1202
|
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1203
1203
|
}
|
|
1204
|
-
if (type === 1 /* End */) {
|
|
1204
|
+
if (type === 1 /* TagType.End */) {
|
|
1205
1205
|
return;
|
|
1206
1206
|
}
|
|
1207
1207
|
// 2.x deprecation checks
|
|
1208
|
-
if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
|
|
1208
|
+
if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
|
|
1209
1209
|
let hasIf = false;
|
|
1210
1210
|
let hasFor = false;
|
|
1211
1211
|
for (let i = 0; i < props.length; i++) {
|
|
1212
1212
|
const p = props[i];
|
|
1213
|
-
if (p.type === 7 /* DIRECTIVE */) {
|
|
1213
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
1214
1214
|
if (p.name === 'if') {
|
|
1215
1215
|
hasIf = true;
|
|
1216
1216
|
}
|
|
@@ -1219,27 +1219,27 @@ function parseTag(context, type, parent) {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
1221
1221
|
if (hasIf && hasFor) {
|
|
1222
|
-
warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
|
|
1222
|
+
warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
|
|
1223
1223
|
break;
|
|
1224
1224
|
}
|
|
1225
1225
|
}
|
|
1226
1226
|
}
|
|
1227
|
-
let tagType = 0 /* ELEMENT */;
|
|
1227
|
+
let tagType = 0 /* ElementTypes.ELEMENT */;
|
|
1228
1228
|
if (!context.inVPre) {
|
|
1229
1229
|
if (tag === 'slot') {
|
|
1230
|
-
tagType = 2 /* SLOT */;
|
|
1230
|
+
tagType = 2 /* ElementTypes.SLOT */;
|
|
1231
1231
|
}
|
|
1232
1232
|
else if (tag === 'template') {
|
|
1233
|
-
if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
|
1234
|
-
tagType = 3 /* TEMPLATE */;
|
|
1233
|
+
if (props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
|
1234
|
+
tagType = 3 /* ElementTypes.TEMPLATE */;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
1237
|
else if (isComponent(tag, props, context)) {
|
|
1238
|
-
tagType = 1 /* COMPONENT */;
|
|
1238
|
+
tagType = 1 /* ElementTypes.COMPONENT */;
|
|
1239
1239
|
}
|
|
1240
1240
|
}
|
|
1241
1241
|
return {
|
|
1242
|
-
type: 1 /* ELEMENT */,
|
|
1242
|
+
type: 1 /* NodeTypes.ELEMENT */,
|
|
1243
1243
|
ns,
|
|
1244
1244
|
tag,
|
|
1245
1245
|
tagType,
|
|
@@ -1266,12 +1266,12 @@ function isComponent(tag, props, context) {
|
|
|
1266
1266
|
// casting
|
|
1267
1267
|
for (let i = 0; i < props.length; i++) {
|
|
1268
1268
|
const p = props[i];
|
|
1269
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
1269
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
1270
1270
|
if (p.name === 'is' && p.value) {
|
|
1271
1271
|
if (p.value.content.startsWith('vue:')) {
|
|
1272
1272
|
return true;
|
|
1273
1273
|
}
|
|
1274
|
-
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1274
|
+
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1275
1275
|
return true;
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
@@ -1287,7 +1287,7 @@ function isComponent(tag, props, context) {
|
|
|
1287
1287
|
p.name === 'bind' &&
|
|
1288
1288
|
isStaticArgOf(p.arg, 'is') &&
|
|
1289
1289
|
true &&
|
|
1290
|
-
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1290
|
+
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1291
1291
|
return true;
|
|
1292
1292
|
}
|
|
1293
1293
|
}
|
|
@@ -1300,27 +1300,27 @@ function parseAttributes(context, type) {
|
|
|
1300
1300
|
!startsWith(context.source, '>') &&
|
|
1301
1301
|
!startsWith(context.source, '/>')) {
|
|
1302
1302
|
if (startsWith(context.source, '/')) {
|
|
1303
|
-
emitError(context, 22 /* UNEXPECTED_SOLIDUS_IN_TAG */);
|
|
1303
|
+
emitError(context, 22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */);
|
|
1304
1304
|
advanceBy(context, 1);
|
|
1305
1305
|
advanceSpaces(context);
|
|
1306
1306
|
continue;
|
|
1307
1307
|
}
|
|
1308
|
-
if (type === 1 /* End */) {
|
|
1309
|
-
emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
|
|
1308
|
+
if (type === 1 /* TagType.End */) {
|
|
1309
|
+
emitError(context, 3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */);
|
|
1310
1310
|
}
|
|
1311
1311
|
const attr = parseAttribute(context, attributeNames);
|
|
1312
1312
|
// Trim whitespace between class
|
|
1313
1313
|
// https://github.com/vuejs/core/issues/4251
|
|
1314
|
-
if (attr.type === 6 /* ATTRIBUTE */ &&
|
|
1314
|
+
if (attr.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
1315
1315
|
attr.value &&
|
|
1316
1316
|
attr.name === 'class') {
|
|
1317
1317
|
attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
|
|
1318
1318
|
}
|
|
1319
|
-
if (type === 0 /* Start */) {
|
|
1319
|
+
if (type === 0 /* TagType.Start */) {
|
|
1320
1320
|
props.push(attr);
|
|
1321
1321
|
}
|
|
1322
1322
|
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1323
|
-
emitError(context, 15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
|
|
1323
|
+
emitError(context, 15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
|
|
1324
1324
|
}
|
|
1325
1325
|
advanceSpaces(context);
|
|
1326
1326
|
}
|
|
@@ -1332,17 +1332,17 @@ function parseAttribute(context, nameSet) {
|
|
|
1332
1332
|
const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
|
1333
1333
|
const name = match[0];
|
|
1334
1334
|
if (nameSet.has(name)) {
|
|
1335
|
-
emitError(context, 2 /* DUPLICATE_ATTRIBUTE */);
|
|
1335
|
+
emitError(context, 2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */);
|
|
1336
1336
|
}
|
|
1337
1337
|
nameSet.add(name);
|
|
1338
1338
|
if (name[0] === '=') {
|
|
1339
|
-
emitError(context, 19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
|
|
1339
|
+
emitError(context, 19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
|
|
1340
1340
|
}
|
|
1341
1341
|
{
|
|
1342
1342
|
const pattern = /["'<]/g;
|
|
1343
1343
|
let m;
|
|
1344
1344
|
while ((m = pattern.exec(name))) {
|
|
1345
|
-
emitError(context, 17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
|
|
1345
|
+
emitError(context, 17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
1348
|
advanceBy(context, name.length);
|
|
@@ -1354,7 +1354,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1354
1354
|
advanceSpaces(context);
|
|
1355
1355
|
value = parseAttributeValue(context);
|
|
1356
1356
|
if (!value) {
|
|
1357
|
-
emitError(context, 13 /* MISSING_ATTRIBUTE_VALUE */);
|
|
1357
|
+
emitError(context, 13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */);
|
|
1358
1358
|
}
|
|
1359
1359
|
}
|
|
1360
1360
|
const loc = getSelection(context, start);
|
|
@@ -1377,7 +1377,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1377
1377
|
if (content.startsWith('[')) {
|
|
1378
1378
|
isStatic = false;
|
|
1379
1379
|
if (!content.endsWith(']')) {
|
|
1380
|
-
emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
|
|
1380
|
+
emitError(context, 27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
|
|
1381
1381
|
content = content.slice(1);
|
|
1382
1382
|
}
|
|
1383
1383
|
else {
|
|
@@ -1391,12 +1391,12 @@ function parseAttribute(context, nameSet) {
|
|
|
1391
1391
|
content += match[3] || '';
|
|
1392
1392
|
}
|
|
1393
1393
|
arg = {
|
|
1394
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1394
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1395
1395
|
content,
|
|
1396
1396
|
isStatic,
|
|
1397
1397
|
constType: isStatic
|
|
1398
|
-
? 3 /* CAN_STRINGIFY */
|
|
1399
|
-
: 0 /* NOT_CONSTANT */,
|
|
1398
|
+
? 3 /* ConstantTypes.CAN_STRINGIFY */
|
|
1399
|
+
: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1400
1400
|
loc
|
|
1401
1401
|
};
|
|
1402
1402
|
}
|
|
@@ -1413,24 +1413,24 @@ function parseAttribute(context, nameSet) {
|
|
|
1413
1413
|
// 2.x compat v-bind:foo.sync -> v-model:foo
|
|
1414
1414
|
if (dirName === 'bind' && arg) {
|
|
1415
1415
|
if (modifiers.includes('sync') &&
|
|
1416
|
-
checkCompatEnabled("COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
|
|
1416
|
+
checkCompatEnabled("COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
|
|
1417
1417
|
dirName = 'model';
|
|
1418
1418
|
modifiers.splice(modifiers.indexOf('sync'), 1);
|
|
1419
1419
|
}
|
|
1420
1420
|
if (modifiers.includes('prop')) {
|
|
1421
|
-
checkCompatEnabled("COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */, context, loc);
|
|
1421
|
+
checkCompatEnabled("COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */, context, loc);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
return {
|
|
1425
|
-
type: 7 /* DIRECTIVE */,
|
|
1425
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
1426
1426
|
name: dirName,
|
|
1427
1427
|
exp: value && {
|
|
1428
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1428
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1429
1429
|
content: value.content,
|
|
1430
1430
|
isStatic: false,
|
|
1431
1431
|
// Treat as non-constant by default. This can be potentially set to
|
|
1432
1432
|
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1433
|
-
constType: 0 /* NOT_CONSTANT */,
|
|
1433
|
+
constType: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1434
1434
|
loc: value.loc
|
|
1435
1435
|
},
|
|
1436
1436
|
arg,
|
|
@@ -1440,13 +1440,13 @@ function parseAttribute(context, nameSet) {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
// missing directive name or illegal directive name
|
|
1442
1442
|
if (!context.inVPre && startsWith(name, 'v-')) {
|
|
1443
|
-
emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
|
|
1443
|
+
emitError(context, 26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */);
|
|
1444
1444
|
}
|
|
1445
1445
|
return {
|
|
1446
|
-
type: 6 /* ATTRIBUTE */,
|
|
1446
|
+
type: 6 /* NodeTypes.ATTRIBUTE */,
|
|
1447
1447
|
name,
|
|
1448
1448
|
value: value && {
|
|
1449
|
-
type: 2 /* TEXT */,
|
|
1449
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1450
1450
|
content: value.content,
|
|
1451
1451
|
loc: value.loc
|
|
1452
1452
|
},
|
|
@@ -1463,10 +1463,10 @@ function parseAttributeValue(context) {
|
|
|
1463
1463
|
advanceBy(context, 1);
|
|
1464
1464
|
const endIndex = context.source.indexOf(quote);
|
|
1465
1465
|
if (endIndex === -1) {
|
|
1466
|
-
content = parseTextData(context, context.source.length, 4 /* ATTRIBUTE_VALUE */);
|
|
1466
|
+
content = parseTextData(context, context.source.length, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1467
1467
|
}
|
|
1468
1468
|
else {
|
|
1469
|
-
content = parseTextData(context, endIndex, 4 /* ATTRIBUTE_VALUE */);
|
|
1469
|
+
content = parseTextData(context, endIndex, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1470
1470
|
advanceBy(context, 1);
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
@@ -1479,9 +1479,9 @@ function parseAttributeValue(context) {
|
|
|
1479
1479
|
const unexpectedChars = /["'<=`]/g;
|
|
1480
1480
|
let m;
|
|
1481
1481
|
while ((m = unexpectedChars.exec(match[0]))) {
|
|
1482
|
-
emitError(context, 18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
|
|
1482
|
+
emitError(context, 18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
|
|
1483
1483
|
}
|
|
1484
|
-
content = parseTextData(context, match[0].length, 4 /* ATTRIBUTE_VALUE */);
|
|
1484
|
+
content = parseTextData(context, match[0].length, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1485
1485
|
}
|
|
1486
1486
|
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1487
1487
|
}
|
|
@@ -1489,7 +1489,7 @@ function parseInterpolation(context, mode) {
|
|
|
1489
1489
|
const [open, close] = context.options.delimiters;
|
|
1490
1490
|
const closeIndex = context.source.indexOf(close, open.length);
|
|
1491
1491
|
if (closeIndex === -1) {
|
|
1492
|
-
emitError(context, 25 /* X_MISSING_INTERPOLATION_END */);
|
|
1492
|
+
emitError(context, 25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */);
|
|
1493
1493
|
return undefined;
|
|
1494
1494
|
}
|
|
1495
1495
|
const start = getCursor(context);
|
|
@@ -1508,12 +1508,12 @@ function parseInterpolation(context, mode) {
|
|
|
1508
1508
|
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1509
1509
|
advanceBy(context, close.length);
|
|
1510
1510
|
return {
|
|
1511
|
-
type: 5 /* INTERPOLATION */,
|
|
1511
|
+
type: 5 /* NodeTypes.INTERPOLATION */,
|
|
1512
1512
|
content: {
|
|
1513
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1513
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1514
1514
|
isStatic: false,
|
|
1515
1515
|
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1516
|
-
constType: 0 /* NOT_CONSTANT */,
|
|
1516
|
+
constType: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1517
1517
|
content,
|
|
1518
1518
|
loc: getSelection(context, innerStart, innerEnd)
|
|
1519
1519
|
},
|
|
@@ -1521,7 +1521,7 @@ function parseInterpolation(context, mode) {
|
|
|
1521
1521
|
};
|
|
1522
1522
|
}
|
|
1523
1523
|
function parseText(context, mode) {
|
|
1524
|
-
const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
|
|
1524
|
+
const endTokens = mode === 3 /* TextModes.CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
|
|
1525
1525
|
let endIndex = context.source.length;
|
|
1526
1526
|
for (let i = 0; i < endTokens.length; i++) {
|
|
1527
1527
|
const index = context.source.indexOf(endTokens[i], 1);
|
|
@@ -1532,7 +1532,7 @@ function parseText(context, mode) {
|
|
|
1532
1532
|
const start = getCursor(context);
|
|
1533
1533
|
const content = parseTextData(context, endIndex, mode);
|
|
1534
1534
|
return {
|
|
1535
|
-
type: 2 /* TEXT */,
|
|
1535
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1536
1536
|
content,
|
|
1537
1537
|
loc: getSelection(context, start)
|
|
1538
1538
|
};
|
|
@@ -1544,14 +1544,14 @@ function parseText(context, mode) {
|
|
|
1544
1544
|
function parseTextData(context, length, mode) {
|
|
1545
1545
|
const rawText = context.source.slice(0, length);
|
|
1546
1546
|
advanceBy(context, length);
|
|
1547
|
-
if (mode === 2 /* RAWTEXT */ ||
|
|
1548
|
-
mode === 3 /* CDATA */ ||
|
|
1547
|
+
if (mode === 2 /* TextModes.RAWTEXT */ ||
|
|
1548
|
+
mode === 3 /* TextModes.CDATA */ ||
|
|
1549
1549
|
!rawText.includes('&')) {
|
|
1550
1550
|
return rawText;
|
|
1551
1551
|
}
|
|
1552
1552
|
else {
|
|
1553
1553
|
// DATA or RCDATA containing "&"". Entity decoding required.
|
|
1554
|
-
return context.options.decodeEntities(rawText, mode === 4 /* ATTRIBUTE_VALUE */);
|
|
1554
|
+
return context.options.decodeEntities(rawText, mode === 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1555
1555
|
}
|
|
1556
1556
|
}
|
|
1557
1557
|
function getCursor(context) {
|
|
@@ -1600,7 +1600,7 @@ function emitError(context, code, offset, loc = getCursor(context)) {
|
|
|
1600
1600
|
function isEnd(context, mode, ancestors) {
|
|
1601
1601
|
const s = context.source;
|
|
1602
1602
|
switch (mode) {
|
|
1603
|
-
case 0 /* DATA */:
|
|
1603
|
+
case 0 /* TextModes.DATA */:
|
|
1604
1604
|
if (startsWith(s, '</')) {
|
|
1605
1605
|
// TODO: probably bad performance
|
|
1606
1606
|
for (let i = ancestors.length - 1; i >= 0; --i) {
|
|
@@ -1610,15 +1610,15 @@ function isEnd(context, mode, ancestors) {
|
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
1612
1612
|
break;
|
|
1613
|
-
case 1 /* RCDATA */:
|
|
1614
|
-
case 2 /* RAWTEXT */: {
|
|
1613
|
+
case 1 /* TextModes.RCDATA */:
|
|
1614
|
+
case 2 /* TextModes.RAWTEXT */: {
|
|
1615
1615
|
const parent = last(ancestors);
|
|
1616
1616
|
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1617
1617
|
return true;
|
|
1618
1618
|
}
|
|
1619
1619
|
break;
|
|
1620
1620
|
}
|
|
1621
|
-
case 3 /* CDATA */:
|
|
1621
|
+
case 3 /* TextModes.CDATA */:
|
|
1622
1622
|
if (startsWith(s, ']]>')) {
|
|
1623
1623
|
return true;
|
|
1624
1624
|
}
|
|
@@ -1641,7 +1641,7 @@ function hoistStatic(root, context) {
|
|
|
1641
1641
|
function isSingleElementRoot(root, child) {
|
|
1642
1642
|
const { children } = root;
|
|
1643
1643
|
return (children.length === 1 &&
|
|
1644
|
-
child.type === 1 /* ELEMENT */ &&
|
|
1644
|
+
child.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1645
1645
|
!isSlotOutlet(child));
|
|
1646
1646
|
}
|
|
1647
1647
|
function walk(node, context, doNotHoistNode = false) {
|
|
@@ -1651,15 +1651,15 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1651
1651
|
for (let i = 0; i < children.length; i++) {
|
|
1652
1652
|
const child = children[i];
|
|
1653
1653
|
// only plain elements & text calls are eligible for hoisting.
|
|
1654
|
-
if (child.type === 1 /* ELEMENT */ &&
|
|
1655
|
-
child.tagType === 0 /* ELEMENT */) {
|
|
1654
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1655
|
+
child.tagType === 0 /* ElementTypes.ELEMENT */) {
|
|
1656
1656
|
const constantType = doNotHoistNode
|
|
1657
|
-
? 0 /* NOT_CONSTANT */
|
|
1657
|
+
? 0 /* ConstantTypes.NOT_CONSTANT */
|
|
1658
1658
|
: getConstantType(child, context);
|
|
1659
|
-
if (constantType > 0 /* NOT_CONSTANT */) {
|
|
1660
|
-
if (constantType >= 2 /* CAN_HOIST */) {
|
|
1659
|
+
if (constantType > 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1660
|
+
if (constantType >= 2 /* ConstantTypes.CAN_HOIST */) {
|
|
1661
1661
|
child.codegenNode.patchFlag =
|
|
1662
|
-
-1 /* HOISTED */ + (` /* HOISTED */` );
|
|
1662
|
+
-1 /* PatchFlags.HOISTED */ + (` /* HOISTED */` );
|
|
1663
1663
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1664
1664
|
hoistedCount++;
|
|
1665
1665
|
continue;
|
|
@@ -1669,13 +1669,13 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1669
1669
|
// node may contain dynamic children, but its props may be eligible for
|
|
1670
1670
|
// hoisting.
|
|
1671
1671
|
const codegenNode = child.codegenNode;
|
|
1672
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
1672
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
1673
1673
|
const flag = getPatchFlag(codegenNode);
|
|
1674
1674
|
if ((!flag ||
|
|
1675
|
-
flag === 512 /* NEED_PATCH */ ||
|
|
1676
|
-
flag === 1 /* TEXT */) &&
|
|
1675
|
+
flag === 512 /* PatchFlags.NEED_PATCH */ ||
|
|
1676
|
+
flag === 1 /* PatchFlags.TEXT */) &&
|
|
1677
1677
|
getGeneratedPropsConstantType(child, context) >=
|
|
1678
|
-
2 /* CAN_HOIST */) {
|
|
1678
|
+
2 /* ConstantTypes.CAN_HOIST */) {
|
|
1679
1679
|
const props = getNodeProps(child);
|
|
1680
1680
|
if (props) {
|
|
1681
1681
|
codegenNode.props = context.hoist(props);
|
|
@@ -1687,14 +1687,14 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1687
1687
|
}
|
|
1688
1688
|
}
|
|
1689
1689
|
}
|
|
1690
|
-
else if (child.type === 12 /* TEXT_CALL */ &&
|
|
1691
|
-
getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
|
|
1690
|
+
else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
|
|
1691
|
+
getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
|
|
1692
1692
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1693
1693
|
hoistedCount++;
|
|
1694
1694
|
}
|
|
1695
1695
|
// walk further
|
|
1696
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
1697
|
-
const isComponent = child.tagType === 1 /* COMPONENT */;
|
|
1696
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
1697
|
+
const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
|
|
1698
1698
|
if (isComponent) {
|
|
1699
1699
|
context.scopes.vSlot++;
|
|
1700
1700
|
}
|
|
@@ -1703,11 +1703,11 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1703
1703
|
context.scopes.vSlot--;
|
|
1704
1704
|
}
|
|
1705
1705
|
}
|
|
1706
|
-
else if (child.type === 11 /* FOR */) {
|
|
1706
|
+
else if (child.type === 11 /* NodeTypes.FOR */) {
|
|
1707
1707
|
// Do not hoist v-for single child because it has to be a block
|
|
1708
1708
|
walk(child, context, child.children.length === 1);
|
|
1709
1709
|
}
|
|
1710
|
-
else if (child.type === 9 /* IF */) {
|
|
1710
|
+
else if (child.type === 9 /* NodeTypes.IF */) {
|
|
1711
1711
|
for (let i = 0; i < child.branches.length; i++) {
|
|
1712
1712
|
// Do not hoist v-if single child because it has to be a block
|
|
1713
1713
|
walk(child.branches[i], context, child.branches[i].children.length === 1);
|
|
@@ -1720,10 +1720,10 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1720
1720
|
// all children were hoisted - the entire children array is hoistable.
|
|
1721
1721
|
if (hoistedCount &&
|
|
1722
1722
|
hoistedCount === originalCount &&
|
|
1723
|
-
node.type === 1 /* ELEMENT */ &&
|
|
1724
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
1723
|
+
node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1724
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
1725
1725
|
node.codegenNode &&
|
|
1726
|
-
node.codegenNode.type === 13 /* VNODE_CALL */ &&
|
|
1726
|
+
node.codegenNode.type === 13 /* NodeTypes.VNODE_CALL */ &&
|
|
1727
1727
|
shared.isArray(node.codegenNode.children)) {
|
|
1728
1728
|
node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
|
|
1729
1729
|
}
|
|
@@ -1731,35 +1731,35 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1731
1731
|
function getConstantType(node, context) {
|
|
1732
1732
|
const { constantCache } = context;
|
|
1733
1733
|
switch (node.type) {
|
|
1734
|
-
case 1 /* ELEMENT */:
|
|
1735
|
-
if (node.tagType !== 0 /* ELEMENT */) {
|
|
1736
|
-
return 0 /* NOT_CONSTANT */;
|
|
1734
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
1735
|
+
if (node.tagType !== 0 /* ElementTypes.ELEMENT */) {
|
|
1736
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1737
1737
|
}
|
|
1738
1738
|
const cached = constantCache.get(node);
|
|
1739
1739
|
if (cached !== undefined) {
|
|
1740
1740
|
return cached;
|
|
1741
1741
|
}
|
|
1742
1742
|
const codegenNode = node.codegenNode;
|
|
1743
|
-
if (codegenNode.type !== 13 /* VNODE_CALL */) {
|
|
1744
|
-
return 0 /* NOT_CONSTANT */;
|
|
1743
|
+
if (codegenNode.type !== 13 /* NodeTypes.VNODE_CALL */) {
|
|
1744
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1745
1745
|
}
|
|
1746
1746
|
if (codegenNode.isBlock &&
|
|
1747
1747
|
node.tag !== 'svg' &&
|
|
1748
1748
|
node.tag !== 'foreignObject') {
|
|
1749
|
-
return 0 /* NOT_CONSTANT */;
|
|
1749
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1750
1750
|
}
|
|
1751
1751
|
const flag = getPatchFlag(codegenNode);
|
|
1752
1752
|
if (!flag) {
|
|
1753
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
1753
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1754
1754
|
// Element itself has no patch flag. However we still need to check:
|
|
1755
1755
|
// 1. Even for a node with no patch flag, it is possible for it to contain
|
|
1756
1756
|
// non-hoistable expressions that refers to scope variables, e.g. compiler
|
|
1757
1757
|
// injected keys or cached event handlers. Therefore we need to always
|
|
1758
1758
|
// check the codegenNode's props to be sure.
|
|
1759
1759
|
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
1760
|
-
if (generatedPropsType === 0 /* NOT_CONSTANT */) {
|
|
1761
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1762
|
-
return 0 /* NOT_CONSTANT */;
|
|
1760
|
+
if (generatedPropsType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1761
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1762
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1763
1763
|
}
|
|
1764
1764
|
if (generatedPropsType < returnType) {
|
|
1765
1765
|
returnType = generatedPropsType;
|
|
@@ -1767,9 +1767,9 @@ function getConstantType(node, context) {
|
|
|
1767
1767
|
// 2. its children.
|
|
1768
1768
|
for (let i = 0; i < node.children.length; i++) {
|
|
1769
1769
|
const childType = getConstantType(node.children[i], context);
|
|
1770
|
-
if (childType === 0 /* NOT_CONSTANT */) {
|
|
1771
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1772
|
-
return 0 /* NOT_CONSTANT */;
|
|
1770
|
+
if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1771
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1772
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1773
1773
|
}
|
|
1774
1774
|
if (childType < returnType) {
|
|
1775
1775
|
returnType = childType;
|
|
@@ -1779,14 +1779,14 @@ function getConstantType(node, context) {
|
|
|
1779
1779
|
// type, check if any of the props can cause the type to be lowered
|
|
1780
1780
|
// we can skip can_patch because it's guaranteed by the absence of a
|
|
1781
1781
|
// patchFlag.
|
|
1782
|
-
if (returnType > 1 /* CAN_SKIP_PATCH */) {
|
|
1782
|
+
if (returnType > 1 /* ConstantTypes.CAN_SKIP_PATCH */) {
|
|
1783
1783
|
for (let i = 0; i < node.props.length; i++) {
|
|
1784
1784
|
const p = node.props[i];
|
|
1785
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind' && p.exp) {
|
|
1785
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind' && p.exp) {
|
|
1786
1786
|
const expType = getConstantType(p.exp, context);
|
|
1787
|
-
if (expType === 0 /* NOT_CONSTANT */) {
|
|
1788
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1789
|
-
return 0 /* NOT_CONSTANT */;
|
|
1787
|
+
if (expType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1788
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1789
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1790
1790
|
}
|
|
1791
1791
|
if (expType < returnType) {
|
|
1792
1792
|
returnType = expType;
|
|
@@ -1801,9 +1801,9 @@ function getConstantType(node, context) {
|
|
|
1801
1801
|
// except set custom directives.
|
|
1802
1802
|
for (let i = 0; i < node.props.length; i++) {
|
|
1803
1803
|
const p = node.props[i];
|
|
1804
|
-
if (p.type === 7 /* DIRECTIVE */) {
|
|
1805
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1806
|
-
return 0 /* NOT_CONSTANT */;
|
|
1804
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
1805
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1806
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
1809
1809
|
context.removeHelper(OPEN_BLOCK);
|
|
@@ -1815,31 +1815,31 @@ function getConstantType(node, context) {
|
|
|
1815
1815
|
return returnType;
|
|
1816
1816
|
}
|
|
1817
1817
|
else {
|
|
1818
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1819
|
-
return 0 /* NOT_CONSTANT */;
|
|
1820
|
-
}
|
|
1821
|
-
case 2 /* TEXT */:
|
|
1822
|
-
case 3 /* COMMENT */:
|
|
1823
|
-
return 3 /* CAN_STRINGIFY */;
|
|
1824
|
-
case 9 /* IF */:
|
|
1825
|
-
case 11 /* FOR */:
|
|
1826
|
-
case 10 /* IF_BRANCH */:
|
|
1827
|
-
return 0 /* NOT_CONSTANT */;
|
|
1828
|
-
case 5 /* INTERPOLATION */:
|
|
1829
|
-
case 12 /* TEXT_CALL */:
|
|
1818
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1819
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1820
|
+
}
|
|
1821
|
+
case 2 /* NodeTypes.TEXT */:
|
|
1822
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
1823
|
+
return 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1824
|
+
case 9 /* NodeTypes.IF */:
|
|
1825
|
+
case 11 /* NodeTypes.FOR */:
|
|
1826
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
1827
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1828
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
1829
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
1830
1830
|
return getConstantType(node.content, context);
|
|
1831
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
1831
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
1832
1832
|
return node.constType;
|
|
1833
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
1834
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
1833
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
1834
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1835
1835
|
for (let i = 0; i < node.children.length; i++) {
|
|
1836
1836
|
const child = node.children[i];
|
|
1837
1837
|
if (shared.isString(child) || shared.isSymbol(child)) {
|
|
1838
1838
|
continue;
|
|
1839
1839
|
}
|
|
1840
1840
|
const childType = getConstantType(child, context);
|
|
1841
|
-
if (childType === 0 /* NOT_CONSTANT */) {
|
|
1842
|
-
return 0 /* NOT_CONSTANT */;
|
|
1841
|
+
if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1842
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1843
1843
|
}
|
|
1844
1844
|
else if (childType < returnType) {
|
|
1845
1845
|
returnType = childType;
|
|
@@ -1847,7 +1847,7 @@ function getConstantType(node, context) {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
return returnType;
|
|
1849
1849
|
default:
|
|
1850
|
-
return 0 /* NOT_CONSTANT */;
|
|
1850
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1851
1851
|
}
|
|
1852
1852
|
}
|
|
1853
1853
|
const allowHoistedHelperSet = new Set([
|
|
@@ -1857,48 +1857,48 @@ const allowHoistedHelperSet = new Set([
|
|
|
1857
1857
|
GUARD_REACTIVE_PROPS
|
|
1858
1858
|
]);
|
|
1859
1859
|
function getConstantTypeOfHelperCall(value, context) {
|
|
1860
|
-
if (value.type === 14 /* JS_CALL_EXPRESSION */ &&
|
|
1860
|
+
if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ &&
|
|
1861
1861
|
!shared.isString(value.callee) &&
|
|
1862
1862
|
allowHoistedHelperSet.has(value.callee)) {
|
|
1863
1863
|
const arg = value.arguments[0];
|
|
1864
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
1864
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
1865
1865
|
return getConstantType(arg, context);
|
|
1866
1866
|
}
|
|
1867
|
-
else if (arg.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
1867
|
+
else if (arg.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
1868
1868
|
// in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
|
|
1869
1869
|
return getConstantTypeOfHelperCall(arg, context);
|
|
1870
1870
|
}
|
|
1871
1871
|
}
|
|
1872
|
-
return 0 /* NOT_CONSTANT */;
|
|
1872
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1873
1873
|
}
|
|
1874
1874
|
function getGeneratedPropsConstantType(node, context) {
|
|
1875
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
1875
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1876
1876
|
const props = getNodeProps(node);
|
|
1877
|
-
if (props && props.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
1877
|
+
if (props && props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
1878
1878
|
const { properties } = props;
|
|
1879
1879
|
for (let i = 0; i < properties.length; i++) {
|
|
1880
1880
|
const { key, value } = properties[i];
|
|
1881
1881
|
const keyType = getConstantType(key, context);
|
|
1882
|
-
if (keyType === 0 /* NOT_CONSTANT */) {
|
|
1882
|
+
if (keyType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1883
1883
|
return keyType;
|
|
1884
1884
|
}
|
|
1885
1885
|
if (keyType < returnType) {
|
|
1886
1886
|
returnType = keyType;
|
|
1887
1887
|
}
|
|
1888
1888
|
let valueType;
|
|
1889
|
-
if (value.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
1889
|
+
if (value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
1890
1890
|
valueType = getConstantType(value, context);
|
|
1891
1891
|
}
|
|
1892
|
-
else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
1892
|
+
else if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
1893
1893
|
// some helper calls can be hoisted,
|
|
1894
1894
|
// such as the `normalizeProps` generated by the compiler for pre-normalize class,
|
|
1895
1895
|
// in this case we need to respect the ConstantType of the helper's arguments
|
|
1896
1896
|
valueType = getConstantTypeOfHelperCall(value, context);
|
|
1897
1897
|
}
|
|
1898
1898
|
else {
|
|
1899
|
-
valueType = 0 /* NOT_CONSTANT */;
|
|
1899
|
+
valueType = 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1900
1900
|
}
|
|
1901
|
-
if (valueType === 0 /* NOT_CONSTANT */) {
|
|
1901
|
+
if (valueType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1902
1902
|
return valueType;
|
|
1903
1903
|
}
|
|
1904
1904
|
if (valueType < returnType) {
|
|
@@ -1910,7 +1910,7 @@ function getGeneratedPropsConstantType(node, context) {
|
|
|
1910
1910
|
}
|
|
1911
1911
|
function getNodeProps(node) {
|
|
1912
1912
|
const codegenNode = node.codegenNode;
|
|
1913
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
1913
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
1914
1914
|
return codegenNode.props;
|
|
1915
1915
|
}
|
|
1916
1916
|
}
|
|
@@ -2036,7 +2036,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
|
|
|
2036
2036
|
else if (exp.identifiers) {
|
|
2037
2037
|
exp.identifiers.forEach(addId);
|
|
2038
2038
|
}
|
|
2039
|
-
else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2039
|
+
else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2040
2040
|
addId(exp.content);
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
@@ -2049,7 +2049,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
|
|
|
2049
2049
|
else if (exp.identifiers) {
|
|
2050
2050
|
exp.identifiers.forEach(removeId);
|
|
2051
2051
|
}
|
|
2052
|
-
else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2052
|
+
else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2053
2053
|
removeId(exp.content);
|
|
2054
2054
|
}
|
|
2055
2055
|
}
|
|
@@ -2058,7 +2058,7 @@ function createTransformContext(root, { filename = '', prefixIdentifiers = false
|
|
|
2058
2058
|
if (shared.isString(exp))
|
|
2059
2059
|
exp = createSimpleExpression(exp);
|
|
2060
2060
|
context.hoists.push(exp);
|
|
2061
|
-
const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* CAN_HOIST */);
|
|
2061
|
+
const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* ConstantTypes.CAN_HOIST */);
|
|
2062
2062
|
identifier.hoisted = exp;
|
|
2063
2063
|
return identifier;
|
|
2064
2064
|
},
|
|
@@ -2112,7 +2112,7 @@ function createRootCodegen(root, context) {
|
|
|
2112
2112
|
// single element root is never hoisted so codegenNode will never be
|
|
2113
2113
|
// SimpleExpressionNode
|
|
2114
2114
|
const codegenNode = child.codegenNode;
|
|
2115
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
2115
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
2116
2116
|
makeBlock(codegenNode, context);
|
|
2117
2117
|
}
|
|
2118
2118
|
root.codegenNode = codegenNode;
|
|
@@ -2126,13 +2126,13 @@ function createRootCodegen(root, context) {
|
|
|
2126
2126
|
}
|
|
2127
2127
|
else if (children.length > 1) {
|
|
2128
2128
|
// root has multiple nodes - return a fragment block.
|
|
2129
|
-
let patchFlag = 64 /* STABLE_FRAGMENT */;
|
|
2130
|
-
let patchFlagText = shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
2129
|
+
let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
|
|
2130
|
+
let patchFlagText = shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
|
|
2131
2131
|
// check if the fragment actually contains a single valid child with
|
|
2132
2132
|
// the rest being comments
|
|
2133
|
-
if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
2134
|
-
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
2135
|
-
patchFlagText += `, ${shared.PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
2133
|
+
if (children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
|
|
2134
|
+
patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
|
|
2135
|
+
patchFlagText += `, ${shared.PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
|
|
2136
2136
|
}
|
|
2137
2137
|
root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false /* isComponent */);
|
|
2138
2138
|
}
|
|
@@ -2178,29 +2178,29 @@ function traverseNode(node, context) {
|
|
|
2178
2178
|
}
|
|
2179
2179
|
}
|
|
2180
2180
|
switch (node.type) {
|
|
2181
|
-
case 3 /* COMMENT */:
|
|
2181
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2182
2182
|
if (!context.ssr) {
|
|
2183
2183
|
// inject import for the Comment symbol, which is needed for creating
|
|
2184
2184
|
// comment nodes with `createVNode`
|
|
2185
2185
|
context.helper(CREATE_COMMENT);
|
|
2186
2186
|
}
|
|
2187
2187
|
break;
|
|
2188
|
-
case 5 /* INTERPOLATION */:
|
|
2188
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2189
2189
|
// no need to traverse, but we need to inject toString helper
|
|
2190
2190
|
if (!context.ssr) {
|
|
2191
2191
|
context.helper(TO_DISPLAY_STRING);
|
|
2192
2192
|
}
|
|
2193
2193
|
break;
|
|
2194
2194
|
// for container types, further traverse downwards
|
|
2195
|
-
case 9 /* IF */:
|
|
2195
|
+
case 9 /* NodeTypes.IF */:
|
|
2196
2196
|
for (let i = 0; i < node.branches.length; i++) {
|
|
2197
2197
|
traverseNode(node.branches[i], context);
|
|
2198
2198
|
}
|
|
2199
2199
|
break;
|
|
2200
|
-
case 10 /* IF_BRANCH */:
|
|
2201
|
-
case 11 /* FOR */:
|
|
2202
|
-
case 1 /* ELEMENT */:
|
|
2203
|
-
case 0 /* ROOT */:
|
|
2200
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
2201
|
+
case 11 /* NodeTypes.FOR */:
|
|
2202
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2203
|
+
case 0 /* NodeTypes.ROOT */:
|
|
2204
2204
|
traverseChildren(node, context);
|
|
2205
2205
|
break;
|
|
2206
2206
|
}
|
|
@@ -2216,17 +2216,17 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2216
2216
|
? (n) => n === name
|
|
2217
2217
|
: (n) => name.test(n);
|
|
2218
2218
|
return (node, context) => {
|
|
2219
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
2219
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2220
2220
|
const { props } = node;
|
|
2221
2221
|
// structural directive transforms are not concerned with slots
|
|
2222
2222
|
// as they are handled separately in vSlot.ts
|
|
2223
|
-
if (node.tagType === 3 /* TEMPLATE */ && props.some(isVSlot)) {
|
|
2223
|
+
if (node.tagType === 3 /* ElementTypes.TEMPLATE */ && props.some(isVSlot)) {
|
|
2224
2224
|
return;
|
|
2225
2225
|
}
|
|
2226
2226
|
const exitFns = [];
|
|
2227
2227
|
for (let i = 0; i < props.length; i++) {
|
|
2228
2228
|
const prop = props[i];
|
|
2229
|
-
if (prop.type === 7 /* DIRECTIVE */ && matches(prop.name)) {
|
|
2229
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */ && matches(prop.name)) {
|
|
2230
2230
|
// structural directives are removed to avoid infinite recursion
|
|
2231
2231
|
// also we remove them *before* applying so that it can further
|
|
2232
2232
|
// traverse itself in case it moves the node around
|
|
@@ -2274,7 +2274,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
|
|
|
2274
2274
|
if (context.map) {
|
|
2275
2275
|
if (node) {
|
|
2276
2276
|
let name;
|
|
2277
|
-
if (node.type === 4 /* SIMPLE_EXPRESSION */ && !node.isStatic) {
|
|
2277
|
+
if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !node.isStatic) {
|
|
2278
2278
|
const content = node.content.replace(/^_ctx\./, '');
|
|
2279
2279
|
if (content !== node.content && isSimpleIdentifier(content)) {
|
|
2280
2280
|
name = content;
|
|
@@ -2550,7 +2550,7 @@ function genHoists(hoists, context) {
|
|
|
2550
2550
|
for (let i = 0; i < hoists.length; i++) {
|
|
2551
2551
|
const exp = hoists[i];
|
|
2552
2552
|
if (exp) {
|
|
2553
|
-
const needScopeIdWrapper = genScopeId && exp.type === 13 /* VNODE_CALL */;
|
|
2553
|
+
const needScopeIdWrapper = genScopeId && exp.type === 13 /* NodeTypes.VNODE_CALL */;
|
|
2554
2554
|
push(`const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`);
|
|
2555
2555
|
genNode(exp, context);
|
|
2556
2556
|
if (needScopeIdWrapper) {
|
|
@@ -2574,10 +2574,10 @@ function genImports(importsOptions, context) {
|
|
|
2574
2574
|
}
|
|
2575
2575
|
function isText$1(n) {
|
|
2576
2576
|
return (shared.isString(n) ||
|
|
2577
|
-
n.type === 4 /* SIMPLE_EXPRESSION */ ||
|
|
2578
|
-
n.type === 2 /* TEXT */ ||
|
|
2579
|
-
n.type === 5 /* INTERPOLATION */ ||
|
|
2580
|
-
n.type === 8 /* COMPOUND_EXPRESSION */);
|
|
2577
|
+
n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
2578
|
+
n.type === 2 /* NodeTypes.TEXT */ ||
|
|
2579
|
+
n.type === 5 /* NodeTypes.INTERPOLATION */ ||
|
|
2580
|
+
n.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */);
|
|
2581
2581
|
}
|
|
2582
2582
|
function genNodeListAsArray(nodes, context) {
|
|
2583
2583
|
const multilines = nodes.length > 3 ||
|
|
@@ -2622,73 +2622,73 @@ function genNode(node, context) {
|
|
|
2622
2622
|
return;
|
|
2623
2623
|
}
|
|
2624
2624
|
switch (node.type) {
|
|
2625
|
-
case 1 /* ELEMENT */:
|
|
2626
|
-
case 9 /* IF */:
|
|
2627
|
-
case 11 /* FOR */:
|
|
2625
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2626
|
+
case 9 /* NodeTypes.IF */:
|
|
2627
|
+
case 11 /* NodeTypes.FOR */:
|
|
2628
2628
|
assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
|
|
2629
2629
|
`Apply appropriate transforms first.`);
|
|
2630
2630
|
genNode(node.codegenNode, context);
|
|
2631
2631
|
break;
|
|
2632
|
-
case 2 /* TEXT */:
|
|
2632
|
+
case 2 /* NodeTypes.TEXT */:
|
|
2633
2633
|
genText(node, context);
|
|
2634
2634
|
break;
|
|
2635
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
2635
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
2636
2636
|
genExpression(node, context);
|
|
2637
2637
|
break;
|
|
2638
|
-
case 5 /* INTERPOLATION */:
|
|
2638
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2639
2639
|
genInterpolation(node, context);
|
|
2640
2640
|
break;
|
|
2641
|
-
case 12 /* TEXT_CALL */:
|
|
2641
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
2642
2642
|
genNode(node.codegenNode, context);
|
|
2643
2643
|
break;
|
|
2644
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
2644
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
2645
2645
|
genCompoundExpression(node, context);
|
|
2646
2646
|
break;
|
|
2647
|
-
case 3 /* COMMENT */:
|
|
2647
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2648
2648
|
genComment(node, context);
|
|
2649
2649
|
break;
|
|
2650
|
-
case 13 /* VNODE_CALL */:
|
|
2650
|
+
case 13 /* NodeTypes.VNODE_CALL */:
|
|
2651
2651
|
genVNodeCall(node, context);
|
|
2652
2652
|
break;
|
|
2653
|
-
case 14 /* JS_CALL_EXPRESSION */:
|
|
2653
|
+
case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
|
|
2654
2654
|
genCallExpression(node, context);
|
|
2655
2655
|
break;
|
|
2656
|
-
case 15 /* JS_OBJECT_EXPRESSION */:
|
|
2656
|
+
case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
|
|
2657
2657
|
genObjectExpression(node, context);
|
|
2658
2658
|
break;
|
|
2659
|
-
case 17 /* JS_ARRAY_EXPRESSION */:
|
|
2659
|
+
case 17 /* NodeTypes.JS_ARRAY_EXPRESSION */:
|
|
2660
2660
|
genArrayExpression(node, context);
|
|
2661
2661
|
break;
|
|
2662
|
-
case 18 /* JS_FUNCTION_EXPRESSION */:
|
|
2662
|
+
case 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */:
|
|
2663
2663
|
genFunctionExpression(node, context);
|
|
2664
2664
|
break;
|
|
2665
|
-
case 19 /* JS_CONDITIONAL_EXPRESSION */:
|
|
2665
|
+
case 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */:
|
|
2666
2666
|
genConditionalExpression(node, context);
|
|
2667
2667
|
break;
|
|
2668
|
-
case 20 /* JS_CACHE_EXPRESSION */:
|
|
2668
|
+
case 20 /* NodeTypes.JS_CACHE_EXPRESSION */:
|
|
2669
2669
|
genCacheExpression(node, context);
|
|
2670
2670
|
break;
|
|
2671
|
-
case 21 /* JS_BLOCK_STATEMENT */:
|
|
2671
|
+
case 21 /* NodeTypes.JS_BLOCK_STATEMENT */:
|
|
2672
2672
|
genNodeList(node.body, context, true, false);
|
|
2673
2673
|
break;
|
|
2674
2674
|
// SSR only types
|
|
2675
|
-
case 22 /* JS_TEMPLATE_LITERAL */:
|
|
2675
|
+
case 22 /* NodeTypes.JS_TEMPLATE_LITERAL */:
|
|
2676
2676
|
genTemplateLiteral(node, context);
|
|
2677
2677
|
break;
|
|
2678
|
-
case 23 /* JS_IF_STATEMENT */:
|
|
2678
|
+
case 23 /* NodeTypes.JS_IF_STATEMENT */:
|
|
2679
2679
|
genIfStatement(node, context);
|
|
2680
2680
|
break;
|
|
2681
|
-
case 24 /* JS_ASSIGNMENT_EXPRESSION */:
|
|
2681
|
+
case 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */:
|
|
2682
2682
|
genAssignmentExpression(node, context);
|
|
2683
2683
|
break;
|
|
2684
|
-
case 25 /* JS_SEQUENCE_EXPRESSION */:
|
|
2684
|
+
case 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */:
|
|
2685
2685
|
genSequenceExpression(node, context);
|
|
2686
2686
|
break;
|
|
2687
|
-
case 26 /* JS_RETURN_STATEMENT */:
|
|
2687
|
+
case 26 /* NodeTypes.JS_RETURN_STATEMENT */:
|
|
2688
2688
|
genReturnStatement(node, context);
|
|
2689
2689
|
break;
|
|
2690
2690
|
/* istanbul ignore next */
|
|
2691
|
-
case 10 /* IF_BRANCH */:
|
|
2691
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
2692
2692
|
// noop
|
|
2693
2693
|
break;
|
|
2694
2694
|
default:
|
|
@@ -2728,7 +2728,7 @@ function genCompoundExpression(node, context) {
|
|
|
2728
2728
|
}
|
|
2729
2729
|
function genExpressionAsPropertyKey(node, context) {
|
|
2730
2730
|
const { push } = context;
|
|
2731
|
-
if (node.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
2731
|
+
if (node.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
2732
2732
|
push(`[`);
|
|
2733
2733
|
genCompoundExpression(node, context);
|
|
2734
2734
|
push(`]`);
|
|
@@ -2805,7 +2805,7 @@ function genObjectExpression(node, context) {
|
|
|
2805
2805
|
return;
|
|
2806
2806
|
}
|
|
2807
2807
|
const multilines = properties.length > 1 ||
|
|
2808
|
-
(properties.some(p => p.value.type !== 4 /* SIMPLE_EXPRESSION */));
|
|
2808
|
+
(properties.some(p => p.value.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */));
|
|
2809
2809
|
push(multilines ? `{` : `{ `);
|
|
2810
2810
|
multilines && indent();
|
|
2811
2811
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2874,7 +2874,7 @@ function genFunctionExpression(node, context) {
|
|
|
2874
2874
|
function genConditionalExpression(node, context) {
|
|
2875
2875
|
const { test, consequent, alternate, newline: needNewline } = node;
|
|
2876
2876
|
const { push, indent, deindent, newline } = context;
|
|
2877
|
-
if (test.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2877
|
+
if (test.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2878
2878
|
const needsParens = !isSimpleIdentifier(test.content);
|
|
2879
2879
|
needsParens && push(`(`);
|
|
2880
2880
|
genExpression(test, context);
|
|
@@ -2894,7 +2894,7 @@ function genConditionalExpression(node, context) {
|
|
|
2894
2894
|
needNewline && newline();
|
|
2895
2895
|
needNewline || push(` `);
|
|
2896
2896
|
push(`: `);
|
|
2897
|
-
const isNested = alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */;
|
|
2897
|
+
const isNested = alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */;
|
|
2898
2898
|
if (!isNested) {
|
|
2899
2899
|
context.indentLevel++;
|
|
2900
2900
|
}
|
|
@@ -2958,7 +2958,7 @@ function genIfStatement(node, context) {
|
|
|
2958
2958
|
push(`}`);
|
|
2959
2959
|
if (alternate) {
|
|
2960
2960
|
push(` else `);
|
|
2961
|
-
if (alternate.type === 23 /* JS_IF_STATEMENT */) {
|
|
2961
|
+
if (alternate.type === 23 /* NodeTypes.JS_IF_STATEMENT */) {
|
|
2962
2962
|
genIfStatement(alternate, context);
|
|
2963
2963
|
}
|
|
2964
2964
|
else {
|
|
@@ -3315,27 +3315,27 @@ function isReferenced(node, parent, grandparent) {
|
|
|
3315
3315
|
|
|
3316
3316
|
const isLiteralWhitelisted = /*#__PURE__*/ shared.makeMap('true,false,null,this');
|
|
3317
3317
|
const transformExpression = (node, context) => {
|
|
3318
|
-
if (node.type === 5 /* INTERPOLATION */) {
|
|
3318
|
+
if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
3319
3319
|
node.content = processExpression(node.content, context);
|
|
3320
3320
|
}
|
|
3321
|
-
else if (node.type === 1 /* ELEMENT */) {
|
|
3321
|
+
else if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
3322
3322
|
// handle directives on element
|
|
3323
3323
|
for (let i = 0; i < node.props.length; i++) {
|
|
3324
3324
|
const dir = node.props[i];
|
|
3325
3325
|
// do not process for v-on & v-for since they are special handled
|
|
3326
|
-
if (dir.type === 7 /* DIRECTIVE */ && dir.name !== 'for') {
|
|
3326
|
+
if (dir.type === 7 /* NodeTypes.DIRECTIVE */ && dir.name !== 'for') {
|
|
3327
3327
|
const exp = dir.exp;
|
|
3328
3328
|
const arg = dir.arg;
|
|
3329
3329
|
// do not process exp if this is v-on:arg - we need special handling
|
|
3330
3330
|
// for wrapping inline statements.
|
|
3331
3331
|
if (exp &&
|
|
3332
|
-
exp.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
3332
|
+
exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
3333
3333
|
!(dir.name === 'on' && arg)) {
|
|
3334
3334
|
dir.exp = processExpression(exp, context,
|
|
3335
3335
|
// slot args must be processed as function params
|
|
3336
3336
|
dir.name === 'slot');
|
|
3337
3337
|
}
|
|
3338
|
-
if (arg && arg.type === 4 /* SIMPLE_EXPRESSION */ && !arg.isStatic) {
|
|
3338
|
+
if (arg && arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !arg.isStatic) {
|
|
3339
3339
|
dir.arg = processExpression(arg, context);
|
|
3340
3340
|
}
|
|
3341
3341
|
}
|
|
@@ -3364,15 +3364,15 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3364
3364
|
const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
|
|
3365
3365
|
// ({ x } = y)
|
|
3366
3366
|
const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
|
|
3367
|
-
if (type === "setup-const" /* SETUP_CONST */ ||
|
|
3368
|
-
type === "setup-reactive-const" /* SETUP_REACTIVE_CONST */ ||
|
|
3367
|
+
if (type === "setup-const" /* BindingTypes.SETUP_CONST */ ||
|
|
3368
|
+
type === "setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */ ||
|
|
3369
3369
|
localVars[raw]) {
|
|
3370
3370
|
return raw;
|
|
3371
3371
|
}
|
|
3372
|
-
else if (type === "setup-ref" /* SETUP_REF */) {
|
|
3372
|
+
else if (type === "setup-ref" /* BindingTypes.SETUP_REF */) {
|
|
3373
3373
|
return `${raw}.value`;
|
|
3374
3374
|
}
|
|
3375
|
-
else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
|
|
3375
|
+
else if (type === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */) {
|
|
3376
3376
|
// const binding that may or may not be ref
|
|
3377
3377
|
// if it's not a ref, then assignments don't make sense -
|
|
3378
3378
|
// so we ignore the non-ref assignment case and generate code
|
|
@@ -3381,7 +3381,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3381
3381
|
? `${raw}.value`
|
|
3382
3382
|
: `${context.helperString(UNREF)}(${raw})`;
|
|
3383
3383
|
}
|
|
3384
|
-
else if (type === "setup-let" /* SETUP_LET */) {
|
|
3384
|
+
else if (type === "setup-let" /* BindingTypes.SETUP_LET */) {
|
|
3385
3385
|
if (isAssignmentLVal) {
|
|
3386
3386
|
// let binding.
|
|
3387
3387
|
// this is a bit more tricky as we need to cover the case where
|
|
@@ -3417,12 +3417,12 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3417
3417
|
return `${context.helperString(UNREF)}(${raw})`;
|
|
3418
3418
|
}
|
|
3419
3419
|
}
|
|
3420
|
-
else if (type === "props" /* PROPS */) {
|
|
3420
|
+
else if (type === "props" /* BindingTypes.PROPS */) {
|
|
3421
3421
|
// use __props which is generated by compileScript so in ts mode
|
|
3422
3422
|
// it gets correct type
|
|
3423
3423
|
return shared.genPropsAccessExp(raw);
|
|
3424
3424
|
}
|
|
3425
|
-
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3425
|
+
else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
|
|
3426
3426
|
// prop with a different local alias (from defineProps() destructure)
|
|
3427
3427
|
return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
|
|
3428
3428
|
}
|
|
@@ -3432,7 +3432,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3432
3432
|
// setup bindings in non-inline mode
|
|
3433
3433
|
return `$setup.${raw}`;
|
|
3434
3434
|
}
|
|
3435
|
-
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3435
|
+
else if (type === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
|
|
3436
3436
|
return `$props['${bindingMetadata.__propsAliases[raw]}']`;
|
|
3437
3437
|
}
|
|
3438
3438
|
else if (type) {
|
|
@@ -3453,17 +3453,17 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3453
3453
|
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
|
|
3454
3454
|
// const bindings exposed from setup can be skipped for patching but
|
|
3455
3455
|
// cannot be hoisted to module scope
|
|
3456
|
-
if (bindingMetadata[node.content] === "setup-const" /* SETUP_CONST */) {
|
|
3457
|
-
node.constType = 1 /* CAN_SKIP_PATCH */;
|
|
3456
|
+
if (bindingMetadata[node.content] === "setup-const" /* BindingTypes.SETUP_CONST */) {
|
|
3457
|
+
node.constType = 1 /* ConstantTypes.CAN_SKIP_PATCH */;
|
|
3458
3458
|
}
|
|
3459
3459
|
node.content = rewriteIdentifier(rawExp);
|
|
3460
3460
|
}
|
|
3461
3461
|
else if (!isScopeVarReference) {
|
|
3462
3462
|
if (isLiteral) {
|
|
3463
|
-
node.constType = 3 /* CAN_STRINGIFY */;
|
|
3463
|
+
node.constType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
3464
3464
|
}
|
|
3465
3465
|
else {
|
|
3466
|
-
node.constType = 2 /* CAN_HOIST */;
|
|
3466
|
+
node.constType = 2 /* ConstantTypes.CAN_HOIST */;
|
|
3467
3467
|
}
|
|
3468
3468
|
}
|
|
3469
3469
|
return node;
|
|
@@ -3483,7 +3483,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3483
3483
|
}).program;
|
|
3484
3484
|
}
|
|
3485
3485
|
catch (e) {
|
|
3486
|
-
context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
|
|
3486
|
+
context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
|
|
3487
3487
|
return node;
|
|
3488
3488
|
}
|
|
3489
3489
|
const ids = [];
|
|
@@ -3537,7 +3537,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3537
3537
|
source,
|
|
3538
3538
|
start: advancePositionWithClone(node.loc.start, source, start),
|
|
3539
3539
|
end: advancePositionWithClone(node.loc.start, source, end)
|
|
3540
|
-
}, id.isConstant ? 3 /* CAN_STRINGIFY */ : 0 /* NOT_CONSTANT */));
|
|
3540
|
+
}, id.isConstant ? 3 /* ConstantTypes.CAN_STRINGIFY */ : 0 /* ConstantTypes.NOT_CONSTANT */));
|
|
3541
3541
|
if (i === ids.length - 1 && end < rawExp.length) {
|
|
3542
3542
|
children.push(rawExp.slice(end));
|
|
3543
3543
|
}
|
|
@@ -3549,8 +3549,8 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3549
3549
|
else {
|
|
3550
3550
|
ret = node;
|
|
3551
3551
|
ret.constType = bailConstant
|
|
3552
|
-
? 0 /* NOT_CONSTANT */
|
|
3553
|
-
: 3 /* CAN_STRINGIFY */;
|
|
3552
|
+
? 0 /* ConstantTypes.NOT_CONSTANT */
|
|
3553
|
+
: 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
3554
3554
|
}
|
|
3555
3555
|
ret.identifiers = Object.keys(knownIds);
|
|
3556
3556
|
return ret;
|
|
@@ -3570,7 +3570,7 @@ function stringifyExpression(exp) {
|
|
|
3570
3570
|
if (shared.isString(exp)) {
|
|
3571
3571
|
return exp;
|
|
3572
3572
|
}
|
|
3573
|
-
else if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
3573
|
+
else if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
3574
3574
|
return exp.content;
|
|
3575
3575
|
}
|
|
3576
3576
|
else {
|
|
@@ -3590,7 +3590,7 @@ const transformIf = createStructuralDirectiveTransform(/^(if|else|else-if)$/, (n
|
|
|
3590
3590
|
let key = 0;
|
|
3591
3591
|
while (i-- >= 0) {
|
|
3592
3592
|
const sibling = siblings[i];
|
|
3593
|
-
if (sibling && sibling.type === 9 /* IF */) {
|
|
3593
|
+
if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
|
|
3594
3594
|
key += sibling.branches.length;
|
|
3595
3595
|
}
|
|
3596
3596
|
}
|
|
@@ -3613,7 +3613,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3613
3613
|
if (dir.name !== 'else' &&
|
|
3614
3614
|
(!dir.exp || !dir.exp.content.trim())) {
|
|
3615
3615
|
const loc = dir.exp ? dir.exp.loc : node.loc;
|
|
3616
|
-
context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
|
|
3616
|
+
context.onError(createCompilerError(28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */, dir.loc));
|
|
3617
3617
|
dir.exp = createSimpleExpression(`true`, false, loc);
|
|
3618
3618
|
}
|
|
3619
3619
|
if (context.prefixIdentifiers && dir.exp) {
|
|
@@ -3624,7 +3624,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3624
3624
|
if (dir.name === 'if') {
|
|
3625
3625
|
const branch = createIfBranch(node, dir);
|
|
3626
3626
|
const ifNode = {
|
|
3627
|
-
type: 9 /* IF */,
|
|
3627
|
+
type: 9 /* NodeTypes.IF */,
|
|
3628
3628
|
loc: node.loc,
|
|
3629
3629
|
branches: [branch]
|
|
3630
3630
|
};
|
|
@@ -3640,22 +3640,22 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3640
3640
|
let i = siblings.indexOf(node);
|
|
3641
3641
|
while (i-- >= -1) {
|
|
3642
3642
|
const sibling = siblings[i];
|
|
3643
|
-
if (sibling && sibling.type === 3 /* COMMENT */) {
|
|
3643
|
+
if (sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
|
|
3644
3644
|
context.removeNode(sibling);
|
|
3645
3645
|
comments.unshift(sibling);
|
|
3646
3646
|
continue;
|
|
3647
3647
|
}
|
|
3648
3648
|
if (sibling &&
|
|
3649
|
-
sibling.type === 2 /* TEXT */ &&
|
|
3649
|
+
sibling.type === 2 /* NodeTypes.TEXT */ &&
|
|
3650
3650
|
!sibling.content.trim().length) {
|
|
3651
3651
|
context.removeNode(sibling);
|
|
3652
3652
|
continue;
|
|
3653
3653
|
}
|
|
3654
|
-
if (sibling && sibling.type === 9 /* IF */) {
|
|
3654
|
+
if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
|
|
3655
3655
|
// Check if v-else was followed by v-else-if
|
|
3656
3656
|
if (dir.name === 'else-if' &&
|
|
3657
3657
|
sibling.branches[sibling.branches.length - 1].condition === undefined) {
|
|
3658
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3658
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3659
3659
|
}
|
|
3660
3660
|
// move the node to the if node's branches
|
|
3661
3661
|
context.removeNode();
|
|
@@ -3663,7 +3663,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3663
3663
|
if (comments.length &&
|
|
3664
3664
|
// #3619 ignore comments if the v-if is direct child of <transition>
|
|
3665
3665
|
!(context.parent &&
|
|
3666
|
-
context.parent.type === 1 /* ELEMENT */ &&
|
|
3666
|
+
context.parent.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3667
3667
|
isBuiltInType(context.parent.tag, 'transition'))) {
|
|
3668
3668
|
branch.children = [...comments, ...branch.children];
|
|
3669
3669
|
}
|
|
@@ -3673,7 +3673,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3673
3673
|
if (key) {
|
|
3674
3674
|
sibling.branches.forEach(({ userKey }) => {
|
|
3675
3675
|
if (isSameKey(userKey, key)) {
|
|
3676
|
-
context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
|
|
3676
|
+
context.onError(createCompilerError(29 /* ErrorCodes.X_V_IF_SAME_KEY */, branch.userKey.loc));
|
|
3677
3677
|
}
|
|
3678
3678
|
});
|
|
3679
3679
|
}
|
|
@@ -3691,16 +3691,16 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3691
3691
|
context.currentNode = null;
|
|
3692
3692
|
}
|
|
3693
3693
|
else {
|
|
3694
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3694
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3695
3695
|
}
|
|
3696
3696
|
break;
|
|
3697
3697
|
}
|
|
3698
3698
|
}
|
|
3699
3699
|
}
|
|
3700
3700
|
function createIfBranch(node, dir) {
|
|
3701
|
-
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3701
|
+
const isTemplateIf = node.tagType === 3 /* ElementTypes.TEMPLATE */;
|
|
3702
3702
|
return {
|
|
3703
|
-
type: 10 /* IF_BRANCH */,
|
|
3703
|
+
type: 10 /* NodeTypes.IF_BRANCH */,
|
|
3704
3704
|
loc: node.loc,
|
|
3705
3705
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3706
3706
|
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
@@ -3724,26 +3724,26 @@ function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
|
3724
3724
|
}
|
|
3725
3725
|
function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
3726
3726
|
const { helper } = context;
|
|
3727
|
-
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* CAN_HOIST */));
|
|
3727
|
+
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* ConstantTypes.CAN_HOIST */));
|
|
3728
3728
|
const { children } = branch;
|
|
3729
3729
|
const firstChild = children[0];
|
|
3730
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* ELEMENT */;
|
|
3730
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* NodeTypes.ELEMENT */;
|
|
3731
3731
|
if (needFragmentWrapper) {
|
|
3732
|
-
if (children.length === 1 && firstChild.type === 11 /* FOR */) {
|
|
3732
|
+
if (children.length === 1 && firstChild.type === 11 /* NodeTypes.FOR */) {
|
|
3733
3733
|
// optimize away nested fragments when child is a ForNode
|
|
3734
3734
|
const vnodeCall = firstChild.codegenNode;
|
|
3735
3735
|
injectProp(vnodeCall, keyProperty, context);
|
|
3736
3736
|
return vnodeCall;
|
|
3737
3737
|
}
|
|
3738
3738
|
else {
|
|
3739
|
-
let patchFlag = 64 /* STABLE_FRAGMENT */;
|
|
3740
|
-
let patchFlagText = shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
3739
|
+
let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
|
|
3740
|
+
let patchFlagText = shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
|
|
3741
3741
|
// check if the fragment actually contains a single valid child with
|
|
3742
3742
|
// the rest being comments
|
|
3743
3743
|
if (!branch.isTemplateIf &&
|
|
3744
|
-
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3745
|
-
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3746
|
-
patchFlagText += `, ${shared.PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
3744
|
+
children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
|
|
3745
|
+
patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
|
|
3746
|
+
patchFlagText += `, ${shared.PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
|
|
3747
3747
|
}
|
|
3748
3748
|
return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false /* isComponent */, branch.loc);
|
|
3749
3749
|
}
|
|
@@ -3752,7 +3752,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3752
3752
|
const ret = firstChild.codegenNode;
|
|
3753
3753
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3754
3754
|
// Change createVNode to createBlock.
|
|
3755
|
-
if (vnodeCall.type === 13 /* VNODE_CALL */) {
|
|
3755
|
+
if (vnodeCall.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
3756
3756
|
makeBlock(vnodeCall, context);
|
|
3757
3757
|
}
|
|
3758
3758
|
// inject branch key
|
|
@@ -3764,7 +3764,7 @@ function isSameKey(a, b) {
|
|
|
3764
3764
|
if (!a || a.type !== b.type) {
|
|
3765
3765
|
return false;
|
|
3766
3766
|
}
|
|
3767
|
-
if (a.type === 6 /* ATTRIBUTE */) {
|
|
3767
|
+
if (a.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
3768
3768
|
if (a.value.content !== b.value.content) {
|
|
3769
3769
|
return false;
|
|
3770
3770
|
}
|
|
@@ -3776,7 +3776,7 @@ function isSameKey(a, b) {
|
|
|
3776
3776
|
if (exp.type !== branchExp.type) {
|
|
3777
3777
|
return false;
|
|
3778
3778
|
}
|
|
3779
|
-
if (exp.type !== 4 /* SIMPLE_EXPRESSION */ ||
|
|
3779
|
+
if (exp.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
3780
3780
|
exp.isStatic !== branchExp.isStatic ||
|
|
3781
3781
|
exp.content !== branchExp.content) {
|
|
3782
3782
|
return false;
|
|
@@ -3786,15 +3786,15 @@ function isSameKey(a, b) {
|
|
|
3786
3786
|
}
|
|
3787
3787
|
function getParentCondition(node) {
|
|
3788
3788
|
while (true) {
|
|
3789
|
-
if (node.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
3790
|
-
if (node.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
3789
|
+
if (node.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
3790
|
+
if (node.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
3791
3791
|
node = node.alternate;
|
|
3792
3792
|
}
|
|
3793
3793
|
else {
|
|
3794
3794
|
return node;
|
|
3795
3795
|
}
|
|
3796
3796
|
}
|
|
3797
|
-
else if (node.type === 20 /* JS_CACHE_EXPRESSION */) {
|
|
3797
|
+
else if (node.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */) {
|
|
3798
3798
|
node = node.value;
|
|
3799
3799
|
}
|
|
3800
3800
|
}
|
|
@@ -3812,7 +3812,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3812
3812
|
const memo = findDir(node, 'memo');
|
|
3813
3813
|
const keyProp = findProp(node, `key`);
|
|
3814
3814
|
const keyExp = keyProp &&
|
|
3815
|
-
(keyProp.type === 6 /* ATTRIBUTE */
|
|
3815
|
+
(keyProp.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
3816
3816
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3817
3817
|
: keyProp.exp);
|
|
3818
3818
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
@@ -3824,17 +3824,17 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3824
3824
|
if (memo) {
|
|
3825
3825
|
memo.exp = processExpression(memo.exp, context);
|
|
3826
3826
|
}
|
|
3827
|
-
if (keyProperty && keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
3827
|
+
if (keyProperty && keyProp.type !== 6 /* NodeTypes.ATTRIBUTE */) {
|
|
3828
3828
|
keyProperty.value = processExpression(keyProperty.value, context);
|
|
3829
3829
|
}
|
|
3830
3830
|
}
|
|
3831
|
-
const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
3832
|
-
forNode.source.constType > 0 /* NOT_CONSTANT */;
|
|
3831
|
+
const isStableFragment = forNode.source.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
3832
|
+
forNode.source.constType > 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
3833
3833
|
const fragmentFlag = isStableFragment
|
|
3834
|
-
? 64 /* STABLE_FRAGMENT */
|
|
3834
|
+
? 64 /* PatchFlags.STABLE_FRAGMENT */
|
|
3835
3835
|
: keyProp
|
|
3836
|
-
? 128 /* KEYED_FRAGMENT */
|
|
3837
|
-
: 256 /* UNKEYED_FRAGMENT */;
|
|
3836
|
+
? 128 /* PatchFlags.KEYED_FRAGMENT */
|
|
3837
|
+
: 256 /* PatchFlags.UNKEYED_FRAGMENT */;
|
|
3838
3838
|
forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
|
|
3839
3839
|
(` /* ${shared.PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
|
|
3840
3840
|
return () => {
|
|
@@ -3844,16 +3844,16 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3844
3844
|
// check <template v-for> key placement
|
|
3845
3845
|
if (isTemplate) {
|
|
3846
3846
|
node.children.some(c => {
|
|
3847
|
-
if (c.type === 1 /* ELEMENT */) {
|
|
3847
|
+
if (c.type === 1 /* NodeTypes.ELEMENT */) {
|
|
3848
3848
|
const key = findProp(c, 'key');
|
|
3849
3849
|
if (key) {
|
|
3850
|
-
context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
|
|
3850
|
+
context.onError(createCompilerError(33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
|
|
3851
3851
|
return true;
|
|
3852
3852
|
}
|
|
3853
3853
|
}
|
|
3854
3854
|
});
|
|
3855
3855
|
}
|
|
3856
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* ELEMENT */;
|
|
3856
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */;
|
|
3857
3857
|
const slotOutlet = isSlotOutlet(node)
|
|
3858
3858
|
? node
|
|
3859
3859
|
: isTemplate &&
|
|
@@ -3874,8 +3874,8 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3874
3874
|
else if (needFragmentWrapper) {
|
|
3875
3875
|
// <template v-for="..."> with text or multi-elements
|
|
3876
3876
|
// should generate a fragment block for each loop
|
|
3877
|
-
childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* STABLE_FRAGMENT */ +
|
|
3878
|
-
(` /* ${shared.PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
|
|
3877
|
+
childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* PatchFlags.STABLE_FRAGMENT */ +
|
|
3878
|
+
(` /* ${shared.PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */]} */`
|
|
3879
3879
|
), undefined, undefined, true, undefined, false /* isComponent */);
|
|
3880
3880
|
}
|
|
3881
3881
|
else {
|
|
@@ -3932,7 +3932,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3932
3932
|
// target-agnostic transform used for both Client and SSR
|
|
3933
3933
|
function processFor(node, dir, context, processCodegen) {
|
|
3934
3934
|
if (!dir.exp) {
|
|
3935
|
-
context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
|
|
3935
|
+
context.onError(createCompilerError(31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */, dir.loc));
|
|
3936
3936
|
return;
|
|
3937
3937
|
}
|
|
3938
3938
|
const parseResult = parseForExpression(
|
|
@@ -3940,13 +3940,13 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3940
3940
|
// before expression transform.
|
|
3941
3941
|
dir.exp, context);
|
|
3942
3942
|
if (!parseResult) {
|
|
3943
|
-
context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
|
|
3943
|
+
context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
|
|
3944
3944
|
return;
|
|
3945
3945
|
}
|
|
3946
3946
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3947
3947
|
const { source, value, key, index } = parseResult;
|
|
3948
3948
|
const forNode = {
|
|
3949
|
-
type: 11 /* FOR */,
|
|
3949
|
+
type: 11 /* NodeTypes.FOR */,
|
|
3950
3950
|
loc: dir.loc,
|
|
3951
3951
|
source,
|
|
3952
3952
|
valueAlias: value,
|
|
@@ -4058,9 +4058,9 @@ const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
|
4058
4058
|
// Note the exit callback is executed before buildSlots() on the same node,
|
|
4059
4059
|
// so only nested slots see positive numbers.
|
|
4060
4060
|
const trackSlotScopes = (node, context) => {
|
|
4061
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
4062
|
-
(node.tagType === 1 /* COMPONENT */ ||
|
|
4063
|
-
node.tagType === 3 /* TEMPLATE */)) {
|
|
4061
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
4062
|
+
(node.tagType === 1 /* ElementTypes.COMPONENT */ ||
|
|
4063
|
+
node.tagType === 3 /* ElementTypes.TEMPLATE */)) {
|
|
4064
4064
|
// We are only checking non-empty v-slot here
|
|
4065
4065
|
// since we only care about slots that introduce scope variables.
|
|
4066
4066
|
const vSlot = findDir(node, 'slot');
|
|
@@ -4133,20 +4133,21 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4133
4133
|
let hasNamedDefaultSlot = false;
|
|
4134
4134
|
const implicitDefaultChildren = [];
|
|
4135
4135
|
const seenSlotNames = new Set();
|
|
4136
|
+
let conditionalBranchIndex = 0;
|
|
4136
4137
|
for (let i = 0; i < children.length; i++) {
|
|
4137
4138
|
const slotElement = children[i];
|
|
4138
4139
|
let slotDir;
|
|
4139
4140
|
if (!isTemplateNode(slotElement) ||
|
|
4140
4141
|
!(slotDir = findDir(slotElement, 'slot', true))) {
|
|
4141
4142
|
// not a <template v-slot>, skip.
|
|
4142
|
-
if (slotElement.type !== 3 /* COMMENT */) {
|
|
4143
|
+
if (slotElement.type !== 3 /* NodeTypes.COMMENT */) {
|
|
4143
4144
|
implicitDefaultChildren.push(slotElement);
|
|
4144
4145
|
}
|
|
4145
4146
|
continue;
|
|
4146
4147
|
}
|
|
4147
4148
|
if (onComponentSlot) {
|
|
4148
4149
|
// already has on-component slot - this is incorrect usage.
|
|
4149
|
-
context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
|
|
4150
|
+
context.onError(createCompilerError(37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
|
|
4150
4151
|
break;
|
|
4151
4152
|
}
|
|
4152
4153
|
hasTemplateSlots = true;
|
|
@@ -4167,7 +4168,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4167
4168
|
let vFor;
|
|
4168
4169
|
if ((vIf = findDir(slotElement, 'if'))) {
|
|
4169
4170
|
hasDynamicSlots = true;
|
|
4170
|
-
dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
|
|
4171
|
+
dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
|
|
4171
4172
|
}
|
|
4172
4173
|
else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
|
|
4173
4174
|
// find adjacent v-if
|
|
@@ -4175,7 +4176,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4175
4176
|
let prev;
|
|
4176
4177
|
while (j--) {
|
|
4177
4178
|
prev = children[j];
|
|
4178
|
-
if (prev.type !== 3 /* COMMENT */) {
|
|
4179
|
+
if (prev.type !== 3 /* NodeTypes.COMMENT */) {
|
|
4179
4180
|
break;
|
|
4180
4181
|
}
|
|
4181
4182
|
}
|
|
@@ -4185,15 +4186,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4185
4186
|
i--;
|
|
4186
4187
|
// attach this slot to previous conditional
|
|
4187
4188
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
4188
|
-
while (conditional.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
4189
|
+
while (conditional.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
4189
4190
|
conditional = conditional.alternate;
|
|
4190
4191
|
}
|
|
4191
4192
|
conditional.alternate = vElse.exp
|
|
4192
|
-
? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
|
|
4193
|
-
: buildDynamicSlot(slotName, slotFunction);
|
|
4193
|
+
? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback)
|
|
4194
|
+
: buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
|
4194
4195
|
}
|
|
4195
4196
|
else {
|
|
4196
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
|
|
4197
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
|
|
4197
4198
|
}
|
|
4198
4199
|
}
|
|
4199
4200
|
else if ((vFor = findDir(slotElement, 'for'))) {
|
|
@@ -4209,14 +4210,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4209
4210
|
]));
|
|
4210
4211
|
}
|
|
4211
4212
|
else {
|
|
4212
|
-
context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
|
|
4213
|
+
context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
|
|
4213
4214
|
}
|
|
4214
4215
|
}
|
|
4215
4216
|
else {
|
|
4216
4217
|
// check duplicate static names
|
|
4217
4218
|
if (staticSlotName) {
|
|
4218
4219
|
if (seenSlotNames.has(staticSlotName)) {
|
|
4219
|
-
context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
|
|
4220
|
+
context.onError(createCompilerError(38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
|
|
4220
4221
|
continue;
|
|
4221
4222
|
}
|
|
4222
4223
|
seenSlotNames.add(staticSlotName);
|
|
@@ -4246,7 +4247,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4246
4247
|
implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
|
|
4247
4248
|
// implicit default slot (mixed with named slots)
|
|
4248
4249
|
if (hasNamedDefaultSlot) {
|
|
4249
|
-
context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
|
|
4250
|
+
context.onError(createCompilerError(39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
|
|
4250
4251
|
}
|
|
4251
4252
|
else {
|
|
4252
4253
|
slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
|
|
@@ -4254,10 +4255,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4254
4255
|
}
|
|
4255
4256
|
}
|
|
4256
4257
|
const slotFlag = hasDynamicSlots
|
|
4257
|
-
? 2 /* DYNAMIC */
|
|
4258
|
+
? 2 /* SlotFlags.DYNAMIC */
|
|
4258
4259
|
: hasForwardedSlots(node.children)
|
|
4259
|
-
? 3 /* FORWARDED */
|
|
4260
|
-
: 1 /* STABLE */;
|
|
4260
|
+
? 3 /* SlotFlags.FORWARDED */
|
|
4261
|
+
: 1 /* SlotFlags.STABLE */;
|
|
4261
4262
|
let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
|
|
4262
4263
|
// 2 = compiled but dynamic = can skip normalization, but must run diff
|
|
4263
4264
|
// 1 = compiled and static = can skip normalization AND diff as optimized
|
|
@@ -4273,28 +4274,32 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
4273
4274
|
hasDynamicSlots
|
|
4274
4275
|
};
|
|
4275
4276
|
}
|
|
4276
|
-
function buildDynamicSlot(name, fn) {
|
|
4277
|
-
|
|
4277
|
+
function buildDynamicSlot(name, fn, index) {
|
|
4278
|
+
const props = [
|
|
4278
4279
|
createObjectProperty(`name`, name),
|
|
4279
4280
|
createObjectProperty(`fn`, fn)
|
|
4280
|
-
]
|
|
4281
|
+
];
|
|
4282
|
+
if (index != null) {
|
|
4283
|
+
props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
|
|
4284
|
+
}
|
|
4285
|
+
return createObjectExpression(props);
|
|
4281
4286
|
}
|
|
4282
4287
|
function hasForwardedSlots(children) {
|
|
4283
4288
|
for (let i = 0; i < children.length; i++) {
|
|
4284
4289
|
const child = children[i];
|
|
4285
4290
|
switch (child.type) {
|
|
4286
|
-
case 1 /* ELEMENT */:
|
|
4287
|
-
if (child.tagType === 2 /* SLOT */ ||
|
|
4291
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
4292
|
+
if (child.tagType === 2 /* ElementTypes.SLOT */ ||
|
|
4288
4293
|
hasForwardedSlots(child.children)) {
|
|
4289
4294
|
return true;
|
|
4290
4295
|
}
|
|
4291
4296
|
break;
|
|
4292
|
-
case 9 /* IF */:
|
|
4297
|
+
case 9 /* NodeTypes.IF */:
|
|
4293
4298
|
if (hasForwardedSlots(child.branches))
|
|
4294
4299
|
return true;
|
|
4295
4300
|
break;
|
|
4296
|
-
case 10 /* IF_BRANCH */:
|
|
4297
|
-
case 11 /* FOR */:
|
|
4301
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
4302
|
+
case 11 /* NodeTypes.FOR */:
|
|
4298
4303
|
if (hasForwardedSlots(child.children))
|
|
4299
4304
|
return true;
|
|
4300
4305
|
break;
|
|
@@ -4303,9 +4308,9 @@ function hasForwardedSlots(children) {
|
|
|
4303
4308
|
return false;
|
|
4304
4309
|
}
|
|
4305
4310
|
function isNonWhitespaceContent(node) {
|
|
4306
|
-
if (node.type !== 2 /* TEXT */ && node.type !== 12 /* TEXT_CALL */)
|
|
4311
|
+
if (node.type !== 2 /* NodeTypes.TEXT */ && node.type !== 12 /* NodeTypes.TEXT_CALL */)
|
|
4307
4312
|
return true;
|
|
4308
|
-
return node.type === 2 /* TEXT */
|
|
4313
|
+
return node.type === 2 /* NodeTypes.TEXT */
|
|
4309
4314
|
? !!node.content.trim()
|
|
4310
4315
|
: isNonWhitespaceContent(node.content);
|
|
4311
4316
|
}
|
|
@@ -4319,13 +4324,13 @@ const transformElement = (node, context) => {
|
|
|
4319
4324
|
// processed and merged.
|
|
4320
4325
|
return function postTransformElement() {
|
|
4321
4326
|
node = context.currentNode;
|
|
4322
|
-
if (!(node.type === 1 /* ELEMENT */ &&
|
|
4323
|
-
(node.tagType === 0 /* ELEMENT */ ||
|
|
4324
|
-
node.tagType === 1 /* COMPONENT */))) {
|
|
4327
|
+
if (!(node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
4328
|
+
(node.tagType === 0 /* ElementTypes.ELEMENT */ ||
|
|
4329
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */))) {
|
|
4325
4330
|
return;
|
|
4326
4331
|
}
|
|
4327
4332
|
const { tag, props } = node;
|
|
4328
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
4333
|
+
const isComponent = node.tagType === 1 /* ElementTypes.COMPONENT */;
|
|
4329
4334
|
// The goal of the transform is to create a codegenNode implementing the
|
|
4330
4335
|
// VNodeCall interface.
|
|
4331
4336
|
let vnodeTag = isComponent
|
|
@@ -4376,9 +4381,9 @@ const transformElement = (node, context) => {
|
|
|
4376
4381
|
// collected by a parent block.
|
|
4377
4382
|
shouldUseBlock = true;
|
|
4378
4383
|
// 2. Force keep-alive to always be updated, since it uses raw children.
|
|
4379
|
-
patchFlag |= 1024 /* DYNAMIC_SLOTS */;
|
|
4384
|
+
patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
|
|
4380
4385
|
if (node.children.length > 1) {
|
|
4381
|
-
context.onError(createCompilerError(45 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
|
|
4386
|
+
context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
|
|
4382
4387
|
start: node.children[0].loc.start,
|
|
4383
4388
|
end: node.children[node.children.length - 1].loc.end,
|
|
4384
4389
|
source: ''
|
|
@@ -4394,22 +4399,22 @@ const transformElement = (node, context) => {
|
|
|
4394
4399
|
const { slots, hasDynamicSlots } = buildSlots(node, context);
|
|
4395
4400
|
vnodeChildren = slots;
|
|
4396
4401
|
if (hasDynamicSlots) {
|
|
4397
|
-
patchFlag |= 1024 /* DYNAMIC_SLOTS */;
|
|
4402
|
+
patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
|
|
4398
4403
|
}
|
|
4399
4404
|
}
|
|
4400
4405
|
else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
|
4401
4406
|
const child = node.children[0];
|
|
4402
4407
|
const type = child.type;
|
|
4403
4408
|
// check for dynamic text children
|
|
4404
|
-
const hasDynamicTextChild = type === 5 /* INTERPOLATION */ ||
|
|
4405
|
-
type === 8 /* COMPOUND_EXPRESSION */;
|
|
4409
|
+
const hasDynamicTextChild = type === 5 /* NodeTypes.INTERPOLATION */ ||
|
|
4410
|
+
type === 8 /* NodeTypes.COMPOUND_EXPRESSION */;
|
|
4406
4411
|
if (hasDynamicTextChild &&
|
|
4407
|
-
getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
|
|
4408
|
-
patchFlag |= 1 /* TEXT */;
|
|
4412
|
+
getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
4413
|
+
patchFlag |= 1 /* PatchFlags.TEXT */;
|
|
4409
4414
|
}
|
|
4410
4415
|
// pass directly if the only child is a text node
|
|
4411
4416
|
// (plain / interpolation / expression)
|
|
4412
|
-
if (hasDynamicTextChild || type === 2 /* TEXT */) {
|
|
4417
|
+
if (hasDynamicTextChild || type === 2 /* NodeTypes.TEXT */) {
|
|
4413
4418
|
vnodeChildren = child;
|
|
4414
4419
|
}
|
|
4415
4420
|
else {
|
|
@@ -4451,8 +4456,8 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4451
4456
|
const isProp = findProp(node, 'is');
|
|
4452
4457
|
if (isProp) {
|
|
4453
4458
|
if (isExplicitDynamic ||
|
|
4454
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))) {
|
|
4455
|
-
const exp = isProp.type === 6 /* ATTRIBUTE */
|
|
4459
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))) {
|
|
4460
|
+
const exp = isProp.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
4456
4461
|
? isProp.value && createSimpleExpression(isProp.value.content, true)
|
|
4457
4462
|
: isProp.exp;
|
|
4458
4463
|
if (exp) {
|
|
@@ -4461,7 +4466,7 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4461
4466
|
]);
|
|
4462
4467
|
}
|
|
4463
4468
|
}
|
|
4464
|
-
else if (isProp.type === 6 /* ATTRIBUTE */ &&
|
|
4469
|
+
else if (isProp.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
4465
4470
|
isProp.value.content.startsWith('vue:')) {
|
|
4466
4471
|
// <button is="vue:xxx">
|
|
4467
4472
|
// if not <component>, only is value that starts with "vue:" will be
|
|
@@ -4535,17 +4540,17 @@ function resolveSetupReference(name, context) {
|
|
|
4535
4540
|
return PascalName;
|
|
4536
4541
|
}
|
|
4537
4542
|
};
|
|
4538
|
-
const fromConst = checkType("setup-const" /* SETUP_CONST */) ||
|
|
4539
|
-
checkType("setup-reactive-const" /* SETUP_REACTIVE_CONST */);
|
|
4543
|
+
const fromConst = checkType("setup-const" /* BindingTypes.SETUP_CONST */) ||
|
|
4544
|
+
checkType("setup-reactive-const" /* BindingTypes.SETUP_REACTIVE_CONST */);
|
|
4540
4545
|
if (fromConst) {
|
|
4541
4546
|
return context.inline
|
|
4542
4547
|
? // in inline mode, const setup bindings (e.g. imports) can be used as-is
|
|
4543
4548
|
fromConst
|
|
4544
4549
|
: `$setup[${JSON.stringify(fromConst)}]`;
|
|
4545
4550
|
}
|
|
4546
|
-
const fromMaybeRef = checkType("setup-let" /* SETUP_LET */) ||
|
|
4547
|
-
checkType("setup-ref" /* SETUP_REF */) ||
|
|
4548
|
-
checkType("setup-maybe-ref" /* SETUP_MAYBE_REF */);
|
|
4551
|
+
const fromMaybeRef = checkType("setup-let" /* BindingTypes.SETUP_LET */) ||
|
|
4552
|
+
checkType("setup-ref" /* BindingTypes.SETUP_REF */) ||
|
|
4553
|
+
checkType("setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
|
|
4549
4554
|
if (fromMaybeRef) {
|
|
4550
4555
|
return context.inline
|
|
4551
4556
|
? // setup scope bindings that may be refs need to be unrefed
|
|
@@ -4587,9 +4592,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4587
4592
|
if (isEventHandler && shared.isReservedProp(name)) {
|
|
4588
4593
|
hasVnodeHook = true;
|
|
4589
4594
|
}
|
|
4590
|
-
if (value.type === 20 /* JS_CACHE_EXPRESSION */ ||
|
|
4591
|
-
((value.type === 4 /* SIMPLE_EXPRESSION */ ||
|
|
4592
|
-
value.type === 8 /* COMPOUND_EXPRESSION */) &&
|
|
4595
|
+
if (value.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */ ||
|
|
4596
|
+
((value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
4597
|
+
value.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) &&
|
|
4593
4598
|
getConstantType(value, context) > 0)) {
|
|
4594
4599
|
// skip if the prop is a cached handler or has constant value
|
|
4595
4600
|
return;
|
|
@@ -4620,7 +4625,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4620
4625
|
for (let i = 0; i < props.length; i++) {
|
|
4621
4626
|
// static attribute
|
|
4622
4627
|
const prop = props[i];
|
|
4623
|
-
if (prop.type === 6 /* ATTRIBUTE */) {
|
|
4628
|
+
if (prop.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
4624
4629
|
const { loc, name, value } = prop;
|
|
4625
4630
|
let isStatic = true;
|
|
4626
4631
|
if (name === 'ref') {
|
|
@@ -4642,7 +4647,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4642
4647
|
if (name === 'is' &&
|
|
4643
4648
|
(isComponentTag(tag) ||
|
|
4644
4649
|
(value && value.content.startsWith('vue:')) ||
|
|
4645
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
|
|
4650
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context)))) {
|
|
4646
4651
|
continue;
|
|
4647
4652
|
}
|
|
4648
4653
|
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
|
|
@@ -4655,7 +4660,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4655
4660
|
// skip v-slot - it is handled by its dedicated transform.
|
|
4656
4661
|
if (name === 'slot') {
|
|
4657
4662
|
if (!isComponent) {
|
|
4658
|
-
context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
|
|
4663
|
+
context.onError(createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, loc));
|
|
4659
4664
|
}
|
|
4660
4665
|
continue;
|
|
4661
4666
|
}
|
|
@@ -4668,7 +4673,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4668
4673
|
(isVBind &&
|
|
4669
4674
|
isStaticArgOf(arg, 'is') &&
|
|
4670
4675
|
(isComponentTag(tag) ||
|
|
4671
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
|
|
4676
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))))) {
|
|
4672
4677
|
continue;
|
|
4673
4678
|
}
|
|
4674
4679
|
// skip v-on in SSR compilation
|
|
@@ -4699,9 +4704,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4699
4704
|
// 2.x v-bind object order compat
|
|
4700
4705
|
{
|
|
4701
4706
|
const hasOverridableKeys = mergeArgs.some(arg => {
|
|
4702
|
-
if (arg.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
4707
|
+
if (arg.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
4703
4708
|
return arg.properties.some(({ key }) => {
|
|
4704
|
-
if (key.type !== 4 /* SIMPLE_EXPRESSION */ ||
|
|
4709
|
+
if (key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
4705
4710
|
!key.isStatic) {
|
|
4706
4711
|
return true;
|
|
4707
4712
|
}
|
|
@@ -4716,10 +4721,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4716
4721
|
}
|
|
4717
4722
|
});
|
|
4718
4723
|
if (hasOverridableKeys) {
|
|
4719
|
-
checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
|
|
4724
|
+
checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
|
|
4720
4725
|
}
|
|
4721
4726
|
}
|
|
4722
|
-
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context)) {
|
|
4727
|
+
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
|
|
4723
4728
|
mergeArgs.unshift(exp);
|
|
4724
4729
|
continue;
|
|
4725
4730
|
}
|
|
@@ -4729,17 +4734,17 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4729
4734
|
else {
|
|
4730
4735
|
// v-on="obj" -> toHandlers(obj)
|
|
4731
4736
|
mergeArgs.push({
|
|
4732
|
-
type: 14 /* JS_CALL_EXPRESSION */,
|
|
4737
|
+
type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
|
|
4733
4738
|
loc,
|
|
4734
4739
|
callee: context.helper(TO_HANDLERS),
|
|
4735
|
-
arguments: [exp]
|
|
4740
|
+
arguments: isComponent ? [exp] : [exp, `true`]
|
|
4736
4741
|
});
|
|
4737
4742
|
}
|
|
4738
4743
|
}
|
|
4739
4744
|
else {
|
|
4740
4745
|
context.onError(createCompilerError(isVBind
|
|
4741
|
-
? 34 /* X_V_BIND_NO_EXPRESSION */
|
|
4742
|
-
: 35 /* X_V_ON_NO_EXPRESSION */, loc));
|
|
4746
|
+
? 34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */
|
|
4747
|
+
: 35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
|
|
4743
4748
|
}
|
|
4744
4749
|
continue;
|
|
4745
4750
|
}
|
|
@@ -4786,31 +4791,31 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4786
4791
|
}
|
|
4787
4792
|
// patchFlag analysis
|
|
4788
4793
|
if (hasDynamicKeys) {
|
|
4789
|
-
patchFlag |= 16 /* FULL_PROPS */;
|
|
4794
|
+
patchFlag |= 16 /* PatchFlags.FULL_PROPS */;
|
|
4790
4795
|
}
|
|
4791
4796
|
else {
|
|
4792
4797
|
if (hasClassBinding && !isComponent) {
|
|
4793
|
-
patchFlag |= 2 /* CLASS */;
|
|
4798
|
+
patchFlag |= 2 /* PatchFlags.CLASS */;
|
|
4794
4799
|
}
|
|
4795
4800
|
if (hasStyleBinding && !isComponent) {
|
|
4796
|
-
patchFlag |= 4 /* STYLE */;
|
|
4801
|
+
patchFlag |= 4 /* PatchFlags.STYLE */;
|
|
4797
4802
|
}
|
|
4798
4803
|
if (dynamicPropNames.length) {
|
|
4799
|
-
patchFlag |= 8 /* PROPS */;
|
|
4804
|
+
patchFlag |= 8 /* PatchFlags.PROPS */;
|
|
4800
4805
|
}
|
|
4801
4806
|
if (hasHydrationEventBinding) {
|
|
4802
|
-
patchFlag |= 32 /* HYDRATE_EVENTS */;
|
|
4807
|
+
patchFlag |= 32 /* PatchFlags.HYDRATE_EVENTS */;
|
|
4803
4808
|
}
|
|
4804
4809
|
}
|
|
4805
4810
|
if (!shouldUseBlock &&
|
|
4806
|
-
(patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
|
|
4811
|
+
(patchFlag === 0 || patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) &&
|
|
4807
4812
|
(hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
|
4808
|
-
patchFlag |= 512 /* NEED_PATCH */;
|
|
4813
|
+
patchFlag |= 512 /* PatchFlags.NEED_PATCH */;
|
|
4809
4814
|
}
|
|
4810
4815
|
// pre-normalize props, SSR is skipped for now
|
|
4811
4816
|
if (!context.inSSR && propsExpression) {
|
|
4812
4817
|
switch (propsExpression.type) {
|
|
4813
|
-
case 15 /* JS_OBJECT_EXPRESSION */:
|
|
4818
|
+
case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
|
|
4814
4819
|
// means that there is no v-bind,
|
|
4815
4820
|
// but still need to deal with dynamic key binding
|
|
4816
4821
|
let classKeyIndex = -1;
|
|
@@ -4841,11 +4846,11 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4841
4846
|
// the static style is compiled into an object,
|
|
4842
4847
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4843
4848
|
(hasStyleBinding ||
|
|
4844
|
-
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4849
|
+
(styleProp.value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
4845
4850
|
styleProp.value.content.trim()[0] === `[`) ||
|
|
4846
4851
|
// v-bind:style and style both exist,
|
|
4847
4852
|
// v-bind:style with static literal object
|
|
4848
|
-
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
4853
|
+
styleProp.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */)) {
|
|
4849
4854
|
styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
|
|
4850
4855
|
}
|
|
4851
4856
|
}
|
|
@@ -4854,7 +4859,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4854
4859
|
propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
|
4855
4860
|
}
|
|
4856
4861
|
break;
|
|
4857
|
-
case 14 /* JS_CALL_EXPRESSION */:
|
|
4862
|
+
case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
|
|
4858
4863
|
// mergeProps call, do nothing
|
|
4859
4864
|
break;
|
|
4860
4865
|
default:
|
|
@@ -4887,7 +4892,7 @@ function dedupeProperties(properties) {
|
|
|
4887
4892
|
for (let i = 0; i < properties.length; i++) {
|
|
4888
4893
|
const prop = properties[i];
|
|
4889
4894
|
// dynamic keys are always allowed
|
|
4890
|
-
if (prop.key.type === 8 /* COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
|
|
4895
|
+
if (prop.key.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
|
|
4891
4896
|
deduped.push(prop);
|
|
4892
4897
|
continue;
|
|
4893
4898
|
}
|
|
@@ -4907,7 +4912,7 @@ function dedupeProperties(properties) {
|
|
|
4907
4912
|
return deduped;
|
|
4908
4913
|
}
|
|
4909
4914
|
function mergeAsArray(existing, incoming) {
|
|
4910
|
-
if (existing.value.type === 17 /* JS_ARRAY_EXPRESSION */) {
|
|
4915
|
+
if (existing.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
|
|
4911
4916
|
existing.value.elements.push(incoming.value);
|
|
4912
4917
|
}
|
|
4913
4918
|
else {
|
|
@@ -5020,7 +5025,7 @@ function processSlotOutlet(node, context) {
|
|
|
5020
5025
|
const nonNameProps = [];
|
|
5021
5026
|
for (let i = 0; i < node.props.length; i++) {
|
|
5022
5027
|
const p = node.props[i];
|
|
5023
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
5028
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
5024
5029
|
if (p.value) {
|
|
5025
5030
|
if (p.name === 'name') {
|
|
5026
5031
|
slotName = JSON.stringify(p.value.content);
|
|
@@ -5048,7 +5053,7 @@ function processSlotOutlet(node, context) {
|
|
|
5048
5053
|
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
5049
5054
|
slotProps = props;
|
|
5050
5055
|
if (directives.length) {
|
|
5051
|
-
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
5056
|
+
context.onError(createCompilerError(36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
5052
5057
|
}
|
|
5053
5058
|
}
|
|
5054
5059
|
return {
|
|
@@ -5061,18 +5066,26 @@ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?functio
|
|
|
5061
5066
|
const transformOn = (dir, node, context, augmentor) => {
|
|
5062
5067
|
const { loc, modifiers, arg } = dir;
|
|
5063
5068
|
if (!dir.exp && !modifiers.length) {
|
|
5064
|
-
context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
|
|
5069
|
+
context.onError(createCompilerError(35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
|
|
5065
5070
|
}
|
|
5066
5071
|
let eventName;
|
|
5067
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5072
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5068
5073
|
if (arg.isStatic) {
|
|
5069
5074
|
let rawName = arg.content;
|
|
5070
5075
|
// TODO deprecate @vnodeXXX usage
|
|
5071
5076
|
if (rawName.startsWith('vue:')) {
|
|
5072
5077
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
5073
5078
|
}
|
|
5074
|
-
|
|
5075
|
-
|
|
5079
|
+
const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
|
|
5080
|
+
rawName.startsWith('vnode') ||
|
|
5081
|
+
!/[A-Z]/.test(rawName)
|
|
5082
|
+
? // for component and vnode lifecycle event listeners, auto convert
|
|
5083
|
+
// it to camelCase. See issue #2249
|
|
5084
|
+
shared.toHandlerKey(shared.camelize(rawName))
|
|
5085
|
+
// preserve case for plain element listeners that have uppercase
|
|
5086
|
+
// letters, as these may be custom elements' custom events
|
|
5087
|
+
: `on:${rawName}`;
|
|
5088
|
+
eventName = createSimpleExpression(eventString, true, arg.loc);
|
|
5076
5089
|
}
|
|
5077
5090
|
else {
|
|
5078
5091
|
// #2388
|
|
@@ -5112,13 +5125,13 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
5112
5125
|
!context.inVOnce &&
|
|
5113
5126
|
// runtime constants don't need to be cached
|
|
5114
5127
|
// (this is analyzed by compileScript in SFC <script setup>)
|
|
5115
|
-
!(exp.type === 4 /* SIMPLE_EXPRESSION */ && exp.constType > 0) &&
|
|
5128
|
+
!(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && exp.constType > 0) &&
|
|
5116
5129
|
// #1541 bail if this is a member exp handler passed to a component -
|
|
5117
5130
|
// we need to use the original function to preserve arity,
|
|
5118
5131
|
// e.g. <transition> relies on checking cb.length to determine
|
|
5119
5132
|
// transition end handling. Inline function is ok since its arity
|
|
5120
5133
|
// is preserved even when cached.
|
|
5121
|
-
!(isMemberExp && node.tagType === 1 /* COMPONENT */) &&
|
|
5134
|
+
!(isMemberExp && node.tagType === 1 /* ElementTypes.COMPONENT */) &&
|
|
5122
5135
|
// bail if the function references closure variables (v-for, v-slot)
|
|
5123
5136
|
// it must be passed fresh to avoid stale values.
|
|
5124
5137
|
!hasScopeRef(exp, context.identifiers);
|
|
@@ -5127,7 +5140,7 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
5127
5140
|
// below) so that it always accesses the latest value when called - thus
|
|
5128
5141
|
// avoiding the need to be patched.
|
|
5129
5142
|
if (shouldCache && isMemberExp) {
|
|
5130
|
-
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5143
|
+
if (exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5131
5144
|
exp.content = `${exp.content} && ${exp.content}(...args)`;
|
|
5132
5145
|
}
|
|
5133
5146
|
else {
|
|
@@ -5174,7 +5187,7 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
5174
5187
|
const transformBind = (dir, _node, context) => {
|
|
5175
5188
|
const { exp, modifiers, loc } = dir;
|
|
5176
5189
|
const arg = dir.arg;
|
|
5177
|
-
if (arg.type !== 4 /* SIMPLE_EXPRESSION */) {
|
|
5190
|
+
if (arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5178
5191
|
arg.children.unshift(`(`);
|
|
5179
5192
|
arg.children.push(`) || ""`);
|
|
5180
5193
|
}
|
|
@@ -5183,7 +5196,7 @@ const transformBind = (dir, _node, context) => {
|
|
|
5183
5196
|
}
|
|
5184
5197
|
// .sync is replaced by v-model:arg
|
|
5185
5198
|
if (modifiers.includes('camel')) {
|
|
5186
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5199
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5187
5200
|
if (arg.isStatic) {
|
|
5188
5201
|
arg.content = shared.camelize(arg.content);
|
|
5189
5202
|
}
|
|
@@ -5205,8 +5218,8 @@ const transformBind = (dir, _node, context) => {
|
|
|
5205
5218
|
}
|
|
5206
5219
|
}
|
|
5207
5220
|
if (!exp ||
|
|
5208
|
-
(exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
|
|
5209
|
-
context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
|
|
5221
|
+
(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !exp.content.trim())) {
|
|
5222
|
+
context.onError(createCompilerError(34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */, loc));
|
|
5210
5223
|
return {
|
|
5211
5224
|
props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
|
|
5212
5225
|
};
|
|
@@ -5216,7 +5229,7 @@ const transformBind = (dir, _node, context) => {
|
|
|
5216
5229
|
};
|
|
5217
5230
|
};
|
|
5218
5231
|
const injectPrefix = (arg, prefix) => {
|
|
5219
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5232
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5220
5233
|
if (arg.isStatic) {
|
|
5221
5234
|
arg.content = prefix + arg.content;
|
|
5222
5235
|
}
|
|
@@ -5233,10 +5246,10 @@ const injectPrefix = (arg, prefix) => {
|
|
|
5233
5246
|
// Merge adjacent text nodes and expressions into a single expression
|
|
5234
5247
|
// e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
|
|
5235
5248
|
const transformText = (node, context) => {
|
|
5236
|
-
if (node.type === 0 /* ROOT */ ||
|
|
5237
|
-
node.type === 1 /* ELEMENT */ ||
|
|
5238
|
-
node.type === 11 /* FOR */ ||
|
|
5239
|
-
node.type === 10 /* IF_BRANCH */) {
|
|
5249
|
+
if (node.type === 0 /* NodeTypes.ROOT */ ||
|
|
5250
|
+
node.type === 1 /* NodeTypes.ELEMENT */ ||
|
|
5251
|
+
node.type === 11 /* NodeTypes.FOR */ ||
|
|
5252
|
+
node.type === 10 /* NodeTypes.IF_BRANCH */) {
|
|
5240
5253
|
// perform the transform on node exit so that all expressions have already
|
|
5241
5254
|
// been processed.
|
|
5242
5255
|
return () => {
|
|
@@ -5271,15 +5284,15 @@ const transformText = (node, context) => {
|
|
|
5271
5284
|
// setting textContent of the element.
|
|
5272
5285
|
// for component root it's always normalized anyway.
|
|
5273
5286
|
(children.length === 1 &&
|
|
5274
|
-
(node.type === 0 /* ROOT */ ||
|
|
5275
|
-
(node.type === 1 /* ELEMENT */ &&
|
|
5276
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
5287
|
+
(node.type === 0 /* NodeTypes.ROOT */ ||
|
|
5288
|
+
(node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
5289
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
5277
5290
|
// #3756
|
|
5278
5291
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
5279
5292
|
// we need to avoid setting textContent of the element at runtime
|
|
5280
5293
|
// to avoid accidentally overwriting the DOM elements added
|
|
5281
5294
|
// by the user through custom directives.
|
|
5282
|
-
!node.props.find(p => p.type === 7 /* DIRECTIVE */ &&
|
|
5295
|
+
!node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
5283
5296
|
!context.directiveTransforms[p.name]) &&
|
|
5284
5297
|
// in compat mode, <template> tags with no special directives
|
|
5285
5298
|
// will be rendered as a fragment so its children must be
|
|
@@ -5291,21 +5304,21 @@ const transformText = (node, context) => {
|
|
|
5291
5304
|
// runtime normalization.
|
|
5292
5305
|
for (let i = 0; i < children.length; i++) {
|
|
5293
5306
|
const child = children[i];
|
|
5294
|
-
if (isText(child) || child.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
5307
|
+
if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
5295
5308
|
const callArgs = [];
|
|
5296
5309
|
// createTextVNode defaults to single whitespace, so if it is a
|
|
5297
5310
|
// single space the code could be an empty call to save bytes.
|
|
5298
|
-
if (child.type !== 2 /* TEXT */ || child.content !== ' ') {
|
|
5311
|
+
if (child.type !== 2 /* NodeTypes.TEXT */ || child.content !== ' ') {
|
|
5299
5312
|
callArgs.push(child);
|
|
5300
5313
|
}
|
|
5301
5314
|
// mark dynamic text with flag so it gets patched inside a block
|
|
5302
5315
|
if (!context.ssr &&
|
|
5303
|
-
getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
|
|
5304
|
-
callArgs.push(1 /* TEXT */ +
|
|
5305
|
-
(` /* ${shared.PatchFlagNames[1 /* TEXT */]} */` ));
|
|
5316
|
+
getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
5317
|
+
callArgs.push(1 /* PatchFlags.TEXT */ +
|
|
5318
|
+
(` /* ${shared.PatchFlagNames[1 /* PatchFlags.TEXT */]} */` ));
|
|
5306
5319
|
}
|
|
5307
5320
|
children[i] = {
|
|
5308
|
-
type: 12 /* TEXT_CALL */,
|
|
5321
|
+
type: 12 /* NodeTypes.TEXT_CALL */,
|
|
5309
5322
|
content: child,
|
|
5310
5323
|
loc: child.loc,
|
|
5311
5324
|
codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
|
|
@@ -5318,7 +5331,7 @@ const transformText = (node, context) => {
|
|
|
5318
5331
|
|
|
5319
5332
|
const seen = new WeakSet();
|
|
5320
5333
|
const transformOnce = (node, context) => {
|
|
5321
|
-
if (node.type === 1 /* ELEMENT */ && findDir(node, 'once', true)) {
|
|
5334
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
|
|
5322
5335
|
if (seen.has(node) || context.inVOnce) {
|
|
5323
5336
|
return;
|
|
5324
5337
|
}
|
|
@@ -5338,26 +5351,26 @@ const transformOnce = (node, context) => {
|
|
|
5338
5351
|
const transformModel = (dir, node, context) => {
|
|
5339
5352
|
const { exp, arg } = dir;
|
|
5340
5353
|
if (!exp) {
|
|
5341
|
-
context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
|
|
5354
|
+
context.onError(createCompilerError(41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */, dir.loc));
|
|
5342
5355
|
return createTransformProps();
|
|
5343
5356
|
}
|
|
5344
5357
|
const rawExp = exp.loc.source;
|
|
5345
|
-
const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
|
|
5358
|
+
const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
|
|
5346
5359
|
// im SFC <script setup> inline mode, the exp may have been transformed into
|
|
5347
5360
|
// _unref(exp)
|
|
5348
5361
|
const bindingType = context.bindingMetadata[rawExp];
|
|
5349
5362
|
const maybeRef = context.inline &&
|
|
5350
5363
|
bindingType &&
|
|
5351
|
-
bindingType !== "setup-const" /* SETUP_CONST */;
|
|
5364
|
+
bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
|
|
5352
5365
|
if (!expString.trim() ||
|
|
5353
5366
|
(!isMemberExpression(expString, context) && !maybeRef)) {
|
|
5354
|
-
context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
|
5367
|
+
context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
|
5355
5368
|
return createTransformProps();
|
|
5356
5369
|
}
|
|
5357
5370
|
if (context.prefixIdentifiers &&
|
|
5358
5371
|
isSimpleIdentifier(expString) &&
|
|
5359
5372
|
context.identifiers[expString]) {
|
|
5360
|
-
context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
|
|
5373
|
+
context.onError(createCompilerError(43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
|
|
5361
5374
|
return createTransformProps();
|
|
5362
5375
|
}
|
|
5363
5376
|
const propName = arg ? arg : createSimpleExpression('modelValue', true);
|
|
@@ -5369,7 +5382,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5369
5382
|
let assignmentExp;
|
|
5370
5383
|
const eventArg = context.isTS ? `($event: any)` : `$event`;
|
|
5371
5384
|
if (maybeRef) {
|
|
5372
|
-
if (bindingType === "setup-ref" /* SETUP_REF */) {
|
|
5385
|
+
if (bindingType === "setup-ref" /* BindingTypes.SETUP_REF */) {
|
|
5373
5386
|
// v-model used on known ref.
|
|
5374
5387
|
assignmentExp = createCompoundExpression([
|
|
5375
5388
|
`${eventArg} => ((`,
|
|
@@ -5380,7 +5393,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5380
5393
|
else {
|
|
5381
5394
|
// v-model used on a potentially ref binding in <script setup> inline mode.
|
|
5382
5395
|
// the assignment needs to check whether the binding is actually a ref.
|
|
5383
|
-
const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
|
|
5396
|
+
const altAssignment = bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ? `${rawExp} = $event` : `null`;
|
|
5384
5397
|
assignmentExp = createCompoundExpression([
|
|
5385
5398
|
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
|
|
5386
5399
|
createSimpleExpression(rawExp, false, exp.loc),
|
|
@@ -5409,7 +5422,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5409
5422
|
props[1].value = context.cache(props[1].value);
|
|
5410
5423
|
}
|
|
5411
5424
|
// modelModifiers: { foo: true, "bar-baz": true }
|
|
5412
|
-
if (dir.modifiers.length && node.tagType === 1 /* COMPONENT */) {
|
|
5425
|
+
if (dir.modifiers.length && node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
5413
5426
|
const modifiers = dir.modifiers
|
|
5414
5427
|
.map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
|
|
5415
5428
|
.join(`, `);
|
|
@@ -5418,7 +5431,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5418
5431
|
? `${arg.content}Modifiers`
|
|
5419
5432
|
: createCompoundExpression([arg, ' + "Modifiers"'])
|
|
5420
5433
|
: `modelModifiers`;
|
|
5421
|
-
props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* CAN_HOIST */)));
|
|
5434
|
+
props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* ConstantTypes.CAN_HOIST */)));
|
|
5422
5435
|
}
|
|
5423
5436
|
return createTransformProps(props);
|
|
5424
5437
|
};
|
|
@@ -5428,17 +5441,17 @@ function createTransformProps(props = []) {
|
|
|
5428
5441
|
|
|
5429
5442
|
const validDivisionCharRE = /[\w).+\-_$\]]/;
|
|
5430
5443
|
const transformFilter = (node, context) => {
|
|
5431
|
-
if (!isCompatEnabled("COMPILER_FILTER" /* COMPILER_FILTERS */, context)) {
|
|
5444
|
+
if (!isCompatEnabled("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context)) {
|
|
5432
5445
|
return;
|
|
5433
5446
|
}
|
|
5434
|
-
if (node.type === 5 /* INTERPOLATION */) {
|
|
5447
|
+
if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
5435
5448
|
// filter rewrite is applied before expression transform so only
|
|
5436
5449
|
// simple expressions are possible at this stage
|
|
5437
5450
|
rewriteFilter(node.content, context);
|
|
5438
5451
|
}
|
|
5439
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
5452
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
5440
5453
|
node.props.forEach((prop) => {
|
|
5441
|
-
if (prop.type === 7 /* DIRECTIVE */ &&
|
|
5454
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
5442
5455
|
prop.name !== 'for' &&
|
|
5443
5456
|
prop.exp) {
|
|
5444
5457
|
rewriteFilter(prop.exp, context);
|
|
@@ -5447,7 +5460,7 @@ const transformFilter = (node, context) => {
|
|
|
5447
5460
|
}
|
|
5448
5461
|
};
|
|
5449
5462
|
function rewriteFilter(node, context) {
|
|
5450
|
-
if (node.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5463
|
+
if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5451
5464
|
parseFilter(node, context);
|
|
5452
5465
|
}
|
|
5453
5466
|
else {
|
|
@@ -5455,13 +5468,13 @@ function rewriteFilter(node, context) {
|
|
|
5455
5468
|
const child = node.children[i];
|
|
5456
5469
|
if (typeof child !== 'object')
|
|
5457
5470
|
continue;
|
|
5458
|
-
if (child.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
5471
|
+
if (child.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
5459
5472
|
parseFilter(child, context);
|
|
5460
5473
|
}
|
|
5461
|
-
else if (child.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
5474
|
+
else if (child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
5462
5475
|
rewriteFilter(node, context);
|
|
5463
5476
|
}
|
|
5464
|
-
else if (child.type === 5 /* INTERPOLATION */) {
|
|
5477
|
+
else if (child.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
5465
5478
|
rewriteFilter(child.content, context);
|
|
5466
5479
|
}
|
|
5467
5480
|
}
|
|
@@ -5569,7 +5582,7 @@ function parseFilter(node, context) {
|
|
|
5569
5582
|
lastFilterIndex = i + 1;
|
|
5570
5583
|
}
|
|
5571
5584
|
if (filters.length) {
|
|
5572
|
-
warnDeprecation("COMPILER_FILTER" /* COMPILER_FILTERS */, context, node.loc);
|
|
5585
|
+
warnDeprecation("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context, node.loc);
|
|
5573
5586
|
for (i = 0; i < filters.length; i++) {
|
|
5574
5587
|
expression = wrapFilter(expression, filters[i], context);
|
|
5575
5588
|
}
|
|
@@ -5593,7 +5606,7 @@ function wrapFilter(exp, filter, context) {
|
|
|
5593
5606
|
|
|
5594
5607
|
const seen$1 = new WeakSet();
|
|
5595
5608
|
const transformMemo = (node, context) => {
|
|
5596
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
5609
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
5597
5610
|
const dir = findDir(node, 'memo');
|
|
5598
5611
|
if (!dir || seen$1.has(node)) {
|
|
5599
5612
|
return;
|
|
@@ -5602,9 +5615,9 @@ const transformMemo = (node, context) => {
|
|
|
5602
5615
|
return () => {
|
|
5603
5616
|
const codegenNode = node.codegenNode ||
|
|
5604
5617
|
context.currentNode.codegenNode;
|
|
5605
|
-
if (codegenNode && codegenNode.type === 13 /* VNODE_CALL */) {
|
|
5618
|
+
if (codegenNode && codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
5606
5619
|
// non-component sub tree should be turned into a block
|
|
5607
|
-
if (node.tagType !== 1 /* COMPONENT */) {
|
|
5620
|
+
if (node.tagType !== 1 /* ElementTypes.COMPONENT */) {
|
|
5608
5621
|
makeBlock(codegenNode, context);
|
|
5609
5622
|
}
|
|
5610
5623
|
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
@@ -5652,10 +5665,10 @@ function baseCompile(template, options = {}) {
|
|
|
5652
5665
|
const isModuleMode = options.mode === 'module';
|
|
5653
5666
|
const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
|
|
5654
5667
|
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
5655
|
-
onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
|
|
5668
|
+
onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
|
|
5656
5669
|
}
|
|
5657
5670
|
if (options.scopeId && !isModuleMode) {
|
|
5658
|
-
onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
|
|
5671
|
+
onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
|
|
5659
5672
|
}
|
|
5660
5673
|
const ast = shared.isString(template) ? baseParse(template, options) : template;
|
|
5661
5674
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|