@vue/compiler-dom 3.2.36 → 3.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +83 -83
- package/dist/compiler-dom.cjs.prod.js +72 -72
- package/dist/compiler-dom.esm-browser.js +591 -578
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +57 -57
- package/dist/compiler-dom.global.js +591 -578
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
|
@@ -21,29 +21,29 @@ var VueCompilerDOM = (function (exports) {
|
|
|
21
21
|
* dev only flag -> name mapping
|
|
22
22
|
*/
|
|
23
23
|
const PatchFlagNames = {
|
|
24
|
-
[1 /* TEXT */]: `TEXT`,
|
|
25
|
-
[2 /* CLASS */]: `CLASS`,
|
|
26
|
-
[4 /* STYLE */]: `STYLE`,
|
|
27
|
-
[8 /* PROPS */]: `PROPS`,
|
|
28
|
-
[16 /* FULL_PROPS */]: `FULL_PROPS`,
|
|
29
|
-
[32 /* HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,
|
|
30
|
-
[64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
|
|
31
|
-
[128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
|
|
32
|
-
[256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
|
|
33
|
-
[512 /* NEED_PATCH */]: `NEED_PATCH`,
|
|
34
|
-
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
|
|
35
|
-
[2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
|
|
36
|
-
[-1 /* HOISTED */]: `HOISTED`,
|
|
37
|
-
[-2 /* BAIL */]: `BAIL`
|
|
24
|
+
[1 /* PatchFlags.TEXT */]: `TEXT`,
|
|
25
|
+
[2 /* PatchFlags.CLASS */]: `CLASS`,
|
|
26
|
+
[4 /* PatchFlags.STYLE */]: `STYLE`,
|
|
27
|
+
[8 /* PatchFlags.PROPS */]: `PROPS`,
|
|
28
|
+
[16 /* PatchFlags.FULL_PROPS */]: `FULL_PROPS`,
|
|
29
|
+
[32 /* PatchFlags.HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,
|
|
30
|
+
[64 /* PatchFlags.STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
|
|
31
|
+
[128 /* PatchFlags.KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
|
|
32
|
+
[256 /* PatchFlags.UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
|
|
33
|
+
[512 /* PatchFlags.NEED_PATCH */]: `NEED_PATCH`,
|
|
34
|
+
[1024 /* PatchFlags.DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
|
|
35
|
+
[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
|
|
36
|
+
[-1 /* PatchFlags.HOISTED */]: `HOISTED`,
|
|
37
|
+
[-2 /* PatchFlags.BAIL */]: `BAIL`
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Dev only
|
|
42
42
|
*/
|
|
43
43
|
const slotFlagsText = {
|
|
44
|
-
[1 /* STABLE */]: 'STABLE',
|
|
45
|
-
[2 /* DYNAMIC */]: 'DYNAMIC',
|
|
46
|
-
[3 /* FORWARDED */]: 'FORWARDED'
|
|
44
|
+
[1 /* SlotFlags.STABLE */]: 'STABLE',
|
|
45
|
+
[2 /* SlotFlags.DYNAMIC */]: 'DYNAMIC',
|
|
46
|
+
[3 /* SlotFlags.FORWARDED */]: 'FORWARDED'
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
const range = 2;
|
|
@@ -208,65 +208,65 @@ var VueCompilerDOM = (function (exports) {
|
|
|
208
208
|
}
|
|
209
209
|
const errorMessages = {
|
|
210
210
|
// parse errors
|
|
211
|
-
[0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
|
|
212
|
-
[1 /* CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
|
|
213
|
-
[2 /* DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
|
|
214
|
-
[3 /* END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
|
|
215
|
-
[4 /* END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
|
|
216
|
-
[5 /* EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
|
|
217
|
-
[6 /* EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
|
|
218
|
-
[7 /* EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
|
|
219
|
-
[8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
|
|
220
|
-
[9 /* EOF_IN_TAG */]: 'Unexpected EOF in tag.',
|
|
221
|
-
[10 /* INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
|
|
222
|
-
[11 /* INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
|
|
223
|
-
[12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '<' to print '<'.",
|
|
224
|
-
[13 /* MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
|
|
225
|
-
[14 /* MISSING_END_TAG_NAME */]: 'End tag name was expected.',
|
|
226
|
-
[15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
|
|
227
|
-
[16 /* NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
|
|
228
|
-
[17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
|
229
|
-
[18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
|
230
|
-
[19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
|
|
231
|
-
[21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
|
|
232
|
-
[20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
|
|
233
|
-
[22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
|
|
211
|
+
[0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */]: 'Illegal comment.',
|
|
212
|
+
[1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */]: 'CDATA section is allowed only in XML context.',
|
|
213
|
+
[2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */]: 'Duplicate attribute.',
|
|
214
|
+
[3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */]: 'End tag cannot have attributes.',
|
|
215
|
+
[4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */]: "Illegal '/' in tags.",
|
|
216
|
+
[5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */]: 'Unexpected EOF in tag.',
|
|
217
|
+
[6 /* ErrorCodes.EOF_IN_CDATA */]: 'Unexpected EOF in CDATA section.',
|
|
218
|
+
[7 /* ErrorCodes.EOF_IN_COMMENT */]: 'Unexpected EOF in comment.',
|
|
219
|
+
[8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */]: 'Unexpected EOF in script.',
|
|
220
|
+
[9 /* ErrorCodes.EOF_IN_TAG */]: 'Unexpected EOF in tag.',
|
|
221
|
+
[10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */]: 'Incorrectly closed comment.',
|
|
222
|
+
[11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */]: 'Incorrectly opened comment.',
|
|
223
|
+
[12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */]: "Illegal tag name. Use '<' to print '<'.",
|
|
224
|
+
[13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */]: 'Attribute value was expected.',
|
|
225
|
+
[14 /* ErrorCodes.MISSING_END_TAG_NAME */]: 'End tag name was expected.',
|
|
226
|
+
[15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */]: 'Whitespace was expected.',
|
|
227
|
+
[16 /* ErrorCodes.NESTED_COMMENT */]: "Unexpected '<!--' in comment.",
|
|
228
|
+
[17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */]: 'Attribute name cannot contain U+0022 ("), U+0027 (\'), and U+003C (<).',
|
|
229
|
+
[18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
|
|
230
|
+
[19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
|
|
231
|
+
[21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
|
|
232
|
+
[20 /* ErrorCodes.UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
|
|
233
|
+
[22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
|
|
234
234
|
// Vue-specific parse errors
|
|
235
|
-
[23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
|
|
236
|
-
[24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
|
|
237
|
-
[25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
|
|
238
|
-
[27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
|
|
235
|
+
[23 /* ErrorCodes.X_INVALID_END_TAG */]: 'Invalid end tag.',
|
|
236
|
+
[24 /* ErrorCodes.X_MISSING_END_TAG */]: 'Element is missing end tag.',
|
|
237
|
+
[25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
|
|
238
|
+
[27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
|
|
239
239
|
'Note that dynamic directive argument cannot contain spaces.',
|
|
240
|
-
[26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
|
|
240
|
+
[26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
|
|
241
241
|
// transform errors
|
|
242
|
-
[28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
|
|
243
|
-
[29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
|
|
244
|
-
[30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
245
|
-
[31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
|
|
246
|
-
[32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
|
|
247
|
-
[33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
|
|
248
|
-
[34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
|
|
249
|
-
[35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
|
|
250
|
-
[36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
|
|
251
|
-
[37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
|
|
242
|
+
[28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
|
|
243
|
+
[29 /* ErrorCodes.X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
|
|
244
|
+
[30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
245
|
+
[31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
|
|
246
|
+
[32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
|
|
247
|
+
[33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
|
|
248
|
+
[34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
|
|
249
|
+
[35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
|
|
250
|
+
[36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
|
|
251
|
+
[37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
|
|
252
252
|
`When there are multiple named slots, all slots should use <template> ` +
|
|
253
253
|
`syntax to avoid scope ambiguity.`,
|
|
254
|
-
[38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
|
|
255
|
-
[39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
|
|
254
|
+
[38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
|
|
255
|
+
[39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
|
|
256
256
|
`default slot. These children will be ignored.`,
|
|
257
|
-
[40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
|
|
258
|
-
[41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
|
|
259
|
-
[42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
|
|
260
|
-
[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.`,
|
|
261
|
-
[44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
|
|
262
|
-
[45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
|
|
257
|
+
[40 /* ErrorCodes.X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
|
|
258
|
+
[41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
|
|
259
|
+
[42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
|
|
260
|
+
[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.`,
|
|
261
|
+
[44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
|
|
262
|
+
[45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
|
|
263
263
|
// generic errors
|
|
264
|
-
[46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
265
|
-
[47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
|
|
266
|
-
[48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
267
|
-
[49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
|
|
264
|
+
[46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
265
|
+
[47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
|
|
266
|
+
[48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
267
|
+
[49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
|
|
268
268
|
// just to fulfill types
|
|
269
|
-
[50 /* __EXTEND_POINT__ */]: ``
|
|
269
|
+
[50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
|
|
270
270
|
};
|
|
271
271
|
|
|
272
272
|
const FRAGMENT = Symbol(`Fragment` );
|
|
@@ -369,7 +369,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
369
369
|
};
|
|
370
370
|
function createRoot(children, loc = locStub) {
|
|
371
371
|
return {
|
|
372
|
-
type: 0 /* ROOT */,
|
|
372
|
+
type: 0 /* NodeTypes.ROOT */,
|
|
373
373
|
children,
|
|
374
374
|
helpers: [],
|
|
375
375
|
components: [],
|
|
@@ -396,7 +396,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
return {
|
|
399
|
-
type: 13 /* VNODE_CALL */,
|
|
399
|
+
type: 13 /* NodeTypes.VNODE_CALL */,
|
|
400
400
|
tag,
|
|
401
401
|
props,
|
|
402
402
|
children,
|
|
@@ -411,38 +411,38 @@ var VueCompilerDOM = (function (exports) {
|
|
|
411
411
|
}
|
|
412
412
|
function createArrayExpression(elements, loc = locStub) {
|
|
413
413
|
return {
|
|
414
|
-
type: 17 /* JS_ARRAY_EXPRESSION */,
|
|
414
|
+
type: 17 /* NodeTypes.JS_ARRAY_EXPRESSION */,
|
|
415
415
|
loc,
|
|
416
416
|
elements
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
function createObjectExpression(properties, loc = locStub) {
|
|
420
420
|
return {
|
|
421
|
-
type: 15 /* JS_OBJECT_EXPRESSION */,
|
|
421
|
+
type: 15 /* NodeTypes.JS_OBJECT_EXPRESSION */,
|
|
422
422
|
loc,
|
|
423
423
|
properties
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
function createObjectProperty(key, value) {
|
|
427
427
|
return {
|
|
428
|
-
type: 16 /* JS_PROPERTY */,
|
|
428
|
+
type: 16 /* NodeTypes.JS_PROPERTY */,
|
|
429
429
|
loc: locStub,
|
|
430
430
|
key: isString(key) ? createSimpleExpression(key, true) : key,
|
|
431
431
|
value
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
|
-
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* NOT_CONSTANT */) {
|
|
434
|
+
function createSimpleExpression(content, isStatic = false, loc = locStub, constType = 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
435
435
|
return {
|
|
436
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
436
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
437
437
|
loc,
|
|
438
438
|
content,
|
|
439
439
|
isStatic,
|
|
440
|
-
constType: isStatic ? 3 /* CAN_STRINGIFY */ : constType
|
|
440
|
+
constType: isStatic ? 3 /* ConstantTypes.CAN_STRINGIFY */ : constType
|
|
441
441
|
};
|
|
442
442
|
}
|
|
443
443
|
function createInterpolation(content, loc) {
|
|
444
444
|
return {
|
|
445
|
-
type: 5 /* INTERPOLATION */,
|
|
445
|
+
type: 5 /* NodeTypes.INTERPOLATION */,
|
|
446
446
|
loc,
|
|
447
447
|
content: isString(content)
|
|
448
448
|
? createSimpleExpression(content, false, loc)
|
|
@@ -451,14 +451,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
451
451
|
}
|
|
452
452
|
function createCompoundExpression(children, loc = locStub) {
|
|
453
453
|
return {
|
|
454
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
454
|
+
type: 8 /* NodeTypes.COMPOUND_EXPRESSION */,
|
|
455
455
|
loc,
|
|
456
456
|
children
|
|
457
457
|
};
|
|
458
458
|
}
|
|
459
459
|
function createCallExpression(callee, args = [], loc = locStub) {
|
|
460
460
|
return {
|
|
461
|
-
type: 14 /* JS_CALL_EXPRESSION */,
|
|
461
|
+
type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
|
|
462
462
|
loc,
|
|
463
463
|
callee,
|
|
464
464
|
arguments: args
|
|
@@ -466,7 +466,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
466
466
|
}
|
|
467
467
|
function createFunctionExpression(params, returns = undefined, newline = false, isSlot = false, loc = locStub) {
|
|
468
468
|
return {
|
|
469
|
-
type: 18 /* JS_FUNCTION_EXPRESSION */,
|
|
469
|
+
type: 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */,
|
|
470
470
|
params,
|
|
471
471
|
returns,
|
|
472
472
|
newline,
|
|
@@ -476,7 +476,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
476
476
|
}
|
|
477
477
|
function createConditionalExpression(test, consequent, alternate, newline = true) {
|
|
478
478
|
return {
|
|
479
|
-
type: 19 /* JS_CONDITIONAL_EXPRESSION */,
|
|
479
|
+
type: 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */,
|
|
480
480
|
test,
|
|
481
481
|
consequent,
|
|
482
482
|
alternate,
|
|
@@ -486,7 +486,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
486
486
|
}
|
|
487
487
|
function createCacheExpression(index, value, isVNode = false) {
|
|
488
488
|
return {
|
|
489
|
-
type: 20 /* JS_CACHE_EXPRESSION */,
|
|
489
|
+
type: 20 /* NodeTypes.JS_CACHE_EXPRESSION */,
|
|
490
490
|
index,
|
|
491
491
|
value,
|
|
492
492
|
isVNode,
|
|
@@ -495,21 +495,21 @@ var VueCompilerDOM = (function (exports) {
|
|
|
495
495
|
}
|
|
496
496
|
function createBlockStatement(body) {
|
|
497
497
|
return {
|
|
498
|
-
type: 21 /* JS_BLOCK_STATEMENT */,
|
|
498
|
+
type: 21 /* NodeTypes.JS_BLOCK_STATEMENT */,
|
|
499
499
|
body,
|
|
500
500
|
loc: locStub
|
|
501
501
|
};
|
|
502
502
|
}
|
|
503
503
|
function createTemplateLiteral(elements) {
|
|
504
504
|
return {
|
|
505
|
-
type: 22 /* JS_TEMPLATE_LITERAL */,
|
|
505
|
+
type: 22 /* NodeTypes.JS_TEMPLATE_LITERAL */,
|
|
506
506
|
elements,
|
|
507
507
|
loc: locStub
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
function createIfStatement(test, consequent, alternate) {
|
|
511
511
|
return {
|
|
512
|
-
type: 23 /* JS_IF_STATEMENT */,
|
|
512
|
+
type: 23 /* NodeTypes.JS_IF_STATEMENT */,
|
|
513
513
|
test,
|
|
514
514
|
consequent,
|
|
515
515
|
alternate,
|
|
@@ -518,7 +518,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
518
518
|
}
|
|
519
519
|
function createAssignmentExpression(left, right) {
|
|
520
520
|
return {
|
|
521
|
-
type: 24 /* JS_ASSIGNMENT_EXPRESSION */,
|
|
521
|
+
type: 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */,
|
|
522
522
|
left,
|
|
523
523
|
right,
|
|
524
524
|
loc: locStub
|
|
@@ -526,20 +526,20 @@ var VueCompilerDOM = (function (exports) {
|
|
|
526
526
|
}
|
|
527
527
|
function createSequenceExpression(expressions) {
|
|
528
528
|
return {
|
|
529
|
-
type: 25 /* JS_SEQUENCE_EXPRESSION */,
|
|
529
|
+
type: 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */,
|
|
530
530
|
expressions,
|
|
531
531
|
loc: locStub
|
|
532
532
|
};
|
|
533
533
|
}
|
|
534
534
|
function createReturnStatement(returns) {
|
|
535
535
|
return {
|
|
536
|
-
type: 26 /* JS_RETURN_STATEMENT */,
|
|
536
|
+
type: 26 /* NodeTypes.JS_RETURN_STATEMENT */,
|
|
537
537
|
returns,
|
|
538
538
|
loc: locStub
|
|
539
539
|
};
|
|
540
540
|
}
|
|
541
541
|
|
|
542
|
-
const isStaticExp = (p) => p.type === 4 /* SIMPLE_EXPRESSION */ && p.isStatic;
|
|
542
|
+
const isStaticExp = (p) => p.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && p.isStatic;
|
|
543
543
|
const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
|
|
544
544
|
function isCoreComponent(tag) {
|
|
545
545
|
if (isBuiltInType(tag, 'Teleport')) {
|
|
@@ -569,7 +569,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
569
569
|
const isMemberExpressionBrowser = (path) => {
|
|
570
570
|
// remove whitespaces around . or [ first
|
|
571
571
|
path = path.trim().replace(whitespaceRE, s => s.trim());
|
|
572
|
-
let state = 0 /* inMemberExp */;
|
|
572
|
+
let state = 0 /* MemberExpLexState.inMemberExp */;
|
|
573
573
|
let stateStack = [];
|
|
574
574
|
let currentOpenBracketCount = 0;
|
|
575
575
|
let currentOpenParensCount = 0;
|
|
@@ -577,25 +577,25 @@ var VueCompilerDOM = (function (exports) {
|
|
|
577
577
|
for (let i = 0; i < path.length; i++) {
|
|
578
578
|
const char = path.charAt(i);
|
|
579
579
|
switch (state) {
|
|
580
|
-
case 0 /* inMemberExp */:
|
|
580
|
+
case 0 /* MemberExpLexState.inMemberExp */:
|
|
581
581
|
if (char === '[') {
|
|
582
582
|
stateStack.push(state);
|
|
583
|
-
state = 1 /* inBrackets */;
|
|
583
|
+
state = 1 /* MemberExpLexState.inBrackets */;
|
|
584
584
|
currentOpenBracketCount++;
|
|
585
585
|
}
|
|
586
586
|
else if (char === '(') {
|
|
587
587
|
stateStack.push(state);
|
|
588
|
-
state = 2 /* inParens */;
|
|
588
|
+
state = 2 /* MemberExpLexState.inParens */;
|
|
589
589
|
currentOpenParensCount++;
|
|
590
590
|
}
|
|
591
591
|
else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
|
592
592
|
return false;
|
|
593
593
|
}
|
|
594
594
|
break;
|
|
595
|
-
case 1 /* inBrackets */:
|
|
595
|
+
case 1 /* MemberExpLexState.inBrackets */:
|
|
596
596
|
if (char === `'` || char === `"` || char === '`') {
|
|
597
597
|
stateStack.push(state);
|
|
598
|
-
state = 3 /* inString */;
|
|
598
|
+
state = 3 /* MemberExpLexState.inString */;
|
|
599
599
|
currentStringType = char;
|
|
600
600
|
}
|
|
601
601
|
else if (char === `[`) {
|
|
@@ -607,10 +607,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
break;
|
|
610
|
-
case 2 /* inParens */:
|
|
610
|
+
case 2 /* MemberExpLexState.inParens */:
|
|
611
611
|
if (char === `'` || char === `"` || char === '`') {
|
|
612
612
|
stateStack.push(state);
|
|
613
|
-
state = 3 /* inString */;
|
|
613
|
+
state = 3 /* MemberExpLexState.inString */;
|
|
614
614
|
currentStringType = char;
|
|
615
615
|
}
|
|
616
616
|
else if (char === `(`) {
|
|
@@ -626,7 +626,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
break;
|
|
629
|
-
case 3 /* inString */:
|
|
629
|
+
case 3 /* MemberExpLexState.inString */:
|
|
630
630
|
if (char === currentStringType) {
|
|
631
631
|
state = stateStack.pop();
|
|
632
632
|
currentStringType = null;
|
|
@@ -683,7 +683,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
683
683
|
function findDir(node, name, allowEmpty = false) {
|
|
684
684
|
for (let i = 0; i < node.props.length; i++) {
|
|
685
685
|
const p = node.props[i];
|
|
686
|
-
if (p.type === 7 /* DIRECTIVE */ &&
|
|
686
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
687
687
|
(allowEmpty || p.exp) &&
|
|
688
688
|
(isString(name) ? p.name === name : name.test(p.name))) {
|
|
689
689
|
return p;
|
|
@@ -693,7 +693,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
693
693
|
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
694
694
|
for (let i = 0; i < node.props.length; i++) {
|
|
695
695
|
const p = node.props[i];
|
|
696
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
696
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
697
697
|
if (dynamicOnly)
|
|
698
698
|
continue;
|
|
699
699
|
if (p.name === name && (p.value || allowEmpty)) {
|
|
@@ -711,24 +711,24 @@ var VueCompilerDOM = (function (exports) {
|
|
|
711
711
|
return !!(arg && isStaticExp(arg) && arg.content === name);
|
|
712
712
|
}
|
|
713
713
|
function hasDynamicKeyVBind(node) {
|
|
714
|
-
return node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
|
|
714
|
+
return node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
715
715
|
p.name === 'bind' &&
|
|
716
716
|
(!p.arg || // v-bind="obj"
|
|
717
|
-
p.arg.type !== 4 /* SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
|
|
717
|
+
p.arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ || // v-bind:[_ctx.foo]
|
|
718
718
|
!p.arg.isStatic) // v-bind:[foo]
|
|
719
719
|
);
|
|
720
720
|
}
|
|
721
721
|
function isText(node) {
|
|
722
|
-
return node.type === 5 /* INTERPOLATION */ || node.type === 2 /* TEXT */;
|
|
722
|
+
return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
|
|
723
723
|
}
|
|
724
724
|
function isVSlot(p) {
|
|
725
|
-
return p.type === 7 /* DIRECTIVE */ && p.name === 'slot';
|
|
725
|
+
return p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'slot';
|
|
726
726
|
}
|
|
727
727
|
function isTemplateNode(node) {
|
|
728
|
-
return (node.type === 1 /* ELEMENT */ && node.tagType === 3 /* TEMPLATE */);
|
|
728
|
+
return (node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 3 /* ElementTypes.TEMPLATE */);
|
|
729
729
|
}
|
|
730
730
|
function isSlotOutlet(node) {
|
|
731
|
-
return node.type === 1 /* ELEMENT */ && node.tagType === 2 /* SLOT */;
|
|
731
|
+
return node.type === 1 /* NodeTypes.ELEMENT */ && node.tagType === 2 /* ElementTypes.SLOT */;
|
|
732
732
|
}
|
|
733
733
|
function getVNodeHelper(ssr, isComponent) {
|
|
734
734
|
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
@@ -740,7 +740,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
740
740
|
function getUnnormalizedProps(props, callPath = []) {
|
|
741
741
|
if (props &&
|
|
742
742
|
!isString(props) &&
|
|
743
|
-
props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
743
|
+
props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
744
744
|
const callee = props.callee;
|
|
745
745
|
if (!isString(callee) && propsHelperSet.has(callee)) {
|
|
746
746
|
return getUnnormalizedProps(props.arguments[0], callPath.concat(props));
|
|
@@ -758,12 +758,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
758
758
|
*
|
|
759
759
|
* we need to get the real props before normalization
|
|
760
760
|
*/
|
|
761
|
-
let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
|
|
761
|
+
let props = node.type === 13 /* NodeTypes.VNODE_CALL */ ? node.props : node.arguments[2];
|
|
762
762
|
let callPath = [];
|
|
763
763
|
let parentCall;
|
|
764
764
|
if (props &&
|
|
765
765
|
!isString(props) &&
|
|
766
|
-
props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
766
|
+
props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
767
767
|
const ret = getUnnormalizedProps(props);
|
|
768
768
|
props = ret[0];
|
|
769
769
|
callPath = ret[1];
|
|
@@ -772,12 +772,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
772
772
|
if (props == null || isString(props)) {
|
|
773
773
|
propsWithInjection = createObjectExpression([prop]);
|
|
774
774
|
}
|
|
775
|
-
else if (props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
775
|
+
else if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
776
776
|
// merged props... add ours
|
|
777
777
|
// only inject key to object literal if it's the first argument so that
|
|
778
778
|
// if doesn't override user provided keys
|
|
779
779
|
const first = props.arguments[0];
|
|
780
|
-
if (!isString(first) && first.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
780
|
+
if (!isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
781
781
|
first.properties.unshift(prop);
|
|
782
782
|
}
|
|
783
783
|
else {
|
|
@@ -794,12 +794,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
794
794
|
}
|
|
795
795
|
!propsWithInjection && (propsWithInjection = props);
|
|
796
796
|
}
|
|
797
|
-
else if (props.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
797
|
+
else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
798
798
|
let alreadyExists = false;
|
|
799
799
|
// check existing key to avoid overriding user provided keys
|
|
800
|
-
if (prop.key.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
800
|
+
if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
801
801
|
const propKeyName = prop.key.content;
|
|
802
|
-
alreadyExists = props.properties.some(p => p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
802
|
+
alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
803
803
|
p.key.content === propKeyName);
|
|
804
804
|
}
|
|
805
805
|
if (!alreadyExists) {
|
|
@@ -820,7 +820,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
820
820
|
parentCall = callPath[callPath.length - 2];
|
|
821
821
|
}
|
|
822
822
|
}
|
|
823
|
-
if (node.type === 13 /* VNODE_CALL */) {
|
|
823
|
+
if (node.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
824
824
|
if (parentCall) {
|
|
825
825
|
parentCall.arguments[0] = propsWithInjection;
|
|
826
826
|
}
|
|
@@ -849,45 +849,45 @@ var VueCompilerDOM = (function (exports) {
|
|
|
849
849
|
return false;
|
|
850
850
|
}
|
|
851
851
|
switch (node.type) {
|
|
852
|
-
case 1 /* ELEMENT */:
|
|
852
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
853
853
|
for (let i = 0; i < node.props.length; i++) {
|
|
854
854
|
const p = node.props[i];
|
|
855
|
-
if (p.type === 7 /* DIRECTIVE */ &&
|
|
855
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
856
856
|
(hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
857
857
|
return true;
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
860
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
861
|
-
case 11 /* FOR */:
|
|
861
|
+
case 11 /* NodeTypes.FOR */:
|
|
862
862
|
if (hasScopeRef(node.source, ids)) {
|
|
863
863
|
return true;
|
|
864
864
|
}
|
|
865
865
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
866
|
-
case 9 /* IF */:
|
|
866
|
+
case 9 /* NodeTypes.IF */:
|
|
867
867
|
return node.branches.some(b => hasScopeRef(b, ids));
|
|
868
|
-
case 10 /* IF_BRANCH */:
|
|
868
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
869
869
|
if (hasScopeRef(node.condition, ids)) {
|
|
870
870
|
return true;
|
|
871
871
|
}
|
|
872
872
|
return node.children.some(c => hasScopeRef(c, ids));
|
|
873
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
873
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
874
874
|
return (!node.isStatic &&
|
|
875
875
|
isSimpleIdentifier(node.content) &&
|
|
876
876
|
!!ids[node.content]);
|
|
877
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
877
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
878
878
|
return node.children.some(c => isObject(c) && hasScopeRef(c, ids));
|
|
879
|
-
case 5 /* INTERPOLATION */:
|
|
880
|
-
case 12 /* TEXT_CALL */:
|
|
879
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
880
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
881
881
|
return hasScopeRef(node.content, ids);
|
|
882
|
-
case 2 /* TEXT */:
|
|
883
|
-
case 3 /* COMMENT */:
|
|
882
|
+
case 2 /* NodeTypes.TEXT */:
|
|
883
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
884
884
|
return false;
|
|
885
885
|
default:
|
|
886
886
|
return false;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
function getMemoedVNodeCall(node) {
|
|
890
|
-
if (node.type === 14 /* JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
|
|
890
|
+
if (node.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ && node.callee === WITH_MEMO) {
|
|
891
891
|
return node.arguments[1].returns;
|
|
892
892
|
}
|
|
893
893
|
else {
|
|
@@ -904,23 +904,23 @@ var VueCompilerDOM = (function (exports) {
|
|
|
904
904
|
}
|
|
905
905
|
|
|
906
906
|
const deprecationData = {
|
|
907
|
-
["COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */]: {
|
|
907
|
+
["COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */]: {
|
|
908
908
|
message: `Platform-native elements with "is" prop will no longer be ` +
|
|
909
909
|
`treated as components in Vue 3 unless the "is" value is explicitly ` +
|
|
910
910
|
`prefixed with "vue:".`,
|
|
911
911
|
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
912
912
|
},
|
|
913
|
-
["COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */]: {
|
|
913
|
+
["COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */]: {
|
|
914
914
|
message: key => `.sync modifier for v-bind has been removed. Use v-model with ` +
|
|
915
915
|
`argument instead. \`v-bind:${key}.sync\` should be changed to ` +
|
|
916
916
|
`\`v-model:${key}\`.`,
|
|
917
917
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
918
918
|
},
|
|
919
|
-
["COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */]: {
|
|
919
|
+
["COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */]: {
|
|
920
920
|
message: `.prop modifier for v-bind has been removed and no longer necessary. ` +
|
|
921
921
|
`Vue 3 will automatically set a binding as DOM property when appropriate.`
|
|
922
922
|
},
|
|
923
|
-
["COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */]: {
|
|
923
|
+
["COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */]: {
|
|
924
924
|
message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript ` +
|
|
925
925
|
`object spread: it will now overwrite an existing non-mergeable attribute ` +
|
|
926
926
|
`that appears before v-bind in the case of conflict. ` +
|
|
@@ -928,11 +928,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
928
928
|
`You can also suppress this warning if the usage is intended.`,
|
|
929
929
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
930
930
|
},
|
|
931
|
-
["COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */]: {
|
|
931
|
+
["COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */]: {
|
|
932
932
|
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
933
933
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
934
934
|
},
|
|
935
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
|
|
935
|
+
["COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */]: {
|
|
936
936
|
message: `v-if / v-for precedence when used on the same element has changed ` +
|
|
937
937
|
`in Vue 3: v-if now takes higher precedence and will no longer have ` +
|
|
938
938
|
`access to v-for scope variables. It is best to avoid the ambiguity ` +
|
|
@@ -940,15 +940,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
940
940
|
`data source.`,
|
|
941
941
|
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
942
942
|
},
|
|
943
|
-
["COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */]: {
|
|
943
|
+
["COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */]: {
|
|
944
944
|
message: `<template> with no special directives will render as a native template ` +
|
|
945
945
|
`element instead of its inner content in Vue 3.`
|
|
946
946
|
},
|
|
947
|
-
["COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */]: {
|
|
947
|
+
["COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */]: {
|
|
948
948
|
message: `"inline-template" has been removed in Vue 3.`,
|
|
949
949
|
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
950
950
|
},
|
|
951
|
-
["COMPILER_FILTER" /* COMPILER_FILTERS */]: {
|
|
951
|
+
["COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */]: {
|
|
952
952
|
message: `filters have been removed in Vue 3. ` +
|
|
953
953
|
`The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
|
|
954
954
|
`Use method calls or computed properties instead.`,
|
|
@@ -1008,8 +1008,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1008
1008
|
};
|
|
1009
1009
|
const defaultParserOptions = {
|
|
1010
1010
|
delimiters: [`{{`, `}}`],
|
|
1011
|
-
getNamespace: () => 0 /* HTML */,
|
|
1012
|
-
getTextMode: () => 0 /* DATA */,
|
|
1011
|
+
getNamespace: () => 0 /* Namespaces.HTML */,
|
|
1012
|
+
getTextMode: () => 0 /* TextModes.DATA */,
|
|
1013
1013
|
isVoidTag: NO,
|
|
1014
1014
|
isPreTag: NO,
|
|
1015
1015
|
isCustomElement: NO,
|
|
@@ -1021,7 +1021,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1021
1021
|
function baseParse(content, options = {}) {
|
|
1022
1022
|
const context = createParserContext(content, options);
|
|
1023
1023
|
const start = getCursor(context);
|
|
1024
|
-
return createRoot(parseChildren(context, 0 /* DATA */, []), getSelection(context, start));
|
|
1024
|
+
return createRoot(parseChildren(context, 0 /* TextModes.DATA */, []), getSelection(context, start));
|
|
1025
1025
|
}
|
|
1026
1026
|
function createParserContext(content, rawOptions) {
|
|
1027
1027
|
const options = extend({}, defaultParserOptions);
|
|
@@ -1047,20 +1047,20 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
function parseChildren(context, mode, ancestors) {
|
|
1049
1049
|
const parent = last(ancestors);
|
|
1050
|
-
const ns = parent ? parent.ns : 0 /* HTML */;
|
|
1050
|
+
const ns = parent ? parent.ns : 0 /* Namespaces.HTML */;
|
|
1051
1051
|
const nodes = [];
|
|
1052
1052
|
while (!isEnd(context, mode, ancestors)) {
|
|
1053
1053
|
const s = context.source;
|
|
1054
1054
|
let node = undefined;
|
|
1055
|
-
if (mode === 0 /* DATA */ || mode === 1 /* RCDATA */) {
|
|
1055
|
+
if (mode === 0 /* TextModes.DATA */ || mode === 1 /* TextModes.RCDATA */) {
|
|
1056
1056
|
if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
|
|
1057
1057
|
// '{{'
|
|
1058
1058
|
node = parseInterpolation(context, mode);
|
|
1059
1059
|
}
|
|
1060
|
-
else if (mode === 0 /* DATA */ && s[0] === '<') {
|
|
1060
|
+
else if (mode === 0 /* TextModes.DATA */ && s[0] === '<') {
|
|
1061
1061
|
// https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
|
|
1062
1062
|
if (s.length === 1) {
|
|
1063
|
-
emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 1);
|
|
1063
|
+
emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 1);
|
|
1064
1064
|
}
|
|
1065
1065
|
else if (s[1] === '!') {
|
|
1066
1066
|
// https://html.spec.whatwg.org/multipage/parsing.html#markup-declaration-open-state
|
|
@@ -1072,57 +1072,57 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1072
1072
|
node = parseBogusComment(context);
|
|
1073
1073
|
}
|
|
1074
1074
|
else if (startsWith(s, '<![CDATA[')) {
|
|
1075
|
-
if (ns !== 0 /* HTML */) {
|
|
1075
|
+
if (ns !== 0 /* Namespaces.HTML */) {
|
|
1076
1076
|
node = parseCDATA(context, ancestors);
|
|
1077
1077
|
}
|
|
1078
1078
|
else {
|
|
1079
|
-
emitError(context, 1 /* CDATA_IN_HTML_CONTENT */);
|
|
1079
|
+
emitError(context, 1 /* ErrorCodes.CDATA_IN_HTML_CONTENT */);
|
|
1080
1080
|
node = parseBogusComment(context);
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
else {
|
|
1084
|
-
emitError(context, 11 /* INCORRECTLY_OPENED_COMMENT */);
|
|
1084
|
+
emitError(context, 11 /* ErrorCodes.INCORRECTLY_OPENED_COMMENT */);
|
|
1085
1085
|
node = parseBogusComment(context);
|
|
1086
1086
|
}
|
|
1087
1087
|
}
|
|
1088
1088
|
else if (s[1] === '/') {
|
|
1089
1089
|
// https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
|
|
1090
1090
|
if (s.length === 2) {
|
|
1091
|
-
emitError(context, 5 /* EOF_BEFORE_TAG_NAME */, 2);
|
|
1091
|
+
emitError(context, 5 /* ErrorCodes.EOF_BEFORE_TAG_NAME */, 2);
|
|
1092
1092
|
}
|
|
1093
1093
|
else if (s[2] === '>') {
|
|
1094
|
-
emitError(context, 14 /* MISSING_END_TAG_NAME */, 2);
|
|
1094
|
+
emitError(context, 14 /* ErrorCodes.MISSING_END_TAG_NAME */, 2);
|
|
1095
1095
|
advanceBy(context, 3);
|
|
1096
1096
|
continue;
|
|
1097
1097
|
}
|
|
1098
1098
|
else if (/[a-z]/i.test(s[2])) {
|
|
1099
|
-
emitError(context, 23 /* X_INVALID_END_TAG */);
|
|
1100
|
-
parseTag(context, 1 /* End */, parent);
|
|
1099
|
+
emitError(context, 23 /* ErrorCodes.X_INVALID_END_TAG */);
|
|
1100
|
+
parseTag(context, 1 /* TagType.End */, parent);
|
|
1101
1101
|
continue;
|
|
1102
1102
|
}
|
|
1103
1103
|
else {
|
|
1104
|
-
emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
|
|
1104
|
+
emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 2);
|
|
1105
1105
|
node = parseBogusComment(context);
|
|
1106
1106
|
}
|
|
1107
1107
|
}
|
|
1108
1108
|
else if (/[a-z]/i.test(s[1])) {
|
|
1109
1109
|
node = parseElement(context, ancestors);
|
|
1110
1110
|
// 2.x <template> with no directive compat
|
|
1111
|
-
if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context) &&
|
|
1111
|
+
if (isCompatEnabled("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context) &&
|
|
1112
1112
|
node &&
|
|
1113
1113
|
node.tag === 'template' &&
|
|
1114
|
-
!node.props.some(p => p.type === 7 /* DIRECTIVE */ &&
|
|
1114
|
+
!node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
1115
1115
|
isSpecialTemplateDirective(p.name))) {
|
|
1116
|
-
warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* COMPILER_NATIVE_TEMPLATE */, context, node.loc);
|
|
1116
|
+
warnDeprecation("COMPILER_NATIVE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE */, context, node.loc);
|
|
1117
1117
|
node = node.children;
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
1120
|
else if (s[1] === '?') {
|
|
1121
|
-
emitError(context, 21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
|
|
1121
|
+
emitError(context, 21 /* ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */, 1);
|
|
1122
1122
|
node = parseBogusComment(context);
|
|
1123
1123
|
}
|
|
1124
1124
|
else {
|
|
1125
|
-
emitError(context, 12 /* INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
|
|
1125
|
+
emitError(context, 12 /* ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME */, 1);
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
@@ -1140,11 +1140,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
// Whitespace handling strategy like v2
|
|
1142
1142
|
let removedWhitespace = false;
|
|
1143
|
-
if (mode !== 2 /* RAWTEXT */ && mode !== 1 /* RCDATA */) {
|
|
1143
|
+
if (mode !== 2 /* TextModes.RAWTEXT */ && mode !== 1 /* TextModes.RCDATA */) {
|
|
1144
1144
|
const shouldCondense = context.options.whitespace !== 'preserve';
|
|
1145
1145
|
for (let i = 0; i < nodes.length; i++) {
|
|
1146
1146
|
const node = nodes[i];
|
|
1147
|
-
if (!context.inPre && node.type === 2 /* TEXT */) {
|
|
1147
|
+
if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
|
|
1148
1148
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
1149
1149
|
const prev = nodes[i - 1];
|
|
1150
1150
|
const next = nodes[i + 1];
|
|
@@ -1155,10 +1155,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1155
1155
|
if (!prev ||
|
|
1156
1156
|
!next ||
|
|
1157
1157
|
(shouldCondense &&
|
|
1158
|
-
(prev.type === 3 /* COMMENT */ ||
|
|
1159
|
-
next.type === 3 /* COMMENT */ ||
|
|
1160
|
-
(prev.type === 1 /* ELEMENT */ &&
|
|
1161
|
-
next.type === 1 /* ELEMENT */ &&
|
|
1158
|
+
(prev.type === 3 /* NodeTypes.COMMENT */ ||
|
|
1159
|
+
next.type === 3 /* NodeTypes.COMMENT */ ||
|
|
1160
|
+
(prev.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1161
|
+
next.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1162
1162
|
/[\r\n]/.test(node.content))))) {
|
|
1163
1163
|
removedWhitespace = true;
|
|
1164
1164
|
nodes[i] = null;
|
|
@@ -1175,7 +1175,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
1177
1177
|
// Remove comment nodes if desired by configuration.
|
|
1178
|
-
else if (node.type === 3 /* COMMENT */ && !context.options.comments) {
|
|
1178
|
+
else if (node.type === 3 /* NodeTypes.COMMENT */ && !context.options.comments) {
|
|
1179
1179
|
removedWhitespace = true;
|
|
1180
1180
|
nodes[i] = null;
|
|
1181
1181
|
}
|
|
@@ -1184,7 +1184,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1184
1184
|
// remove leading newline per html spec
|
|
1185
1185
|
// https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element
|
|
1186
1186
|
const first = nodes[0];
|
|
1187
|
-
if (first && first.type === 2 /* TEXT */) {
|
|
1187
|
+
if (first && first.type === 2 /* NodeTypes.TEXT */) {
|
|
1188
1188
|
first.content = first.content.replace(/^\r?\n/, '');
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
@@ -1192,12 +1192,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1192
1192
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1193
1193
|
}
|
|
1194
1194
|
function pushNode(nodes, node) {
|
|
1195
|
-
if (node.type === 2 /* TEXT */) {
|
|
1195
|
+
if (node.type === 2 /* NodeTypes.TEXT */) {
|
|
1196
1196
|
const prev = last(nodes);
|
|
1197
1197
|
// Merge if both this and the previous node are text and those are
|
|
1198
1198
|
// consecutive. This happens for cases like "a < b".
|
|
1199
1199
|
if (prev &&
|
|
1200
|
-
prev.type === 2 /* TEXT */ &&
|
|
1200
|
+
prev.type === 2 /* NodeTypes.TEXT */ &&
|
|
1201
1201
|
prev.loc.end.offset === node.loc.start.offset) {
|
|
1202
1202
|
prev.content += node.content;
|
|
1203
1203
|
prev.loc.end = node.loc.end;
|
|
@@ -1209,9 +1209,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1209
1209
|
}
|
|
1210
1210
|
function parseCDATA(context, ancestors) {
|
|
1211
1211
|
advanceBy(context, 9);
|
|
1212
|
-
const nodes = parseChildren(context, 3 /* CDATA */, ancestors);
|
|
1212
|
+
const nodes = parseChildren(context, 3 /* TextModes.CDATA */, ancestors);
|
|
1213
1213
|
if (context.source.length === 0) {
|
|
1214
|
-
emitError(context, 6 /* EOF_IN_CDATA */);
|
|
1214
|
+
emitError(context, 6 /* ErrorCodes.EOF_IN_CDATA */);
|
|
1215
1215
|
}
|
|
1216
1216
|
else {
|
|
1217
1217
|
advanceBy(context, 3);
|
|
@@ -1226,14 +1226,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1226
1226
|
if (!match) {
|
|
1227
1227
|
content = context.source.slice(4);
|
|
1228
1228
|
advanceBy(context, context.source.length);
|
|
1229
|
-
emitError(context, 7 /* EOF_IN_COMMENT */);
|
|
1229
|
+
emitError(context, 7 /* ErrorCodes.EOF_IN_COMMENT */);
|
|
1230
1230
|
}
|
|
1231
1231
|
else {
|
|
1232
1232
|
if (match.index <= 3) {
|
|
1233
|
-
emitError(context, 0 /* ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
|
|
1233
|
+
emitError(context, 0 /* ErrorCodes.ABRUPT_CLOSING_OF_EMPTY_COMMENT */);
|
|
1234
1234
|
}
|
|
1235
1235
|
if (match[1]) {
|
|
1236
|
-
emitError(context, 10 /* INCORRECTLY_CLOSED_COMMENT */);
|
|
1236
|
+
emitError(context, 10 /* ErrorCodes.INCORRECTLY_CLOSED_COMMENT */);
|
|
1237
1237
|
}
|
|
1238
1238
|
content = context.source.slice(4, match.index);
|
|
1239
1239
|
// Advancing with reporting nested comments.
|
|
@@ -1242,14 +1242,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1242
1242
|
while ((nestedIndex = s.indexOf('<!--', prevIndex)) !== -1) {
|
|
1243
1243
|
advanceBy(context, nestedIndex - prevIndex + 1);
|
|
1244
1244
|
if (nestedIndex + 4 < s.length) {
|
|
1245
|
-
emitError(context, 16 /* NESTED_COMMENT */);
|
|
1245
|
+
emitError(context, 16 /* ErrorCodes.NESTED_COMMENT */);
|
|
1246
1246
|
}
|
|
1247
1247
|
prevIndex = nestedIndex + 1;
|
|
1248
1248
|
}
|
|
1249
1249
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1250
1250
|
}
|
|
1251
1251
|
return {
|
|
1252
|
-
type: 3 /* COMMENT */,
|
|
1252
|
+
type: 3 /* NodeTypes.COMMENT */,
|
|
1253
1253
|
content,
|
|
1254
1254
|
loc: getSelection(context, start)
|
|
1255
1255
|
};
|
|
@@ -1268,7 +1268,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1268
1268
|
advanceBy(context, closeIndex + 1);
|
|
1269
1269
|
}
|
|
1270
1270
|
return {
|
|
1271
|
-
type: 3 /* COMMENT */,
|
|
1271
|
+
type: 3 /* NodeTypes.COMMENT */,
|
|
1272
1272
|
content,
|
|
1273
1273
|
loc: getSelection(context, start)
|
|
1274
1274
|
};
|
|
@@ -1278,7 +1278,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1278
1278
|
const wasInPre = context.inPre;
|
|
1279
1279
|
const wasInVPre = context.inVPre;
|
|
1280
1280
|
const parent = last(ancestors);
|
|
1281
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
1281
|
+
const element = parseTag(context, 0 /* TagType.Start */, parent);
|
|
1282
1282
|
const isPreBoundary = context.inPre && !wasInPre;
|
|
1283
1283
|
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
1284
1284
|
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
@@ -1298,12 +1298,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1298
1298
|
ancestors.pop();
|
|
1299
1299
|
// 2.x inline-template compat
|
|
1300
1300
|
{
|
|
1301
|
-
const inlineTemplateProp = element.props.find(p => p.type === 6 /* ATTRIBUTE */ && p.name === 'inline-template');
|
|
1301
|
+
const inlineTemplateProp = element.props.find(p => p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'inline-template');
|
|
1302
1302
|
if (inlineTemplateProp &&
|
|
1303
|
-
checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
|
|
1303
|
+
checkCompatEnabled("COMPILER_INLINE_TEMPLATE" /* CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE */, context, inlineTemplateProp.loc)) {
|
|
1304
1304
|
const loc = getSelection(context, element.loc.end);
|
|
1305
1305
|
inlineTemplateProp.value = {
|
|
1306
|
-
type: 2 /* TEXT */,
|
|
1306
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1307
1307
|
content: loc.source,
|
|
1308
1308
|
loc
|
|
1309
1309
|
};
|
|
@@ -1312,14 +1312,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1312
1312
|
element.children = children;
|
|
1313
1313
|
// End tag.
|
|
1314
1314
|
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1315
|
-
parseTag(context, 1 /* End */, parent);
|
|
1315
|
+
parseTag(context, 1 /* TagType.End */, parent);
|
|
1316
1316
|
}
|
|
1317
1317
|
else {
|
|
1318
|
-
emitError(context, 24 /* X_MISSING_END_TAG */, 0, element.loc.start);
|
|
1318
|
+
emitError(context, 24 /* ErrorCodes.X_MISSING_END_TAG */, 0, element.loc.start);
|
|
1319
1319
|
if (context.source.length === 0 && element.tag.toLowerCase() === 'script') {
|
|
1320
1320
|
const first = children[0];
|
|
1321
1321
|
if (first && startsWith(first.loc.source, '<!--')) {
|
|
1322
|
-
emitError(context, 8 /* EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
|
|
1322
|
+
emitError(context, 8 /* ErrorCodes.EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT */);
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
@@ -1351,9 +1351,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1351
1351
|
// Attributes.
|
|
1352
1352
|
let props = parseAttributes(context, type);
|
|
1353
1353
|
// check v-pre
|
|
1354
|
-
if (type === 0 /* Start */ &&
|
|
1354
|
+
if (type === 0 /* TagType.Start */ &&
|
|
1355
1355
|
!context.inVPre &&
|
|
1356
|
-
props.some(p => p.type === 7 /* DIRECTIVE */ && p.name === 'pre')) {
|
|
1356
|
+
props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'pre')) {
|
|
1357
1357
|
context.inVPre = true;
|
|
1358
1358
|
// reset context
|
|
1359
1359
|
extend(context, cursor);
|
|
@@ -1364,25 +1364,25 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1364
1364
|
// Tag close.
|
|
1365
1365
|
let isSelfClosing = false;
|
|
1366
1366
|
if (context.source.length === 0) {
|
|
1367
|
-
emitError(context, 9 /* EOF_IN_TAG */);
|
|
1367
|
+
emitError(context, 9 /* ErrorCodes.EOF_IN_TAG */);
|
|
1368
1368
|
}
|
|
1369
1369
|
else {
|
|
1370
1370
|
isSelfClosing = startsWith(context.source, '/>');
|
|
1371
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1372
|
-
emitError(context, 4 /* END_TAG_WITH_TRAILING_SOLIDUS */);
|
|
1371
|
+
if (type === 1 /* TagType.End */ && isSelfClosing) {
|
|
1372
|
+
emitError(context, 4 /* ErrorCodes.END_TAG_WITH_TRAILING_SOLIDUS */);
|
|
1373
1373
|
}
|
|
1374
1374
|
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1375
1375
|
}
|
|
1376
|
-
if (type === 1 /* End */) {
|
|
1376
|
+
if (type === 1 /* TagType.End */) {
|
|
1377
1377
|
return;
|
|
1378
1378
|
}
|
|
1379
1379
|
// 2.x deprecation checks
|
|
1380
|
-
if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
|
|
1380
|
+
if (isCompatEnabled("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context)) {
|
|
1381
1381
|
let hasIf = false;
|
|
1382
1382
|
let hasFor = false;
|
|
1383
1383
|
for (let i = 0; i < props.length; i++) {
|
|
1384
1384
|
const p = props[i];
|
|
1385
|
-
if (p.type === 7 /* DIRECTIVE */) {
|
|
1385
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
1386
1386
|
if (p.name === 'if') {
|
|
1387
1387
|
hasIf = true;
|
|
1388
1388
|
}
|
|
@@ -1391,27 +1391,27 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
1393
1393
|
if (hasIf && hasFor) {
|
|
1394
|
-
warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
|
|
1394
|
+
warnDeprecation("COMPILER_V_IF_V_FOR_PRECEDENCE" /* CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE */, context, getSelection(context, start));
|
|
1395
1395
|
break;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
let tagType = 0 /* ELEMENT */;
|
|
1399
|
+
let tagType = 0 /* ElementTypes.ELEMENT */;
|
|
1400
1400
|
if (!context.inVPre) {
|
|
1401
1401
|
if (tag === 'slot') {
|
|
1402
|
-
tagType = 2 /* SLOT */;
|
|
1402
|
+
tagType = 2 /* ElementTypes.SLOT */;
|
|
1403
1403
|
}
|
|
1404
1404
|
else if (tag === 'template') {
|
|
1405
|
-
if (props.some(p => p.type === 7 /* DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
|
1406
|
-
tagType = 3 /* TEMPLATE */;
|
|
1405
|
+
if (props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && isSpecialTemplateDirective(p.name))) {
|
|
1406
|
+
tagType = 3 /* ElementTypes.TEMPLATE */;
|
|
1407
1407
|
}
|
|
1408
1408
|
}
|
|
1409
1409
|
else if (isComponent(tag, props, context)) {
|
|
1410
|
-
tagType = 1 /* COMPONENT */;
|
|
1410
|
+
tagType = 1 /* ElementTypes.COMPONENT */;
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
1413
|
return {
|
|
1414
|
-
type: 1 /* ELEMENT */,
|
|
1414
|
+
type: 1 /* NodeTypes.ELEMENT */,
|
|
1415
1415
|
ns,
|
|
1416
1416
|
tag,
|
|
1417
1417
|
tagType,
|
|
@@ -1438,12 +1438,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1438
1438
|
// casting
|
|
1439
1439
|
for (let i = 0; i < props.length; i++) {
|
|
1440
1440
|
const p = props[i];
|
|
1441
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
1441
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
1442
1442
|
if (p.name === 'is' && p.value) {
|
|
1443
1443
|
if (p.value.content.startsWith('vue:')) {
|
|
1444
1444
|
return true;
|
|
1445
1445
|
}
|
|
1446
|
-
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1446
|
+
else if (checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1447
1447
|
return true;
|
|
1448
1448
|
}
|
|
1449
1449
|
}
|
|
@@ -1459,7 +1459,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1459
1459
|
p.name === 'bind' &&
|
|
1460
1460
|
isStaticArgOf(p.arg, 'is') &&
|
|
1461
1461
|
true &&
|
|
1462
|
-
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1462
|
+
checkCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context, p.loc)) {
|
|
1463
1463
|
return true;
|
|
1464
1464
|
}
|
|
1465
1465
|
}
|
|
@@ -1472,27 +1472,27 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1472
1472
|
!startsWith(context.source, '>') &&
|
|
1473
1473
|
!startsWith(context.source, '/>')) {
|
|
1474
1474
|
if (startsWith(context.source, '/')) {
|
|
1475
|
-
emitError(context, 22 /* UNEXPECTED_SOLIDUS_IN_TAG */);
|
|
1475
|
+
emitError(context, 22 /* ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG */);
|
|
1476
1476
|
advanceBy(context, 1);
|
|
1477
1477
|
advanceSpaces(context);
|
|
1478
1478
|
continue;
|
|
1479
1479
|
}
|
|
1480
|
-
if (type === 1 /* End */) {
|
|
1481
|
-
emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
|
|
1480
|
+
if (type === 1 /* TagType.End */) {
|
|
1481
|
+
emitError(context, 3 /* ErrorCodes.END_TAG_WITH_ATTRIBUTES */);
|
|
1482
1482
|
}
|
|
1483
1483
|
const attr = parseAttribute(context, attributeNames);
|
|
1484
1484
|
// Trim whitespace between class
|
|
1485
1485
|
// https://github.com/vuejs/core/issues/4251
|
|
1486
|
-
if (attr.type === 6 /* ATTRIBUTE */ &&
|
|
1486
|
+
if (attr.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
1487
1487
|
attr.value &&
|
|
1488
1488
|
attr.name === 'class') {
|
|
1489
1489
|
attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
|
|
1490
1490
|
}
|
|
1491
|
-
if (type === 0 /* Start */) {
|
|
1491
|
+
if (type === 0 /* TagType.Start */) {
|
|
1492
1492
|
props.push(attr);
|
|
1493
1493
|
}
|
|
1494
1494
|
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1495
|
-
emitError(context, 15 /* MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
|
|
1495
|
+
emitError(context, 15 /* ErrorCodes.MISSING_WHITESPACE_BETWEEN_ATTRIBUTES */);
|
|
1496
1496
|
}
|
|
1497
1497
|
advanceSpaces(context);
|
|
1498
1498
|
}
|
|
@@ -1504,17 +1504,17 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1504
1504
|
const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
|
|
1505
1505
|
const name = match[0];
|
|
1506
1506
|
if (nameSet.has(name)) {
|
|
1507
|
-
emitError(context, 2 /* DUPLICATE_ATTRIBUTE */);
|
|
1507
|
+
emitError(context, 2 /* ErrorCodes.DUPLICATE_ATTRIBUTE */);
|
|
1508
1508
|
}
|
|
1509
1509
|
nameSet.add(name);
|
|
1510
1510
|
if (name[0] === '=') {
|
|
1511
|
-
emitError(context, 19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
|
|
1511
|
+
emitError(context, 19 /* ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */);
|
|
1512
1512
|
}
|
|
1513
1513
|
{
|
|
1514
1514
|
const pattern = /["'<]/g;
|
|
1515
1515
|
let m;
|
|
1516
1516
|
while ((m = pattern.exec(name))) {
|
|
1517
|
-
emitError(context, 17 /* UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
|
|
1517
|
+
emitError(context, 17 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME */, m.index);
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
1520
|
advanceBy(context, name.length);
|
|
@@ -1526,7 +1526,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1526
1526
|
advanceSpaces(context);
|
|
1527
1527
|
value = parseAttributeValue(context);
|
|
1528
1528
|
if (!value) {
|
|
1529
|
-
emitError(context, 13 /* MISSING_ATTRIBUTE_VALUE */);
|
|
1529
|
+
emitError(context, 13 /* ErrorCodes.MISSING_ATTRIBUTE_VALUE */);
|
|
1530
1530
|
}
|
|
1531
1531
|
}
|
|
1532
1532
|
const loc = getSelection(context, start);
|
|
@@ -1549,7 +1549,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1549
1549
|
if (content.startsWith('[')) {
|
|
1550
1550
|
isStatic = false;
|
|
1551
1551
|
if (!content.endsWith(']')) {
|
|
1552
|
-
emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
|
|
1552
|
+
emitError(context, 27 /* ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
|
|
1553
1553
|
content = content.slice(1);
|
|
1554
1554
|
}
|
|
1555
1555
|
else {
|
|
@@ -1563,12 +1563,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1563
1563
|
content += match[3] || '';
|
|
1564
1564
|
}
|
|
1565
1565
|
arg = {
|
|
1566
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1566
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1567
1567
|
content,
|
|
1568
1568
|
isStatic,
|
|
1569
1569
|
constType: isStatic
|
|
1570
|
-
? 3 /* CAN_STRINGIFY */
|
|
1571
|
-
: 0 /* NOT_CONSTANT */,
|
|
1570
|
+
? 3 /* ConstantTypes.CAN_STRINGIFY */
|
|
1571
|
+
: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1572
1572
|
loc
|
|
1573
1573
|
};
|
|
1574
1574
|
}
|
|
@@ -1585,24 +1585,24 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1585
1585
|
// 2.x compat v-bind:foo.sync -> v-model:foo
|
|
1586
1586
|
if (dirName === 'bind' && arg) {
|
|
1587
1587
|
if (modifiers.includes('sync') &&
|
|
1588
|
-
checkCompatEnabled("COMPILER_V_BIND_SYNC" /* COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
|
|
1588
|
+
checkCompatEnabled("COMPILER_V_BIND_SYNC" /* CompilerDeprecationTypes.COMPILER_V_BIND_SYNC */, context, loc, arg.loc.source)) {
|
|
1589
1589
|
dirName = 'model';
|
|
1590
1590
|
modifiers.splice(modifiers.indexOf('sync'), 1);
|
|
1591
1591
|
}
|
|
1592
1592
|
if (modifiers.includes('prop')) {
|
|
1593
|
-
checkCompatEnabled("COMPILER_V_BIND_PROP" /* COMPILER_V_BIND_PROP */, context, loc);
|
|
1593
|
+
checkCompatEnabled("COMPILER_V_BIND_PROP" /* CompilerDeprecationTypes.COMPILER_V_BIND_PROP */, context, loc);
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
1596
|
return {
|
|
1597
|
-
type: 7 /* DIRECTIVE */,
|
|
1597
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
1598
1598
|
name: dirName,
|
|
1599
1599
|
exp: value && {
|
|
1600
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1600
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1601
1601
|
content: value.content,
|
|
1602
1602
|
isStatic: false,
|
|
1603
1603
|
// Treat as non-constant by default. This can be potentially set to
|
|
1604
1604
|
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1605
|
-
constType: 0 /* NOT_CONSTANT */,
|
|
1605
|
+
constType: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1606
1606
|
loc: value.loc
|
|
1607
1607
|
},
|
|
1608
1608
|
arg,
|
|
@@ -1612,13 +1612,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
// missing directive name or illegal directive name
|
|
1614
1614
|
if (!context.inVPre && startsWith(name, 'v-')) {
|
|
1615
|
-
emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
|
|
1615
|
+
emitError(context, 26 /* ErrorCodes.X_MISSING_DIRECTIVE_NAME */);
|
|
1616
1616
|
}
|
|
1617
1617
|
return {
|
|
1618
|
-
type: 6 /* ATTRIBUTE */,
|
|
1618
|
+
type: 6 /* NodeTypes.ATTRIBUTE */,
|
|
1619
1619
|
name,
|
|
1620
1620
|
value: value && {
|
|
1621
|
-
type: 2 /* TEXT */,
|
|
1621
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1622
1622
|
content: value.content,
|
|
1623
1623
|
loc: value.loc
|
|
1624
1624
|
},
|
|
@@ -1635,10 +1635,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1635
1635
|
advanceBy(context, 1);
|
|
1636
1636
|
const endIndex = context.source.indexOf(quote);
|
|
1637
1637
|
if (endIndex === -1) {
|
|
1638
|
-
content = parseTextData(context, context.source.length, 4 /* ATTRIBUTE_VALUE */);
|
|
1638
|
+
content = parseTextData(context, context.source.length, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1639
1639
|
}
|
|
1640
1640
|
else {
|
|
1641
|
-
content = parseTextData(context, endIndex, 4 /* ATTRIBUTE_VALUE */);
|
|
1641
|
+
content = parseTextData(context, endIndex, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1642
1642
|
advanceBy(context, 1);
|
|
1643
1643
|
}
|
|
1644
1644
|
}
|
|
@@ -1651,9 +1651,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1651
1651
|
const unexpectedChars = /["'<=`]/g;
|
|
1652
1652
|
let m;
|
|
1653
1653
|
while ((m = unexpectedChars.exec(match[0]))) {
|
|
1654
|
-
emitError(context, 18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
|
|
1654
|
+
emitError(context, 18 /* ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */, m.index);
|
|
1655
1655
|
}
|
|
1656
|
-
content = parseTextData(context, match[0].length, 4 /* ATTRIBUTE_VALUE */);
|
|
1656
|
+
content = parseTextData(context, match[0].length, 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1657
1657
|
}
|
|
1658
1658
|
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1659
1659
|
}
|
|
@@ -1661,7 +1661,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1661
1661
|
const [open, close] = context.options.delimiters;
|
|
1662
1662
|
const closeIndex = context.source.indexOf(close, open.length);
|
|
1663
1663
|
if (closeIndex === -1) {
|
|
1664
|
-
emitError(context, 25 /* X_MISSING_INTERPOLATION_END */);
|
|
1664
|
+
emitError(context, 25 /* ErrorCodes.X_MISSING_INTERPOLATION_END */);
|
|
1665
1665
|
return undefined;
|
|
1666
1666
|
}
|
|
1667
1667
|
const start = getCursor(context);
|
|
@@ -1680,12 +1680,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1680
1680
|
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1681
1681
|
advanceBy(context, close.length);
|
|
1682
1682
|
return {
|
|
1683
|
-
type: 5 /* INTERPOLATION */,
|
|
1683
|
+
type: 5 /* NodeTypes.INTERPOLATION */,
|
|
1684
1684
|
content: {
|
|
1685
|
-
type: 4 /* SIMPLE_EXPRESSION */,
|
|
1685
|
+
type: 4 /* NodeTypes.SIMPLE_EXPRESSION */,
|
|
1686
1686
|
isStatic: false,
|
|
1687
1687
|
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1688
|
-
constType: 0 /* NOT_CONSTANT */,
|
|
1688
|
+
constType: 0 /* ConstantTypes.NOT_CONSTANT */,
|
|
1689
1689
|
content,
|
|
1690
1690
|
loc: getSelection(context, innerStart, innerEnd)
|
|
1691
1691
|
},
|
|
@@ -1693,7 +1693,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1693
1693
|
};
|
|
1694
1694
|
}
|
|
1695
1695
|
function parseText(context, mode) {
|
|
1696
|
-
const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
|
|
1696
|
+
const endTokens = mode === 3 /* TextModes.CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
|
|
1697
1697
|
let endIndex = context.source.length;
|
|
1698
1698
|
for (let i = 0; i < endTokens.length; i++) {
|
|
1699
1699
|
const index = context.source.indexOf(endTokens[i], 1);
|
|
@@ -1704,7 +1704,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1704
1704
|
const start = getCursor(context);
|
|
1705
1705
|
const content = parseTextData(context, endIndex, mode);
|
|
1706
1706
|
return {
|
|
1707
|
-
type: 2 /* TEXT */,
|
|
1707
|
+
type: 2 /* NodeTypes.TEXT */,
|
|
1708
1708
|
content,
|
|
1709
1709
|
loc: getSelection(context, start)
|
|
1710
1710
|
};
|
|
@@ -1716,14 +1716,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1716
1716
|
function parseTextData(context, length, mode) {
|
|
1717
1717
|
const rawText = context.source.slice(0, length);
|
|
1718
1718
|
advanceBy(context, length);
|
|
1719
|
-
if (mode === 2 /* RAWTEXT */ ||
|
|
1720
|
-
mode === 3 /* CDATA */ ||
|
|
1719
|
+
if (mode === 2 /* TextModes.RAWTEXT */ ||
|
|
1720
|
+
mode === 3 /* TextModes.CDATA */ ||
|
|
1721
1721
|
!rawText.includes('&')) {
|
|
1722
1722
|
return rawText;
|
|
1723
1723
|
}
|
|
1724
1724
|
else {
|
|
1725
1725
|
// DATA or RCDATA containing "&"". Entity decoding required.
|
|
1726
|
-
return context.options.decodeEntities(rawText, mode === 4 /* ATTRIBUTE_VALUE */);
|
|
1726
|
+
return context.options.decodeEntities(rawText, mode === 4 /* TextModes.ATTRIBUTE_VALUE */);
|
|
1727
1727
|
}
|
|
1728
1728
|
}
|
|
1729
1729
|
function getCursor(context) {
|
|
@@ -1772,7 +1772,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1772
1772
|
function isEnd(context, mode, ancestors) {
|
|
1773
1773
|
const s = context.source;
|
|
1774
1774
|
switch (mode) {
|
|
1775
|
-
case 0 /* DATA */:
|
|
1775
|
+
case 0 /* TextModes.DATA */:
|
|
1776
1776
|
if (startsWith(s, '</')) {
|
|
1777
1777
|
// TODO: probably bad performance
|
|
1778
1778
|
for (let i = ancestors.length - 1; i >= 0; --i) {
|
|
@@ -1782,15 +1782,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1782
1782
|
}
|
|
1783
1783
|
}
|
|
1784
1784
|
break;
|
|
1785
|
-
case 1 /* RCDATA */:
|
|
1786
|
-
case 2 /* RAWTEXT */: {
|
|
1785
|
+
case 1 /* TextModes.RCDATA */:
|
|
1786
|
+
case 2 /* TextModes.RAWTEXT */: {
|
|
1787
1787
|
const parent = last(ancestors);
|
|
1788
1788
|
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1789
1789
|
return true;
|
|
1790
1790
|
}
|
|
1791
1791
|
break;
|
|
1792
1792
|
}
|
|
1793
|
-
case 3 /* CDATA */:
|
|
1793
|
+
case 3 /* TextModes.CDATA */:
|
|
1794
1794
|
if (startsWith(s, ']]>')) {
|
|
1795
1795
|
return true;
|
|
1796
1796
|
}
|
|
@@ -1813,7 +1813,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1813
1813
|
function isSingleElementRoot(root, child) {
|
|
1814
1814
|
const { children } = root;
|
|
1815
1815
|
return (children.length === 1 &&
|
|
1816
|
-
child.type === 1 /* ELEMENT */ &&
|
|
1816
|
+
child.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1817
1817
|
!isSlotOutlet(child));
|
|
1818
1818
|
}
|
|
1819
1819
|
function walk(node, context, doNotHoistNode = false) {
|
|
@@ -1823,15 +1823,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1823
1823
|
for (let i = 0; i < children.length; i++) {
|
|
1824
1824
|
const child = children[i];
|
|
1825
1825
|
// only plain elements & text calls are eligible for hoisting.
|
|
1826
|
-
if (child.type === 1 /* ELEMENT */ &&
|
|
1827
|
-
child.tagType === 0 /* ELEMENT */) {
|
|
1826
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1827
|
+
child.tagType === 0 /* ElementTypes.ELEMENT */) {
|
|
1828
1828
|
const constantType = doNotHoistNode
|
|
1829
|
-
? 0 /* NOT_CONSTANT */
|
|
1829
|
+
? 0 /* ConstantTypes.NOT_CONSTANT */
|
|
1830
1830
|
: getConstantType(child, context);
|
|
1831
|
-
if (constantType > 0 /* NOT_CONSTANT */) {
|
|
1832
|
-
if (constantType >= 2 /* CAN_HOIST */) {
|
|
1831
|
+
if (constantType > 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1832
|
+
if (constantType >= 2 /* ConstantTypes.CAN_HOIST */) {
|
|
1833
1833
|
child.codegenNode.patchFlag =
|
|
1834
|
-
-1 /* HOISTED */ + (` /* HOISTED */` );
|
|
1834
|
+
-1 /* PatchFlags.HOISTED */ + (` /* HOISTED */` );
|
|
1835
1835
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1836
1836
|
hoistedCount++;
|
|
1837
1837
|
continue;
|
|
@@ -1841,13 +1841,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1841
1841
|
// node may contain dynamic children, but its props may be eligible for
|
|
1842
1842
|
// hoisting.
|
|
1843
1843
|
const codegenNode = child.codegenNode;
|
|
1844
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
1844
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
1845
1845
|
const flag = getPatchFlag(codegenNode);
|
|
1846
1846
|
if ((!flag ||
|
|
1847
|
-
flag === 512 /* NEED_PATCH */ ||
|
|
1848
|
-
flag === 1 /* TEXT */) &&
|
|
1847
|
+
flag === 512 /* PatchFlags.NEED_PATCH */ ||
|
|
1848
|
+
flag === 1 /* PatchFlags.TEXT */) &&
|
|
1849
1849
|
getGeneratedPropsConstantType(child, context) >=
|
|
1850
|
-
2 /* CAN_HOIST */) {
|
|
1850
|
+
2 /* ConstantTypes.CAN_HOIST */) {
|
|
1851
1851
|
const props = getNodeProps(child);
|
|
1852
1852
|
if (props) {
|
|
1853
1853
|
codegenNode.props = context.hoist(props);
|
|
@@ -1859,14 +1859,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1859
1859
|
}
|
|
1860
1860
|
}
|
|
1861
1861
|
}
|
|
1862
|
-
else if (child.type === 12 /* TEXT_CALL */ &&
|
|
1863
|
-
getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
|
|
1862
|
+
else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
|
|
1863
|
+
getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
|
|
1864
1864
|
child.codegenNode = context.hoist(child.codegenNode);
|
|
1865
1865
|
hoistedCount++;
|
|
1866
1866
|
}
|
|
1867
1867
|
// walk further
|
|
1868
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
1869
|
-
const isComponent = child.tagType === 1 /* COMPONENT */;
|
|
1868
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
1869
|
+
const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
|
|
1870
1870
|
if (isComponent) {
|
|
1871
1871
|
context.scopes.vSlot++;
|
|
1872
1872
|
}
|
|
@@ -1875,11 +1875,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1875
1875
|
context.scopes.vSlot--;
|
|
1876
1876
|
}
|
|
1877
1877
|
}
|
|
1878
|
-
else if (child.type === 11 /* FOR */) {
|
|
1878
|
+
else if (child.type === 11 /* NodeTypes.FOR */) {
|
|
1879
1879
|
// Do not hoist v-for single child because it has to be a block
|
|
1880
1880
|
walk(child, context, child.children.length === 1);
|
|
1881
1881
|
}
|
|
1882
|
-
else if (child.type === 9 /* IF */) {
|
|
1882
|
+
else if (child.type === 9 /* NodeTypes.IF */) {
|
|
1883
1883
|
for (let i = 0; i < child.branches.length; i++) {
|
|
1884
1884
|
// Do not hoist v-if single child because it has to be a block
|
|
1885
1885
|
walk(child.branches[i], context, child.branches[i].children.length === 1);
|
|
@@ -1892,10 +1892,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1892
1892
|
// all children were hoisted - the entire children array is hoistable.
|
|
1893
1893
|
if (hoistedCount &&
|
|
1894
1894
|
hoistedCount === originalCount &&
|
|
1895
|
-
node.type === 1 /* ELEMENT */ &&
|
|
1896
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
1895
|
+
node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1896
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
1897
1897
|
node.codegenNode &&
|
|
1898
|
-
node.codegenNode.type === 13 /* VNODE_CALL */ &&
|
|
1898
|
+
node.codegenNode.type === 13 /* NodeTypes.VNODE_CALL */ &&
|
|
1899
1899
|
isArray(node.codegenNode.children)) {
|
|
1900
1900
|
node.codegenNode.children = context.hoist(createArrayExpression(node.codegenNode.children));
|
|
1901
1901
|
}
|
|
@@ -1903,35 +1903,35 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1903
1903
|
function getConstantType(node, context) {
|
|
1904
1904
|
const { constantCache } = context;
|
|
1905
1905
|
switch (node.type) {
|
|
1906
|
-
case 1 /* ELEMENT */:
|
|
1907
|
-
if (node.tagType !== 0 /* ELEMENT */) {
|
|
1908
|
-
return 0 /* NOT_CONSTANT */;
|
|
1906
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
1907
|
+
if (node.tagType !== 0 /* ElementTypes.ELEMENT */) {
|
|
1908
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1909
1909
|
}
|
|
1910
1910
|
const cached = constantCache.get(node);
|
|
1911
1911
|
if (cached !== undefined) {
|
|
1912
1912
|
return cached;
|
|
1913
1913
|
}
|
|
1914
1914
|
const codegenNode = node.codegenNode;
|
|
1915
|
-
if (codegenNode.type !== 13 /* VNODE_CALL */) {
|
|
1916
|
-
return 0 /* NOT_CONSTANT */;
|
|
1915
|
+
if (codegenNode.type !== 13 /* NodeTypes.VNODE_CALL */) {
|
|
1916
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1917
1917
|
}
|
|
1918
1918
|
if (codegenNode.isBlock &&
|
|
1919
1919
|
node.tag !== 'svg' &&
|
|
1920
1920
|
node.tag !== 'foreignObject') {
|
|
1921
|
-
return 0 /* NOT_CONSTANT */;
|
|
1921
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1922
1922
|
}
|
|
1923
1923
|
const flag = getPatchFlag(codegenNode);
|
|
1924
1924
|
if (!flag) {
|
|
1925
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
1925
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1926
1926
|
// Element itself has no patch flag. However we still need to check:
|
|
1927
1927
|
// 1. Even for a node with no patch flag, it is possible for it to contain
|
|
1928
1928
|
// non-hoistable expressions that refers to scope variables, e.g. compiler
|
|
1929
1929
|
// injected keys or cached event handlers. Therefore we need to always
|
|
1930
1930
|
// check the codegenNode's props to be sure.
|
|
1931
1931
|
const generatedPropsType = getGeneratedPropsConstantType(node, context);
|
|
1932
|
-
if (generatedPropsType === 0 /* NOT_CONSTANT */) {
|
|
1933
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1934
|
-
return 0 /* NOT_CONSTANT */;
|
|
1932
|
+
if (generatedPropsType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1933
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1934
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1935
1935
|
}
|
|
1936
1936
|
if (generatedPropsType < returnType) {
|
|
1937
1937
|
returnType = generatedPropsType;
|
|
@@ -1939,9 +1939,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1939
1939
|
// 2. its children.
|
|
1940
1940
|
for (let i = 0; i < node.children.length; i++) {
|
|
1941
1941
|
const childType = getConstantType(node.children[i], context);
|
|
1942
|
-
if (childType === 0 /* NOT_CONSTANT */) {
|
|
1943
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1944
|
-
return 0 /* NOT_CONSTANT */;
|
|
1942
|
+
if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1943
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1944
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1945
1945
|
}
|
|
1946
1946
|
if (childType < returnType) {
|
|
1947
1947
|
returnType = childType;
|
|
@@ -1951,14 +1951,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1951
1951
|
// type, check if any of the props can cause the type to be lowered
|
|
1952
1952
|
// we can skip can_patch because it's guaranteed by the absence of a
|
|
1953
1953
|
// patchFlag.
|
|
1954
|
-
if (returnType > 1 /* CAN_SKIP_PATCH */) {
|
|
1954
|
+
if (returnType > 1 /* ConstantTypes.CAN_SKIP_PATCH */) {
|
|
1955
1955
|
for (let i = 0; i < node.props.length; i++) {
|
|
1956
1956
|
const p = node.props[i];
|
|
1957
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind' && p.exp) {
|
|
1957
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'bind' && p.exp) {
|
|
1958
1958
|
const expType = getConstantType(p.exp, context);
|
|
1959
|
-
if (expType === 0 /* NOT_CONSTANT */) {
|
|
1960
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1961
|
-
return 0 /* NOT_CONSTANT */;
|
|
1959
|
+
if (expType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
1960
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1961
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1962
1962
|
}
|
|
1963
1963
|
if (expType < returnType) {
|
|
1964
1964
|
returnType = expType;
|
|
@@ -1973,9 +1973,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1973
1973
|
// except set custom directives.
|
|
1974
1974
|
for (let i = 0; i < node.props.length; i++) {
|
|
1975
1975
|
const p = node.props[i];
|
|
1976
|
-
if (p.type === 7 /* DIRECTIVE */) {
|
|
1977
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1978
|
-
return 0 /* NOT_CONSTANT */;
|
|
1976
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
1977
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1978
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1979
1979
|
}
|
|
1980
1980
|
}
|
|
1981
1981
|
context.removeHelper(OPEN_BLOCK);
|
|
@@ -1987,31 +1987,31 @@ var VueCompilerDOM = (function (exports) {
|
|
|
1987
1987
|
return returnType;
|
|
1988
1988
|
}
|
|
1989
1989
|
else {
|
|
1990
|
-
constantCache.set(node, 0 /* NOT_CONSTANT */);
|
|
1991
|
-
return 0 /* NOT_CONSTANT */;
|
|
1992
|
-
}
|
|
1993
|
-
case 2 /* TEXT */:
|
|
1994
|
-
case 3 /* COMMENT */:
|
|
1995
|
-
return 3 /* CAN_STRINGIFY */;
|
|
1996
|
-
case 9 /* IF */:
|
|
1997
|
-
case 11 /* FOR */:
|
|
1998
|
-
case 10 /* IF_BRANCH */:
|
|
1999
|
-
return 0 /* NOT_CONSTANT */;
|
|
2000
|
-
case 5 /* INTERPOLATION */:
|
|
2001
|
-
case 12 /* TEXT_CALL */:
|
|
1990
|
+
constantCache.set(node, 0 /* ConstantTypes.NOT_CONSTANT */);
|
|
1991
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
1992
|
+
}
|
|
1993
|
+
case 2 /* NodeTypes.TEXT */:
|
|
1994
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
1995
|
+
return 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
1996
|
+
case 9 /* NodeTypes.IF */:
|
|
1997
|
+
case 11 /* NodeTypes.FOR */:
|
|
1998
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
1999
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
2000
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2001
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
2002
2002
|
return getConstantType(node.content, context);
|
|
2003
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
2003
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
2004
2004
|
return node.constType;
|
|
2005
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
2006
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
2005
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
2006
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
2007
2007
|
for (let i = 0; i < node.children.length; i++) {
|
|
2008
2008
|
const child = node.children[i];
|
|
2009
2009
|
if (isString(child) || isSymbol(child)) {
|
|
2010
2010
|
continue;
|
|
2011
2011
|
}
|
|
2012
2012
|
const childType = getConstantType(child, context);
|
|
2013
|
-
if (childType === 0 /* NOT_CONSTANT */) {
|
|
2014
|
-
return 0 /* NOT_CONSTANT */;
|
|
2013
|
+
if (childType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
2014
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
2015
2015
|
}
|
|
2016
2016
|
else if (childType < returnType) {
|
|
2017
2017
|
returnType = childType;
|
|
@@ -2019,7 +2019,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
return returnType;
|
|
2021
2021
|
default:
|
|
2022
|
-
return 0 /* NOT_CONSTANT */;
|
|
2022
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
2025
2025
|
const allowHoistedHelperSet = new Set([
|
|
@@ -2029,48 +2029,48 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2029
2029
|
GUARD_REACTIVE_PROPS
|
|
2030
2030
|
]);
|
|
2031
2031
|
function getConstantTypeOfHelperCall(value, context) {
|
|
2032
|
-
if (value.type === 14 /* JS_CALL_EXPRESSION */ &&
|
|
2032
|
+
if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */ &&
|
|
2033
2033
|
!isString(value.callee) &&
|
|
2034
2034
|
allowHoistedHelperSet.has(value.callee)) {
|
|
2035
2035
|
const arg = value.arguments[0];
|
|
2036
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2036
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2037
2037
|
return getConstantType(arg, context);
|
|
2038
2038
|
}
|
|
2039
|
-
else if (arg.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
2039
|
+
else if (arg.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
2040
2040
|
// in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(exp))`
|
|
2041
2041
|
return getConstantTypeOfHelperCall(arg, context);
|
|
2042
2042
|
}
|
|
2043
2043
|
}
|
|
2044
|
-
return 0 /* NOT_CONSTANT */;
|
|
2044
|
+
return 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
2045
2045
|
}
|
|
2046
2046
|
function getGeneratedPropsConstantType(node, context) {
|
|
2047
|
-
let returnType = 3 /* CAN_STRINGIFY */;
|
|
2047
|
+
let returnType = 3 /* ConstantTypes.CAN_STRINGIFY */;
|
|
2048
2048
|
const props = getNodeProps(node);
|
|
2049
|
-
if (props && props.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
2049
|
+
if (props && props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
2050
2050
|
const { properties } = props;
|
|
2051
2051
|
for (let i = 0; i < properties.length; i++) {
|
|
2052
2052
|
const { key, value } = properties[i];
|
|
2053
2053
|
const keyType = getConstantType(key, context);
|
|
2054
|
-
if (keyType === 0 /* NOT_CONSTANT */) {
|
|
2054
|
+
if (keyType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
2055
2055
|
return keyType;
|
|
2056
2056
|
}
|
|
2057
2057
|
if (keyType < returnType) {
|
|
2058
2058
|
returnType = keyType;
|
|
2059
2059
|
}
|
|
2060
2060
|
let valueType;
|
|
2061
|
-
if (value.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2061
|
+
if (value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2062
2062
|
valueType = getConstantType(value, context);
|
|
2063
2063
|
}
|
|
2064
|
-
else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
2064
|
+
else if (value.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
2065
2065
|
// some helper calls can be hoisted,
|
|
2066
2066
|
// such as the `normalizeProps` generated by the compiler for pre-normalize class,
|
|
2067
2067
|
// in this case we need to respect the ConstantType of the helper's arguments
|
|
2068
2068
|
valueType = getConstantTypeOfHelperCall(value, context);
|
|
2069
2069
|
}
|
|
2070
2070
|
else {
|
|
2071
|
-
valueType = 0 /* NOT_CONSTANT */;
|
|
2071
|
+
valueType = 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
2072
2072
|
}
|
|
2073
|
-
if (valueType === 0 /* NOT_CONSTANT */) {
|
|
2073
|
+
if (valueType === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
2074
2074
|
return valueType;
|
|
2075
2075
|
}
|
|
2076
2076
|
if (valueType < returnType) {
|
|
@@ -2082,7 +2082,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2082
2082
|
}
|
|
2083
2083
|
function getNodeProps(node) {
|
|
2084
2084
|
const codegenNode = node.codegenNode;
|
|
2085
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
2085
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
2086
2086
|
return codegenNode.props;
|
|
2087
2087
|
}
|
|
2088
2088
|
}
|
|
@@ -2207,7 +2207,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2207
2207
|
if (isString(exp))
|
|
2208
2208
|
exp = createSimpleExpression(exp);
|
|
2209
2209
|
context.hoists.push(exp);
|
|
2210
|
-
const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* CAN_HOIST */);
|
|
2210
|
+
const identifier = createSimpleExpression(`_hoisted_${context.hoists.length}`, false, exp.loc, 2 /* ConstantTypes.CAN_HOIST */);
|
|
2211
2211
|
identifier.hoisted = exp;
|
|
2212
2212
|
return identifier;
|
|
2213
2213
|
},
|
|
@@ -2251,7 +2251,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2251
2251
|
// single element root is never hoisted so codegenNode will never be
|
|
2252
2252
|
// SimpleExpressionNode
|
|
2253
2253
|
const codegenNode = child.codegenNode;
|
|
2254
|
-
if (codegenNode.type === 13 /* VNODE_CALL */) {
|
|
2254
|
+
if (codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
2255
2255
|
makeBlock(codegenNode, context);
|
|
2256
2256
|
}
|
|
2257
2257
|
root.codegenNode = codegenNode;
|
|
@@ -2265,13 +2265,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
else if (children.length > 1) {
|
|
2267
2267
|
// root has multiple nodes - return a fragment block.
|
|
2268
|
-
let patchFlag = 64 /* STABLE_FRAGMENT */;
|
|
2269
|
-
let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
2268
|
+
let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
|
|
2269
|
+
let patchFlagText = PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
|
|
2270
2270
|
// check if the fragment actually contains a single valid child with
|
|
2271
2271
|
// the rest being comments
|
|
2272
|
-
if (children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
2273
|
-
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
2274
|
-
patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
2272
|
+
if (children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
|
|
2273
|
+
patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
|
|
2274
|
+
patchFlagText += `, ${PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
|
|
2275
2275
|
}
|
|
2276
2276
|
root.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, root.children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, undefined, false /* isComponent */);
|
|
2277
2277
|
}
|
|
@@ -2317,29 +2317,29 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
2319
|
switch (node.type) {
|
|
2320
|
-
case 3 /* COMMENT */:
|
|
2320
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2321
2321
|
if (!context.ssr) {
|
|
2322
2322
|
// inject import for the Comment symbol, which is needed for creating
|
|
2323
2323
|
// comment nodes with `createVNode`
|
|
2324
2324
|
context.helper(CREATE_COMMENT);
|
|
2325
2325
|
}
|
|
2326
2326
|
break;
|
|
2327
|
-
case 5 /* INTERPOLATION */:
|
|
2327
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2328
2328
|
// no need to traverse, but we need to inject toString helper
|
|
2329
2329
|
if (!context.ssr) {
|
|
2330
2330
|
context.helper(TO_DISPLAY_STRING);
|
|
2331
2331
|
}
|
|
2332
2332
|
break;
|
|
2333
2333
|
// for container types, further traverse downwards
|
|
2334
|
-
case 9 /* IF */:
|
|
2334
|
+
case 9 /* NodeTypes.IF */:
|
|
2335
2335
|
for (let i = 0; i < node.branches.length; i++) {
|
|
2336
2336
|
traverseNode(node.branches[i], context);
|
|
2337
2337
|
}
|
|
2338
2338
|
break;
|
|
2339
|
-
case 10 /* IF_BRANCH */:
|
|
2340
|
-
case 11 /* FOR */:
|
|
2341
|
-
case 1 /* ELEMENT */:
|
|
2342
|
-
case 0 /* ROOT */:
|
|
2339
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
2340
|
+
case 11 /* NodeTypes.FOR */:
|
|
2341
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2342
|
+
case 0 /* NodeTypes.ROOT */:
|
|
2343
2343
|
traverseChildren(node, context);
|
|
2344
2344
|
break;
|
|
2345
2345
|
}
|
|
@@ -2355,17 +2355,17 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2355
2355
|
? (n) => n === name
|
|
2356
2356
|
: (n) => name.test(n);
|
|
2357
2357
|
return (node, context) => {
|
|
2358
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
2358
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
2359
2359
|
const { props } = node;
|
|
2360
2360
|
// structural directive transforms are not concerned with slots
|
|
2361
2361
|
// as they are handled separately in vSlot.ts
|
|
2362
|
-
if (node.tagType === 3 /* TEMPLATE */ && props.some(isVSlot)) {
|
|
2362
|
+
if (node.tagType === 3 /* ElementTypes.TEMPLATE */ && props.some(isVSlot)) {
|
|
2363
2363
|
return;
|
|
2364
2364
|
}
|
|
2365
2365
|
const exitFns = [];
|
|
2366
2366
|
for (let i = 0; i < props.length; i++) {
|
|
2367
2367
|
const prop = props[i];
|
|
2368
|
-
if (prop.type === 7 /* DIRECTIVE */ && matches(prop.name)) {
|
|
2368
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */ && matches(prop.name)) {
|
|
2369
2369
|
// structural directives are removed to avoid infinite recursion
|
|
2370
2370
|
// also we remove them *before* applying so that it can further
|
|
2371
2371
|
// traverse itself in case it moves the node around
|
|
@@ -2588,10 +2588,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2588
2588
|
}
|
|
2589
2589
|
function isText$1(n) {
|
|
2590
2590
|
return (isString(n) ||
|
|
2591
|
-
n.type === 4 /* SIMPLE_EXPRESSION */ ||
|
|
2592
|
-
n.type === 2 /* TEXT */ ||
|
|
2593
|
-
n.type === 5 /* INTERPOLATION */ ||
|
|
2594
|
-
n.type === 8 /* COMPOUND_EXPRESSION */);
|
|
2591
|
+
n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
2592
|
+
n.type === 2 /* NodeTypes.TEXT */ ||
|
|
2593
|
+
n.type === 5 /* NodeTypes.INTERPOLATION */ ||
|
|
2594
|
+
n.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */);
|
|
2595
2595
|
}
|
|
2596
2596
|
function genNodeListAsArray(nodes, context) {
|
|
2597
2597
|
const multilines = nodes.length > 3 ||
|
|
@@ -2636,68 +2636,68 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2636
2636
|
return;
|
|
2637
2637
|
}
|
|
2638
2638
|
switch (node.type) {
|
|
2639
|
-
case 1 /* ELEMENT */:
|
|
2640
|
-
case 9 /* IF */:
|
|
2641
|
-
case 11 /* FOR */:
|
|
2639
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
2640
|
+
case 9 /* NodeTypes.IF */:
|
|
2641
|
+
case 11 /* NodeTypes.FOR */:
|
|
2642
2642
|
assert(node.codegenNode != null, `Codegen node is missing for element/if/for node. ` +
|
|
2643
2643
|
`Apply appropriate transforms first.`);
|
|
2644
2644
|
genNode(node.codegenNode, context);
|
|
2645
2645
|
break;
|
|
2646
|
-
case 2 /* TEXT */:
|
|
2646
|
+
case 2 /* NodeTypes.TEXT */:
|
|
2647
2647
|
genText(node, context);
|
|
2648
2648
|
break;
|
|
2649
|
-
case 4 /* SIMPLE_EXPRESSION */:
|
|
2649
|
+
case 4 /* NodeTypes.SIMPLE_EXPRESSION */:
|
|
2650
2650
|
genExpression(node, context);
|
|
2651
2651
|
break;
|
|
2652
|
-
case 5 /* INTERPOLATION */:
|
|
2652
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
2653
2653
|
genInterpolation(node, context);
|
|
2654
2654
|
break;
|
|
2655
|
-
case 12 /* TEXT_CALL */:
|
|
2655
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
2656
2656
|
genNode(node.codegenNode, context);
|
|
2657
2657
|
break;
|
|
2658
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
2658
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
2659
2659
|
genCompoundExpression(node, context);
|
|
2660
2660
|
break;
|
|
2661
|
-
case 3 /* COMMENT */:
|
|
2661
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
2662
2662
|
genComment(node, context);
|
|
2663
2663
|
break;
|
|
2664
|
-
case 13 /* VNODE_CALL */:
|
|
2664
|
+
case 13 /* NodeTypes.VNODE_CALL */:
|
|
2665
2665
|
genVNodeCall(node, context);
|
|
2666
2666
|
break;
|
|
2667
|
-
case 14 /* JS_CALL_EXPRESSION */:
|
|
2667
|
+
case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
|
|
2668
2668
|
genCallExpression(node, context);
|
|
2669
2669
|
break;
|
|
2670
|
-
case 15 /* JS_OBJECT_EXPRESSION */:
|
|
2670
|
+
case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
|
|
2671
2671
|
genObjectExpression(node, context);
|
|
2672
2672
|
break;
|
|
2673
|
-
case 17 /* JS_ARRAY_EXPRESSION */:
|
|
2673
|
+
case 17 /* NodeTypes.JS_ARRAY_EXPRESSION */:
|
|
2674
2674
|
genArrayExpression(node, context);
|
|
2675
2675
|
break;
|
|
2676
|
-
case 18 /* JS_FUNCTION_EXPRESSION */:
|
|
2676
|
+
case 18 /* NodeTypes.JS_FUNCTION_EXPRESSION */:
|
|
2677
2677
|
genFunctionExpression(node, context);
|
|
2678
2678
|
break;
|
|
2679
|
-
case 19 /* JS_CONDITIONAL_EXPRESSION */:
|
|
2679
|
+
case 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */:
|
|
2680
2680
|
genConditionalExpression(node, context);
|
|
2681
2681
|
break;
|
|
2682
|
-
case 20 /* JS_CACHE_EXPRESSION */:
|
|
2682
|
+
case 20 /* NodeTypes.JS_CACHE_EXPRESSION */:
|
|
2683
2683
|
genCacheExpression(node, context);
|
|
2684
2684
|
break;
|
|
2685
|
-
case 21 /* JS_BLOCK_STATEMENT */:
|
|
2685
|
+
case 21 /* NodeTypes.JS_BLOCK_STATEMENT */:
|
|
2686
2686
|
genNodeList(node.body, context, true, false);
|
|
2687
2687
|
break;
|
|
2688
2688
|
// SSR only types
|
|
2689
|
-
case 22 /* JS_TEMPLATE_LITERAL */:
|
|
2689
|
+
case 22 /* NodeTypes.JS_TEMPLATE_LITERAL */:
|
|
2690
2690
|
break;
|
|
2691
|
-
case 23 /* JS_IF_STATEMENT */:
|
|
2691
|
+
case 23 /* NodeTypes.JS_IF_STATEMENT */:
|
|
2692
2692
|
break;
|
|
2693
|
-
case 24 /* JS_ASSIGNMENT_EXPRESSION */:
|
|
2693
|
+
case 24 /* NodeTypes.JS_ASSIGNMENT_EXPRESSION */:
|
|
2694
2694
|
break;
|
|
2695
|
-
case 25 /* JS_SEQUENCE_EXPRESSION */:
|
|
2695
|
+
case 25 /* NodeTypes.JS_SEQUENCE_EXPRESSION */:
|
|
2696
2696
|
break;
|
|
2697
|
-
case 26 /* JS_RETURN_STATEMENT */:
|
|
2697
|
+
case 26 /* NodeTypes.JS_RETURN_STATEMENT */:
|
|
2698
2698
|
break;
|
|
2699
2699
|
/* istanbul ignore next */
|
|
2700
|
-
case 10 /* IF_BRANCH */:
|
|
2700
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
2701
2701
|
// noop
|
|
2702
2702
|
break;
|
|
2703
2703
|
default:
|
|
@@ -2737,7 +2737,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2737
2737
|
}
|
|
2738
2738
|
function genExpressionAsPropertyKey(node, context) {
|
|
2739
2739
|
const { push } = context;
|
|
2740
|
-
if (node.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
2740
|
+
if (node.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
2741
2741
|
push(`[`);
|
|
2742
2742
|
genCompoundExpression(node, context);
|
|
2743
2743
|
push(`]`);
|
|
@@ -2814,7 +2814,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2814
2814
|
return;
|
|
2815
2815
|
}
|
|
2816
2816
|
const multilines = properties.length > 1 ||
|
|
2817
|
-
(properties.some(p => p.value.type !== 4 /* SIMPLE_EXPRESSION */));
|
|
2817
|
+
(properties.some(p => p.value.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */));
|
|
2818
2818
|
push(multilines ? `{` : `{ `);
|
|
2819
2819
|
multilines && indent();
|
|
2820
2820
|
for (let i = 0; i < properties.length; i++) {
|
|
@@ -2883,7 +2883,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2883
2883
|
function genConditionalExpression(node, context) {
|
|
2884
2884
|
const { test, consequent, alternate, newline: needNewline } = node;
|
|
2885
2885
|
const { push, indent, deindent, newline } = context;
|
|
2886
|
-
if (test.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2886
|
+
if (test.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
2887
2887
|
const needsParens = !isSimpleIdentifier(test.content);
|
|
2888
2888
|
needsParens && push(`(`);
|
|
2889
2889
|
genExpression(test, context);
|
|
@@ -2903,7 +2903,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
2903
2903
|
needNewline && newline();
|
|
2904
2904
|
needNewline || push(` `);
|
|
2905
2905
|
push(`: `);
|
|
2906
|
-
const isNested = alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */;
|
|
2906
|
+
const isNested = alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */;
|
|
2907
2907
|
if (!isNested) {
|
|
2908
2908
|
context.indentLevel++;
|
|
2909
2909
|
}
|
|
@@ -3067,32 +3067,32 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3067
3067
|
if (keywordMatch) {
|
|
3068
3068
|
message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
|
|
3069
3069
|
}
|
|
3070
|
-
context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, message));
|
|
3070
|
+
context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, message));
|
|
3071
3071
|
}
|
|
3072
3072
|
}
|
|
3073
3073
|
|
|
3074
3074
|
const transformExpression = (node, context) => {
|
|
3075
|
-
if (node.type === 5 /* INTERPOLATION */) {
|
|
3075
|
+
if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
3076
3076
|
node.content = processExpression(node.content, context);
|
|
3077
3077
|
}
|
|
3078
|
-
else if (node.type === 1 /* ELEMENT */) {
|
|
3078
|
+
else if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
3079
3079
|
// handle directives on element
|
|
3080
3080
|
for (let i = 0; i < node.props.length; i++) {
|
|
3081
3081
|
const dir = node.props[i];
|
|
3082
3082
|
// do not process for v-on & v-for since they are special handled
|
|
3083
|
-
if (dir.type === 7 /* DIRECTIVE */ && dir.name !== 'for') {
|
|
3083
|
+
if (dir.type === 7 /* NodeTypes.DIRECTIVE */ && dir.name !== 'for') {
|
|
3084
3084
|
const exp = dir.exp;
|
|
3085
3085
|
const arg = dir.arg;
|
|
3086
3086
|
// do not process exp if this is v-on:arg - we need special handling
|
|
3087
3087
|
// for wrapping inline statements.
|
|
3088
3088
|
if (exp &&
|
|
3089
|
-
exp.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
3089
|
+
exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
3090
3090
|
!(dir.name === 'on' && arg)) {
|
|
3091
3091
|
dir.exp = processExpression(exp, context,
|
|
3092
3092
|
// slot args must be processed as function params
|
|
3093
3093
|
dir.name === 'slot');
|
|
3094
3094
|
}
|
|
3095
|
-
if (arg && arg.type === 4 /* SIMPLE_EXPRESSION */ && !arg.isStatic) {
|
|
3095
|
+
if (arg && arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !arg.isStatic) {
|
|
3096
3096
|
dir.arg = processExpression(arg, context);
|
|
3097
3097
|
}
|
|
3098
3098
|
}
|
|
@@ -3127,7 +3127,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3127
3127
|
let key = 0;
|
|
3128
3128
|
while (i-- >= 0) {
|
|
3129
3129
|
const sibling = siblings[i];
|
|
3130
|
-
if (sibling && sibling.type === 9 /* IF */) {
|
|
3130
|
+
if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
|
|
3131
3131
|
key += sibling.branches.length;
|
|
3132
3132
|
}
|
|
3133
3133
|
}
|
|
@@ -3150,7 +3150,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3150
3150
|
if (dir.name !== 'else' &&
|
|
3151
3151
|
(!dir.exp || !dir.exp.content.trim())) {
|
|
3152
3152
|
const loc = dir.exp ? dir.exp.loc : node.loc;
|
|
3153
|
-
context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
|
|
3153
|
+
context.onError(createCompilerError(28 /* ErrorCodes.X_V_IF_NO_EXPRESSION */, dir.loc));
|
|
3154
3154
|
dir.exp = createSimpleExpression(`true`, false, loc);
|
|
3155
3155
|
}
|
|
3156
3156
|
if (dir.exp) {
|
|
@@ -3159,7 +3159,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3159
3159
|
if (dir.name === 'if') {
|
|
3160
3160
|
const branch = createIfBranch(node, dir);
|
|
3161
3161
|
const ifNode = {
|
|
3162
|
-
type: 9 /* IF */,
|
|
3162
|
+
type: 9 /* NodeTypes.IF */,
|
|
3163
3163
|
loc: node.loc,
|
|
3164
3164
|
branches: [branch]
|
|
3165
3165
|
};
|
|
@@ -3175,22 +3175,22 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3175
3175
|
let i = siblings.indexOf(node);
|
|
3176
3176
|
while (i-- >= -1) {
|
|
3177
3177
|
const sibling = siblings[i];
|
|
3178
|
-
if (sibling && sibling.type === 3 /* COMMENT */) {
|
|
3178
|
+
if (sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
|
|
3179
3179
|
context.removeNode(sibling);
|
|
3180
3180
|
comments.unshift(sibling);
|
|
3181
3181
|
continue;
|
|
3182
3182
|
}
|
|
3183
3183
|
if (sibling &&
|
|
3184
|
-
sibling.type === 2 /* TEXT */ &&
|
|
3184
|
+
sibling.type === 2 /* NodeTypes.TEXT */ &&
|
|
3185
3185
|
!sibling.content.trim().length) {
|
|
3186
3186
|
context.removeNode(sibling);
|
|
3187
3187
|
continue;
|
|
3188
3188
|
}
|
|
3189
|
-
if (sibling && sibling.type === 9 /* IF */) {
|
|
3189
|
+
if (sibling && sibling.type === 9 /* NodeTypes.IF */) {
|
|
3190
3190
|
// Check if v-else was followed by v-else-if
|
|
3191
3191
|
if (dir.name === 'else-if' &&
|
|
3192
3192
|
sibling.branches[sibling.branches.length - 1].condition === undefined) {
|
|
3193
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3193
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3194
3194
|
}
|
|
3195
3195
|
// move the node to the if node's branches
|
|
3196
3196
|
context.removeNode();
|
|
@@ -3198,7 +3198,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3198
3198
|
if (comments.length &&
|
|
3199
3199
|
// #3619 ignore comments if the v-if is direct child of <transition>
|
|
3200
3200
|
!(context.parent &&
|
|
3201
|
-
context.parent.type === 1 /* ELEMENT */ &&
|
|
3201
|
+
context.parent.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3202
3202
|
isBuiltInType(context.parent.tag, 'transition'))) {
|
|
3203
3203
|
branch.children = [...comments, ...branch.children];
|
|
3204
3204
|
}
|
|
@@ -3208,7 +3208,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3208
3208
|
if (key) {
|
|
3209
3209
|
sibling.branches.forEach(({ userKey }) => {
|
|
3210
3210
|
if (isSameKey(userKey, key)) {
|
|
3211
|
-
context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
|
|
3211
|
+
context.onError(createCompilerError(29 /* ErrorCodes.X_V_IF_SAME_KEY */, branch.userKey.loc));
|
|
3212
3212
|
}
|
|
3213
3213
|
});
|
|
3214
3214
|
}
|
|
@@ -3226,16 +3226,16 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3226
3226
|
context.currentNode = null;
|
|
3227
3227
|
}
|
|
3228
3228
|
else {
|
|
3229
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3229
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, node.loc));
|
|
3230
3230
|
}
|
|
3231
3231
|
break;
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
3234
|
}
|
|
3235
3235
|
function createIfBranch(node, dir) {
|
|
3236
|
-
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3236
|
+
const isTemplateIf = node.tagType === 3 /* ElementTypes.TEMPLATE */;
|
|
3237
3237
|
return {
|
|
3238
|
-
type: 10 /* IF_BRANCH */,
|
|
3238
|
+
type: 10 /* NodeTypes.IF_BRANCH */,
|
|
3239
3239
|
loc: node.loc,
|
|
3240
3240
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3241
3241
|
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
@@ -3259,26 +3259,26 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3259
3259
|
}
|
|
3260
3260
|
function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
3261
3261
|
const { helper } = context;
|
|
3262
|
-
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* CAN_HOIST */));
|
|
3262
|
+
const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2 /* ConstantTypes.CAN_HOIST */));
|
|
3263
3263
|
const { children } = branch;
|
|
3264
3264
|
const firstChild = children[0];
|
|
3265
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* ELEMENT */;
|
|
3265
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1 /* NodeTypes.ELEMENT */;
|
|
3266
3266
|
if (needFragmentWrapper) {
|
|
3267
|
-
if (children.length === 1 && firstChild.type === 11 /* FOR */) {
|
|
3267
|
+
if (children.length === 1 && firstChild.type === 11 /* NodeTypes.FOR */) {
|
|
3268
3268
|
// optimize away nested fragments when child is a ForNode
|
|
3269
3269
|
const vnodeCall = firstChild.codegenNode;
|
|
3270
3270
|
injectProp(vnodeCall, keyProperty, context);
|
|
3271
3271
|
return vnodeCall;
|
|
3272
3272
|
}
|
|
3273
3273
|
else {
|
|
3274
|
-
let patchFlag = 64 /* STABLE_FRAGMENT */;
|
|
3275
|
-
let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
3274
|
+
let patchFlag = 64 /* PatchFlags.STABLE_FRAGMENT */;
|
|
3275
|
+
let patchFlagText = PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */];
|
|
3276
3276
|
// check if the fragment actually contains a single valid child with
|
|
3277
3277
|
// the rest being comments
|
|
3278
3278
|
if (!branch.isTemplateIf &&
|
|
3279
|
-
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3280
|
-
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3281
|
-
patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
3279
|
+
children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */).length === 1) {
|
|
3280
|
+
patchFlag |= 2048 /* PatchFlags.DEV_ROOT_FRAGMENT */;
|
|
3281
|
+
patchFlagText += `, ${PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]}`;
|
|
3282
3282
|
}
|
|
3283
3283
|
return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag + (` /* ${patchFlagText} */` ), undefined, undefined, true, false, false /* isComponent */, branch.loc);
|
|
3284
3284
|
}
|
|
@@ -3287,7 +3287,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3287
3287
|
const ret = firstChild.codegenNode;
|
|
3288
3288
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3289
3289
|
// Change createVNode to createBlock.
|
|
3290
|
-
if (vnodeCall.type === 13 /* VNODE_CALL */) {
|
|
3290
|
+
if (vnodeCall.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
3291
3291
|
makeBlock(vnodeCall, context);
|
|
3292
3292
|
}
|
|
3293
3293
|
// inject branch key
|
|
@@ -3299,7 +3299,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3299
3299
|
if (!a || a.type !== b.type) {
|
|
3300
3300
|
return false;
|
|
3301
3301
|
}
|
|
3302
|
-
if (a.type === 6 /* ATTRIBUTE */) {
|
|
3302
|
+
if (a.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
3303
3303
|
if (a.value.content !== b.value.content) {
|
|
3304
3304
|
return false;
|
|
3305
3305
|
}
|
|
@@ -3311,7 +3311,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3311
3311
|
if (exp.type !== branchExp.type) {
|
|
3312
3312
|
return false;
|
|
3313
3313
|
}
|
|
3314
|
-
if (exp.type !== 4 /* SIMPLE_EXPRESSION */ ||
|
|
3314
|
+
if (exp.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
3315
3315
|
exp.isStatic !== branchExp.isStatic ||
|
|
3316
3316
|
exp.content !== branchExp.content) {
|
|
3317
3317
|
return false;
|
|
@@ -3321,15 +3321,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3321
3321
|
}
|
|
3322
3322
|
function getParentCondition(node) {
|
|
3323
3323
|
while (true) {
|
|
3324
|
-
if (node.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
3325
|
-
if (node.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
3324
|
+
if (node.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
3325
|
+
if (node.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
3326
3326
|
node = node.alternate;
|
|
3327
3327
|
}
|
|
3328
3328
|
else {
|
|
3329
3329
|
return node;
|
|
3330
3330
|
}
|
|
3331
3331
|
}
|
|
3332
|
-
else if (node.type === 20 /* JS_CACHE_EXPRESSION */) {
|
|
3332
|
+
else if (node.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */) {
|
|
3333
3333
|
node = node.value;
|
|
3334
3334
|
}
|
|
3335
3335
|
}
|
|
@@ -3347,17 +3347,17 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3347
3347
|
const memo = findDir(node, 'memo');
|
|
3348
3348
|
const keyProp = findProp(node, `key`);
|
|
3349
3349
|
const keyExp = keyProp &&
|
|
3350
|
-
(keyProp.type === 6 /* ATTRIBUTE */
|
|
3350
|
+
(keyProp.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
3351
3351
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3352
3352
|
: keyProp.exp);
|
|
3353
3353
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3354
|
-
const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
3355
|
-
forNode.source.constType > 0 /* NOT_CONSTANT */;
|
|
3354
|
+
const isStableFragment = forNode.source.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
3355
|
+
forNode.source.constType > 0 /* ConstantTypes.NOT_CONSTANT */;
|
|
3356
3356
|
const fragmentFlag = isStableFragment
|
|
3357
|
-
? 64 /* STABLE_FRAGMENT */
|
|
3357
|
+
? 64 /* PatchFlags.STABLE_FRAGMENT */
|
|
3358
3358
|
: keyProp
|
|
3359
|
-
? 128 /* KEYED_FRAGMENT */
|
|
3360
|
-
: 256 /* UNKEYED_FRAGMENT */;
|
|
3359
|
+
? 128 /* PatchFlags.KEYED_FRAGMENT */
|
|
3360
|
+
: 256 /* PatchFlags.UNKEYED_FRAGMENT */;
|
|
3361
3361
|
forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), undefined, renderExp, fragmentFlag +
|
|
3362
3362
|
(` /* ${PatchFlagNames[fragmentFlag]} */` ), undefined, undefined, true /* isBlock */, !isStableFragment /* disableTracking */, false /* isComponent */, node.loc);
|
|
3363
3363
|
return () => {
|
|
@@ -3367,16 +3367,16 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3367
3367
|
// check <template v-for> key placement
|
|
3368
3368
|
if (isTemplate) {
|
|
3369
3369
|
node.children.some(c => {
|
|
3370
|
-
if (c.type === 1 /* ELEMENT */) {
|
|
3370
|
+
if (c.type === 1 /* NodeTypes.ELEMENT */) {
|
|
3371
3371
|
const key = findProp(c, 'key');
|
|
3372
3372
|
if (key) {
|
|
3373
|
-
context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
|
|
3373
|
+
context.onError(createCompilerError(33 /* ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
|
|
3374
3374
|
return true;
|
|
3375
3375
|
}
|
|
3376
3376
|
}
|
|
3377
3377
|
});
|
|
3378
3378
|
}
|
|
3379
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* ELEMENT */;
|
|
3379
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */;
|
|
3380
3380
|
const slotOutlet = isSlotOutlet(node)
|
|
3381
3381
|
? node
|
|
3382
3382
|
: isTemplate &&
|
|
@@ -3397,8 +3397,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3397
3397
|
else if (needFragmentWrapper) {
|
|
3398
3398
|
// <template v-for="..."> with text or multi-elements
|
|
3399
3399
|
// should generate a fragment block for each loop
|
|
3400
|
-
childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* STABLE_FRAGMENT */ +
|
|
3401
|
-
(` /* ${PatchFlagNames[64 /* STABLE_FRAGMENT */]} */`
|
|
3400
|
+
childBlock = createVNodeCall(context, helper(FRAGMENT), keyProperty ? createObjectExpression([keyProperty]) : undefined, node.children, 64 /* PatchFlags.STABLE_FRAGMENT */ +
|
|
3401
|
+
(` /* ${PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */]} */`
|
|
3402
3402
|
), undefined, undefined, true, undefined, false /* isComponent */);
|
|
3403
3403
|
}
|
|
3404
3404
|
else {
|
|
@@ -3455,7 +3455,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3455
3455
|
// target-agnostic transform used for both Client and SSR
|
|
3456
3456
|
function processFor(node, dir, context, processCodegen) {
|
|
3457
3457
|
if (!dir.exp) {
|
|
3458
|
-
context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
|
|
3458
|
+
context.onError(createCompilerError(31 /* ErrorCodes.X_V_FOR_NO_EXPRESSION */, dir.loc));
|
|
3459
3459
|
return;
|
|
3460
3460
|
}
|
|
3461
3461
|
const parseResult = parseForExpression(
|
|
@@ -3463,13 +3463,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3463
3463
|
// before expression transform.
|
|
3464
3464
|
dir.exp, context);
|
|
3465
3465
|
if (!parseResult) {
|
|
3466
|
-
context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
|
|
3466
|
+
context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
|
|
3467
3467
|
return;
|
|
3468
3468
|
}
|
|
3469
3469
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3470
3470
|
const { source, value, key, index } = parseResult;
|
|
3471
3471
|
const forNode = {
|
|
3472
|
-
type: 11 /* FOR */,
|
|
3472
|
+
type: 11 /* NodeTypes.FOR */,
|
|
3473
3473
|
loc: dir.loc,
|
|
3474
3474
|
source,
|
|
3475
3475
|
valueAlias: value,
|
|
@@ -3569,9 +3569,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3569
3569
|
// Note the exit callback is executed before buildSlots() on the same node,
|
|
3570
3570
|
// so only nested slots see positive numbers.
|
|
3571
3571
|
const trackSlotScopes = (node, context) => {
|
|
3572
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
3573
|
-
(node.tagType === 1 /* COMPONENT */ ||
|
|
3574
|
-
node.tagType === 3 /* TEMPLATE */)) {
|
|
3572
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3573
|
+
(node.tagType === 1 /* ElementTypes.COMPONENT */ ||
|
|
3574
|
+
node.tagType === 3 /* ElementTypes.TEMPLATE */)) {
|
|
3575
3575
|
// We are only checking non-empty v-slot here
|
|
3576
3576
|
// since we only care about slots that introduce scope variables.
|
|
3577
3577
|
const vSlot = findDir(node, 'slot');
|
|
@@ -3633,20 +3633,21 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3633
3633
|
let hasNamedDefaultSlot = false;
|
|
3634
3634
|
const implicitDefaultChildren = [];
|
|
3635
3635
|
const seenSlotNames = new Set();
|
|
3636
|
+
let conditionalBranchIndex = 0;
|
|
3636
3637
|
for (let i = 0; i < children.length; i++) {
|
|
3637
3638
|
const slotElement = children[i];
|
|
3638
3639
|
let slotDir;
|
|
3639
3640
|
if (!isTemplateNode(slotElement) ||
|
|
3640
3641
|
!(slotDir = findDir(slotElement, 'slot', true))) {
|
|
3641
3642
|
// not a <template v-slot>, skip.
|
|
3642
|
-
if (slotElement.type !== 3 /* COMMENT */) {
|
|
3643
|
+
if (slotElement.type !== 3 /* NodeTypes.COMMENT */) {
|
|
3643
3644
|
implicitDefaultChildren.push(slotElement);
|
|
3644
3645
|
}
|
|
3645
3646
|
continue;
|
|
3646
3647
|
}
|
|
3647
3648
|
if (onComponentSlot) {
|
|
3648
3649
|
// already has on-component slot - this is incorrect usage.
|
|
3649
|
-
context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
|
|
3650
|
+
context.onError(createCompilerError(37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
|
|
3650
3651
|
break;
|
|
3651
3652
|
}
|
|
3652
3653
|
hasTemplateSlots = true;
|
|
@@ -3667,7 +3668,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3667
3668
|
let vFor;
|
|
3668
3669
|
if ((vIf = findDir(slotElement, 'if'))) {
|
|
3669
3670
|
hasDynamicSlots = true;
|
|
3670
|
-
dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback));
|
|
3671
|
+
dynamicSlots.push(createConditionalExpression(vIf.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback));
|
|
3671
3672
|
}
|
|
3672
3673
|
else if ((vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))) {
|
|
3673
3674
|
// find adjacent v-if
|
|
@@ -3675,7 +3676,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3675
3676
|
let prev;
|
|
3676
3677
|
while (j--) {
|
|
3677
3678
|
prev = children[j];
|
|
3678
|
-
if (prev.type !== 3 /* COMMENT */) {
|
|
3679
|
+
if (prev.type !== 3 /* NodeTypes.COMMENT */) {
|
|
3679
3680
|
break;
|
|
3680
3681
|
}
|
|
3681
3682
|
}
|
|
@@ -3685,15 +3686,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3685
3686
|
i--;
|
|
3686
3687
|
// attach this slot to previous conditional
|
|
3687
3688
|
let conditional = dynamicSlots[dynamicSlots.length - 1];
|
|
3688
|
-
while (conditional.alternate.type === 19 /* JS_CONDITIONAL_EXPRESSION */) {
|
|
3689
|
+
while (conditional.alternate.type === 19 /* NodeTypes.JS_CONDITIONAL_EXPRESSION */) {
|
|
3689
3690
|
conditional = conditional.alternate;
|
|
3690
3691
|
}
|
|
3691
3692
|
conditional.alternate = vElse.exp
|
|
3692
|
-
? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction), defaultFallback)
|
|
3693
|
-
: buildDynamicSlot(slotName, slotFunction);
|
|
3693
|
+
? createConditionalExpression(vElse.exp, buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++), defaultFallback)
|
|
3694
|
+
: buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++);
|
|
3694
3695
|
}
|
|
3695
3696
|
else {
|
|
3696
|
-
context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
|
|
3697
|
+
context.onError(createCompilerError(30 /* ErrorCodes.X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
|
|
3697
3698
|
}
|
|
3698
3699
|
}
|
|
3699
3700
|
else if ((vFor = findDir(slotElement, 'for'))) {
|
|
@@ -3709,14 +3710,14 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3709
3710
|
]));
|
|
3710
3711
|
}
|
|
3711
3712
|
else {
|
|
3712
|
-
context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
|
|
3713
|
+
context.onError(createCompilerError(32 /* ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
|
|
3713
3714
|
}
|
|
3714
3715
|
}
|
|
3715
3716
|
else {
|
|
3716
3717
|
// check duplicate static names
|
|
3717
3718
|
if (staticSlotName) {
|
|
3718
3719
|
if (seenSlotNames.has(staticSlotName)) {
|
|
3719
|
-
context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
|
|
3720
|
+
context.onError(createCompilerError(38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
|
|
3720
3721
|
continue;
|
|
3721
3722
|
}
|
|
3722
3723
|
seenSlotNames.add(staticSlotName);
|
|
@@ -3746,7 +3747,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3746
3747
|
implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
|
|
3747
3748
|
// implicit default slot (mixed with named slots)
|
|
3748
3749
|
if (hasNamedDefaultSlot) {
|
|
3749
|
-
context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
|
|
3750
|
+
context.onError(createCompilerError(39 /* ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
|
|
3750
3751
|
}
|
|
3751
3752
|
else {
|
|
3752
3753
|
slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
|
|
@@ -3754,10 +3755,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3754
3755
|
}
|
|
3755
3756
|
}
|
|
3756
3757
|
const slotFlag = hasDynamicSlots
|
|
3757
|
-
? 2 /* DYNAMIC */
|
|
3758
|
+
? 2 /* SlotFlags.DYNAMIC */
|
|
3758
3759
|
: hasForwardedSlots(node.children)
|
|
3759
|
-
? 3 /* FORWARDED */
|
|
3760
|
-
: 1 /* STABLE */;
|
|
3760
|
+
? 3 /* SlotFlags.FORWARDED */
|
|
3761
|
+
: 1 /* SlotFlags.STABLE */;
|
|
3761
3762
|
let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`,
|
|
3762
3763
|
// 2 = compiled but dynamic = can skip normalization, but must run diff
|
|
3763
3764
|
// 1 = compiled and static = can skip normalization AND diff as optimized
|
|
@@ -3773,28 +3774,32 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3773
3774
|
hasDynamicSlots
|
|
3774
3775
|
};
|
|
3775
3776
|
}
|
|
3776
|
-
function buildDynamicSlot(name, fn) {
|
|
3777
|
-
|
|
3777
|
+
function buildDynamicSlot(name, fn, index) {
|
|
3778
|
+
const props = [
|
|
3778
3779
|
createObjectProperty(`name`, name),
|
|
3779
3780
|
createObjectProperty(`fn`, fn)
|
|
3780
|
-
]
|
|
3781
|
+
];
|
|
3782
|
+
if (index != null) {
|
|
3783
|
+
props.push(createObjectProperty(`key`, createSimpleExpression(String(index), true)));
|
|
3784
|
+
}
|
|
3785
|
+
return createObjectExpression(props);
|
|
3781
3786
|
}
|
|
3782
3787
|
function hasForwardedSlots(children) {
|
|
3783
3788
|
for (let i = 0; i < children.length; i++) {
|
|
3784
3789
|
const child = children[i];
|
|
3785
3790
|
switch (child.type) {
|
|
3786
|
-
case 1 /* ELEMENT */:
|
|
3787
|
-
if (child.tagType === 2 /* SLOT */ ||
|
|
3791
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
3792
|
+
if (child.tagType === 2 /* ElementTypes.SLOT */ ||
|
|
3788
3793
|
hasForwardedSlots(child.children)) {
|
|
3789
3794
|
return true;
|
|
3790
3795
|
}
|
|
3791
3796
|
break;
|
|
3792
|
-
case 9 /* IF */:
|
|
3797
|
+
case 9 /* NodeTypes.IF */:
|
|
3793
3798
|
if (hasForwardedSlots(child.branches))
|
|
3794
3799
|
return true;
|
|
3795
3800
|
break;
|
|
3796
|
-
case 10 /* IF_BRANCH */:
|
|
3797
|
-
case 11 /* FOR */:
|
|
3801
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
3802
|
+
case 11 /* NodeTypes.FOR */:
|
|
3798
3803
|
if (hasForwardedSlots(child.children))
|
|
3799
3804
|
return true;
|
|
3800
3805
|
break;
|
|
@@ -3803,9 +3808,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3803
3808
|
return false;
|
|
3804
3809
|
}
|
|
3805
3810
|
function isNonWhitespaceContent(node) {
|
|
3806
|
-
if (node.type !== 2 /* TEXT */ && node.type !== 12 /* TEXT_CALL */)
|
|
3811
|
+
if (node.type !== 2 /* NodeTypes.TEXT */ && node.type !== 12 /* NodeTypes.TEXT_CALL */)
|
|
3807
3812
|
return true;
|
|
3808
|
-
return node.type === 2 /* TEXT */
|
|
3813
|
+
return node.type === 2 /* NodeTypes.TEXT */
|
|
3809
3814
|
? !!node.content.trim()
|
|
3810
3815
|
: isNonWhitespaceContent(node.content);
|
|
3811
3816
|
}
|
|
@@ -3819,13 +3824,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3819
3824
|
// processed and merged.
|
|
3820
3825
|
return function postTransformElement() {
|
|
3821
3826
|
node = context.currentNode;
|
|
3822
|
-
if (!(node.type === 1 /* ELEMENT */ &&
|
|
3823
|
-
(node.tagType === 0 /* ELEMENT */ ||
|
|
3824
|
-
node.tagType === 1 /* COMPONENT */))) {
|
|
3827
|
+
if (!(node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
3828
|
+
(node.tagType === 0 /* ElementTypes.ELEMENT */ ||
|
|
3829
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */))) {
|
|
3825
3830
|
return;
|
|
3826
3831
|
}
|
|
3827
3832
|
const { tag, props } = node;
|
|
3828
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
3833
|
+
const isComponent = node.tagType === 1 /* ElementTypes.COMPONENT */;
|
|
3829
3834
|
// The goal of the transform is to create a codegenNode implementing the
|
|
3830
3835
|
// VNodeCall interface.
|
|
3831
3836
|
let vnodeTag = isComponent
|
|
@@ -3876,9 +3881,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3876
3881
|
// collected by a parent block.
|
|
3877
3882
|
shouldUseBlock = true;
|
|
3878
3883
|
// 2. Force keep-alive to always be updated, since it uses raw children.
|
|
3879
|
-
patchFlag |= 1024 /* DYNAMIC_SLOTS */;
|
|
3884
|
+
patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
|
|
3880
3885
|
if (node.children.length > 1) {
|
|
3881
|
-
context.onError(createCompilerError(45 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
|
|
3886
|
+
context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
|
|
3882
3887
|
start: node.children[0].loc.start,
|
|
3883
3888
|
end: node.children[node.children.length - 1].loc.end,
|
|
3884
3889
|
source: ''
|
|
@@ -3894,22 +3899,22 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3894
3899
|
const { slots, hasDynamicSlots } = buildSlots(node, context);
|
|
3895
3900
|
vnodeChildren = slots;
|
|
3896
3901
|
if (hasDynamicSlots) {
|
|
3897
|
-
patchFlag |= 1024 /* DYNAMIC_SLOTS */;
|
|
3902
|
+
patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
|
|
3898
3903
|
}
|
|
3899
3904
|
}
|
|
3900
3905
|
else if (node.children.length === 1 && vnodeTag !== TELEPORT) {
|
|
3901
3906
|
const child = node.children[0];
|
|
3902
3907
|
const type = child.type;
|
|
3903
3908
|
// check for dynamic text children
|
|
3904
|
-
const hasDynamicTextChild = type === 5 /* INTERPOLATION */ ||
|
|
3905
|
-
type === 8 /* COMPOUND_EXPRESSION */;
|
|
3909
|
+
const hasDynamicTextChild = type === 5 /* NodeTypes.INTERPOLATION */ ||
|
|
3910
|
+
type === 8 /* NodeTypes.COMPOUND_EXPRESSION */;
|
|
3906
3911
|
if (hasDynamicTextChild &&
|
|
3907
|
-
getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
|
|
3908
|
-
patchFlag |= 1 /* TEXT */;
|
|
3912
|
+
getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
3913
|
+
patchFlag |= 1 /* PatchFlags.TEXT */;
|
|
3909
3914
|
}
|
|
3910
3915
|
// pass directly if the only child is a text node
|
|
3911
3916
|
// (plain / interpolation / expression)
|
|
3912
|
-
if (hasDynamicTextChild || type === 2 /* TEXT */) {
|
|
3917
|
+
if (hasDynamicTextChild || type === 2 /* NodeTypes.TEXT */) {
|
|
3913
3918
|
vnodeChildren = child;
|
|
3914
3919
|
}
|
|
3915
3920
|
else {
|
|
@@ -3951,8 +3956,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3951
3956
|
const isProp = findProp(node, 'is');
|
|
3952
3957
|
if (isProp) {
|
|
3953
3958
|
if (isExplicitDynamic ||
|
|
3954
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))) {
|
|
3955
|
-
const exp = isProp.type === 6 /* ATTRIBUTE */
|
|
3959
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))) {
|
|
3960
|
+
const exp = isProp.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
3956
3961
|
? isProp.value && createSimpleExpression(isProp.value.content, true)
|
|
3957
3962
|
: isProp.exp;
|
|
3958
3963
|
if (exp) {
|
|
@@ -3961,7 +3966,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
3961
3966
|
]);
|
|
3962
3967
|
}
|
|
3963
3968
|
}
|
|
3964
|
-
else if (isProp.type === 6 /* ATTRIBUTE */ &&
|
|
3969
|
+
else if (isProp.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
3965
3970
|
isProp.value.content.startsWith('vue:')) {
|
|
3966
3971
|
// <button is="vue:xxx">
|
|
3967
3972
|
// if not <component>, only is value that starts with "vue:" will be
|
|
@@ -4025,9 +4030,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4025
4030
|
if (isEventHandler && isReservedProp(name)) {
|
|
4026
4031
|
hasVnodeHook = true;
|
|
4027
4032
|
}
|
|
4028
|
-
if (value.type === 20 /* JS_CACHE_EXPRESSION */ ||
|
|
4029
|
-
((value.type === 4 /* SIMPLE_EXPRESSION */ ||
|
|
4030
|
-
value.type === 8 /* COMPOUND_EXPRESSION */) &&
|
|
4033
|
+
if (value.type === 20 /* NodeTypes.JS_CACHE_EXPRESSION */ ||
|
|
4034
|
+
((value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
4035
|
+
value.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) &&
|
|
4031
4036
|
getConstantType(value, context) > 0)) {
|
|
4032
4037
|
// skip if the prop is a cached handler or has constant value
|
|
4033
4038
|
return;
|
|
@@ -4058,7 +4063,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4058
4063
|
for (let i = 0; i < props.length; i++) {
|
|
4059
4064
|
// static attribute
|
|
4060
4065
|
const prop = props[i];
|
|
4061
|
-
if (prop.type === 6 /* ATTRIBUTE */) {
|
|
4066
|
+
if (prop.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
4062
4067
|
const { loc, name, value } = prop;
|
|
4063
4068
|
let isStatic = true;
|
|
4064
4069
|
if (name === 'ref') {
|
|
@@ -4071,7 +4076,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4071
4076
|
if (name === 'is' &&
|
|
4072
4077
|
(isComponentTag(tag) ||
|
|
4073
4078
|
(value && value.content.startsWith('vue:')) ||
|
|
4074
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
|
|
4079
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context)))) {
|
|
4075
4080
|
continue;
|
|
4076
4081
|
}
|
|
4077
4082
|
properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
|
|
@@ -4084,7 +4089,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4084
4089
|
// skip v-slot - it is handled by its dedicated transform.
|
|
4085
4090
|
if (name === 'slot') {
|
|
4086
4091
|
if (!isComponent) {
|
|
4087
|
-
context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
|
|
4092
|
+
context.onError(createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, loc));
|
|
4088
4093
|
}
|
|
4089
4094
|
continue;
|
|
4090
4095
|
}
|
|
@@ -4097,7 +4102,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4097
4102
|
(isVBind &&
|
|
4098
4103
|
isStaticArgOf(arg, 'is') &&
|
|
4099
4104
|
(isComponentTag(tag) ||
|
|
4100
|
-
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context))))) {
|
|
4105
|
+
(isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT */, context))))) {
|
|
4101
4106
|
continue;
|
|
4102
4107
|
}
|
|
4103
4108
|
// skip v-on in SSR compilation
|
|
@@ -4128,9 +4133,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4128
4133
|
// 2.x v-bind object order compat
|
|
4129
4134
|
{
|
|
4130
4135
|
const hasOverridableKeys = mergeArgs.some(arg => {
|
|
4131
|
-
if (arg.type === 15 /* JS_OBJECT_EXPRESSION */) {
|
|
4136
|
+
if (arg.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
|
|
4132
4137
|
return arg.properties.some(({ key }) => {
|
|
4133
|
-
if (key.type !== 4 /* SIMPLE_EXPRESSION */ ||
|
|
4138
|
+
if (key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
|
|
4134
4139
|
!key.isStatic) {
|
|
4135
4140
|
return true;
|
|
4136
4141
|
}
|
|
@@ -4145,10 +4150,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4145
4150
|
}
|
|
4146
4151
|
});
|
|
4147
4152
|
if (hasOverridableKeys) {
|
|
4148
|
-
checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
|
|
4153
|
+
checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context, loc);
|
|
4149
4154
|
}
|
|
4150
4155
|
}
|
|
4151
|
-
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* COMPILER_V_BIND_OBJECT_ORDER */, context)) {
|
|
4156
|
+
if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
|
|
4152
4157
|
mergeArgs.unshift(exp);
|
|
4153
4158
|
continue;
|
|
4154
4159
|
}
|
|
@@ -4158,17 +4163,17 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4158
4163
|
else {
|
|
4159
4164
|
// v-on="obj" -> toHandlers(obj)
|
|
4160
4165
|
mergeArgs.push({
|
|
4161
|
-
type: 14 /* JS_CALL_EXPRESSION */,
|
|
4166
|
+
type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
|
|
4162
4167
|
loc,
|
|
4163
4168
|
callee: context.helper(TO_HANDLERS),
|
|
4164
|
-
arguments: [exp]
|
|
4169
|
+
arguments: isComponent ? [exp] : [exp, `true`]
|
|
4165
4170
|
});
|
|
4166
4171
|
}
|
|
4167
4172
|
}
|
|
4168
4173
|
else {
|
|
4169
4174
|
context.onError(createCompilerError(isVBind
|
|
4170
|
-
? 34 /* X_V_BIND_NO_EXPRESSION */
|
|
4171
|
-
: 35 /* X_V_ON_NO_EXPRESSION */, loc));
|
|
4175
|
+
? 34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */
|
|
4176
|
+
: 35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
|
|
4172
4177
|
}
|
|
4173
4178
|
continue;
|
|
4174
4179
|
}
|
|
@@ -4215,31 +4220,31 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4215
4220
|
}
|
|
4216
4221
|
// patchFlag analysis
|
|
4217
4222
|
if (hasDynamicKeys) {
|
|
4218
|
-
patchFlag |= 16 /* FULL_PROPS */;
|
|
4223
|
+
patchFlag |= 16 /* PatchFlags.FULL_PROPS */;
|
|
4219
4224
|
}
|
|
4220
4225
|
else {
|
|
4221
4226
|
if (hasClassBinding && !isComponent) {
|
|
4222
|
-
patchFlag |= 2 /* CLASS */;
|
|
4227
|
+
patchFlag |= 2 /* PatchFlags.CLASS */;
|
|
4223
4228
|
}
|
|
4224
4229
|
if (hasStyleBinding && !isComponent) {
|
|
4225
|
-
patchFlag |= 4 /* STYLE */;
|
|
4230
|
+
patchFlag |= 4 /* PatchFlags.STYLE */;
|
|
4226
4231
|
}
|
|
4227
4232
|
if (dynamicPropNames.length) {
|
|
4228
|
-
patchFlag |= 8 /* PROPS */;
|
|
4233
|
+
patchFlag |= 8 /* PatchFlags.PROPS */;
|
|
4229
4234
|
}
|
|
4230
4235
|
if (hasHydrationEventBinding) {
|
|
4231
|
-
patchFlag |= 32 /* HYDRATE_EVENTS */;
|
|
4236
|
+
patchFlag |= 32 /* PatchFlags.HYDRATE_EVENTS */;
|
|
4232
4237
|
}
|
|
4233
4238
|
}
|
|
4234
4239
|
if (!shouldUseBlock &&
|
|
4235
|
-
(patchFlag === 0 || patchFlag === 32 /* HYDRATE_EVENTS */) &&
|
|
4240
|
+
(patchFlag === 0 || patchFlag === 32 /* PatchFlags.HYDRATE_EVENTS */) &&
|
|
4236
4241
|
(hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
|
|
4237
|
-
patchFlag |= 512 /* NEED_PATCH */;
|
|
4242
|
+
patchFlag |= 512 /* PatchFlags.NEED_PATCH */;
|
|
4238
4243
|
}
|
|
4239
4244
|
// pre-normalize props, SSR is skipped for now
|
|
4240
4245
|
if (!context.inSSR && propsExpression) {
|
|
4241
4246
|
switch (propsExpression.type) {
|
|
4242
|
-
case 15 /* JS_OBJECT_EXPRESSION */:
|
|
4247
|
+
case 15 /* NodeTypes.JS_OBJECT_EXPRESSION */:
|
|
4243
4248
|
// means that there is no v-bind,
|
|
4244
4249
|
// but still need to deal with dynamic key binding
|
|
4245
4250
|
let classKeyIndex = -1;
|
|
@@ -4270,11 +4275,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4270
4275
|
// the static style is compiled into an object,
|
|
4271
4276
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4272
4277
|
(hasStyleBinding ||
|
|
4273
|
-
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4278
|
+
(styleProp.value.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
4274
4279
|
styleProp.value.content.trim()[0] === `[`) ||
|
|
4275
4280
|
// v-bind:style and style both exist,
|
|
4276
4281
|
// v-bind:style with static literal object
|
|
4277
|
-
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
4282
|
+
styleProp.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */)) {
|
|
4278
4283
|
styleProp.value = createCallExpression(context.helper(NORMALIZE_STYLE), [styleProp.value]);
|
|
4279
4284
|
}
|
|
4280
4285
|
}
|
|
@@ -4283,7 +4288,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4283
4288
|
propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
|
|
4284
4289
|
}
|
|
4285
4290
|
break;
|
|
4286
|
-
case 14 /* JS_CALL_EXPRESSION */:
|
|
4291
|
+
case 14 /* NodeTypes.JS_CALL_EXPRESSION */:
|
|
4287
4292
|
// mergeProps call, do nothing
|
|
4288
4293
|
break;
|
|
4289
4294
|
default:
|
|
@@ -4316,7 +4321,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4316
4321
|
for (let i = 0; i < properties.length; i++) {
|
|
4317
4322
|
const prop = properties[i];
|
|
4318
4323
|
// dynamic keys are always allowed
|
|
4319
|
-
if (prop.key.type === 8 /* COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
|
|
4324
|
+
if (prop.key.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */ || !prop.key.isStatic) {
|
|
4320
4325
|
deduped.push(prop);
|
|
4321
4326
|
continue;
|
|
4322
4327
|
}
|
|
@@ -4336,7 +4341,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4336
4341
|
return deduped;
|
|
4337
4342
|
}
|
|
4338
4343
|
function mergeAsArray(existing, incoming) {
|
|
4339
|
-
if (existing.value.type === 17 /* JS_ARRAY_EXPRESSION */) {
|
|
4344
|
+
if (existing.value.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
|
|
4340
4345
|
existing.value.elements.push(incoming.value);
|
|
4341
4346
|
}
|
|
4342
4347
|
else {
|
|
@@ -4425,7 +4430,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4425
4430
|
const nonNameProps = [];
|
|
4426
4431
|
for (let i = 0; i < node.props.length; i++) {
|
|
4427
4432
|
const p = node.props[i];
|
|
4428
|
-
if (p.type === 6 /* ATTRIBUTE */) {
|
|
4433
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
4429
4434
|
if (p.value) {
|
|
4430
4435
|
if (p.name === 'name') {
|
|
4431
4436
|
slotName = JSON.stringify(p.value.content);
|
|
@@ -4453,7 +4458,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4453
4458
|
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4454
4459
|
slotProps = props;
|
|
4455
4460
|
if (directives.length) {
|
|
4456
|
-
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
4461
|
+
context.onError(createCompilerError(36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
4457
4462
|
}
|
|
4458
4463
|
}
|
|
4459
4464
|
return {
|
|
@@ -4466,18 +4471,26 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4466
4471
|
const transformOn = (dir, node, context, augmentor) => {
|
|
4467
4472
|
const { loc, modifiers, arg } = dir;
|
|
4468
4473
|
if (!dir.exp && !modifiers.length) {
|
|
4469
|
-
context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
|
|
4474
|
+
context.onError(createCompilerError(35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */, loc));
|
|
4470
4475
|
}
|
|
4471
4476
|
let eventName;
|
|
4472
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
4477
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4473
4478
|
if (arg.isStatic) {
|
|
4474
4479
|
let rawName = arg.content;
|
|
4475
4480
|
// TODO deprecate @vnodeXXX usage
|
|
4476
4481
|
if (rawName.startsWith('vue:')) {
|
|
4477
4482
|
rawName = `vnode-${rawName.slice(4)}`;
|
|
4478
4483
|
}
|
|
4479
|
-
|
|
4480
|
-
|
|
4484
|
+
const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
|
|
4485
|
+
rawName.startsWith('vnode') ||
|
|
4486
|
+
!/[A-Z]/.test(rawName)
|
|
4487
|
+
? // for component and vnode lifecycle event listeners, auto convert
|
|
4488
|
+
// it to camelCase. See issue #2249
|
|
4489
|
+
toHandlerKey(camelize(rawName))
|
|
4490
|
+
// preserve case for plain element listeners that have uppercase
|
|
4491
|
+
// letters, as these may be custom elements' custom events
|
|
4492
|
+
: `on:${rawName}`;
|
|
4493
|
+
eventName = createSimpleExpression(eventString, true, arg.loc);
|
|
4481
4494
|
}
|
|
4482
4495
|
else {
|
|
4483
4496
|
// #2388
|
|
@@ -4544,7 +4557,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4544
4557
|
const transformBind = (dir, _node, context) => {
|
|
4545
4558
|
const { exp, modifiers, loc } = dir;
|
|
4546
4559
|
const arg = dir.arg;
|
|
4547
|
-
if (arg.type !== 4 /* SIMPLE_EXPRESSION */) {
|
|
4560
|
+
if (arg.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4548
4561
|
arg.children.unshift(`(`);
|
|
4549
4562
|
arg.children.push(`) || ""`);
|
|
4550
4563
|
}
|
|
@@ -4553,7 +4566,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4553
4566
|
}
|
|
4554
4567
|
// .sync is replaced by v-model:arg
|
|
4555
4568
|
if (modifiers.includes('camel')) {
|
|
4556
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
4569
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4557
4570
|
if (arg.isStatic) {
|
|
4558
4571
|
arg.content = camelize(arg.content);
|
|
4559
4572
|
}
|
|
@@ -4575,8 +4588,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4575
4588
|
}
|
|
4576
4589
|
}
|
|
4577
4590
|
if (!exp ||
|
|
4578
|
-
(exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
|
|
4579
|
-
context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
|
|
4591
|
+
(exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ && !exp.content.trim())) {
|
|
4592
|
+
context.onError(createCompilerError(34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */, loc));
|
|
4580
4593
|
return {
|
|
4581
4594
|
props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
|
|
4582
4595
|
};
|
|
@@ -4586,7 +4599,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4586
4599
|
};
|
|
4587
4600
|
};
|
|
4588
4601
|
const injectPrefix = (arg, prefix) => {
|
|
4589
|
-
if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
4602
|
+
if (arg.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4590
4603
|
if (arg.isStatic) {
|
|
4591
4604
|
arg.content = prefix + arg.content;
|
|
4592
4605
|
}
|
|
@@ -4603,10 +4616,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4603
4616
|
// Merge adjacent text nodes and expressions into a single expression
|
|
4604
4617
|
// e.g. <div>abc {{ d }} {{ e }}</div> should have a single expression node as child.
|
|
4605
4618
|
const transformText = (node, context) => {
|
|
4606
|
-
if (node.type === 0 /* ROOT */ ||
|
|
4607
|
-
node.type === 1 /* ELEMENT */ ||
|
|
4608
|
-
node.type === 11 /* FOR */ ||
|
|
4609
|
-
node.type === 10 /* IF_BRANCH */) {
|
|
4619
|
+
if (node.type === 0 /* NodeTypes.ROOT */ ||
|
|
4620
|
+
node.type === 1 /* NodeTypes.ELEMENT */ ||
|
|
4621
|
+
node.type === 11 /* NodeTypes.FOR */ ||
|
|
4622
|
+
node.type === 10 /* NodeTypes.IF_BRANCH */) {
|
|
4610
4623
|
// perform the transform on node exit so that all expressions have already
|
|
4611
4624
|
// been processed.
|
|
4612
4625
|
return () => {
|
|
@@ -4641,15 +4654,15 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4641
4654
|
// setting textContent of the element.
|
|
4642
4655
|
// for component root it's always normalized anyway.
|
|
4643
4656
|
(children.length === 1 &&
|
|
4644
|
-
(node.type === 0 /* ROOT */ ||
|
|
4645
|
-
(node.type === 1 /* ELEMENT */ &&
|
|
4646
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
4657
|
+
(node.type === 0 /* NodeTypes.ROOT */ ||
|
|
4658
|
+
(node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
4659
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
4647
4660
|
// #3756
|
|
4648
4661
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
4649
4662
|
// we need to avoid setting textContent of the element at runtime
|
|
4650
4663
|
// to avoid accidentally overwriting the DOM elements added
|
|
4651
4664
|
// by the user through custom directives.
|
|
4652
|
-
!node.props.find(p => p.type === 7 /* DIRECTIVE */ &&
|
|
4665
|
+
!node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
4653
4666
|
!context.directiveTransforms[p.name]) &&
|
|
4654
4667
|
// in compat mode, <template> tags with no special directives
|
|
4655
4668
|
// will be rendered as a fragment so its children must be
|
|
@@ -4661,21 +4674,21 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4661
4674
|
// runtime normalization.
|
|
4662
4675
|
for (let i = 0; i < children.length; i++) {
|
|
4663
4676
|
const child = children[i];
|
|
4664
|
-
if (isText(child) || child.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
4677
|
+
if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
4665
4678
|
const callArgs = [];
|
|
4666
4679
|
// createTextVNode defaults to single whitespace, so if it is a
|
|
4667
4680
|
// single space the code could be an empty call to save bytes.
|
|
4668
|
-
if (child.type !== 2 /* TEXT */ || child.content !== ' ') {
|
|
4681
|
+
if (child.type !== 2 /* NodeTypes.TEXT */ || child.content !== ' ') {
|
|
4669
4682
|
callArgs.push(child);
|
|
4670
4683
|
}
|
|
4671
4684
|
// mark dynamic text with flag so it gets patched inside a block
|
|
4672
4685
|
if (!context.ssr &&
|
|
4673
|
-
getConstantType(child, context) === 0 /* NOT_CONSTANT */) {
|
|
4674
|
-
callArgs.push(1 /* TEXT */ +
|
|
4675
|
-
(` /* ${PatchFlagNames[1 /* TEXT */]} */` ));
|
|
4686
|
+
getConstantType(child, context) === 0 /* ConstantTypes.NOT_CONSTANT */) {
|
|
4687
|
+
callArgs.push(1 /* PatchFlags.TEXT */ +
|
|
4688
|
+
(` /* ${PatchFlagNames[1 /* PatchFlags.TEXT */]} */` ));
|
|
4676
4689
|
}
|
|
4677
4690
|
children[i] = {
|
|
4678
|
-
type: 12 /* TEXT_CALL */,
|
|
4691
|
+
type: 12 /* NodeTypes.TEXT_CALL */,
|
|
4679
4692
|
content: child,
|
|
4680
4693
|
loc: child.loc,
|
|
4681
4694
|
codegenNode: createCallExpression(context.helper(CREATE_TEXT), callArgs)
|
|
@@ -4688,7 +4701,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4688
4701
|
|
|
4689
4702
|
const seen = new WeakSet();
|
|
4690
4703
|
const transformOnce = (node, context) => {
|
|
4691
|
-
if (node.type === 1 /* ELEMENT */ && findDir(node, 'once', true)) {
|
|
4704
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
|
|
4692
4705
|
if (seen.has(node) || context.inVOnce) {
|
|
4693
4706
|
return;
|
|
4694
4707
|
}
|
|
@@ -4708,18 +4721,18 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4708
4721
|
const transformModel = (dir, node, context) => {
|
|
4709
4722
|
const { exp, arg } = dir;
|
|
4710
4723
|
if (!exp) {
|
|
4711
|
-
context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
|
|
4724
|
+
context.onError(createCompilerError(41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */, dir.loc));
|
|
4712
4725
|
return createTransformProps();
|
|
4713
4726
|
}
|
|
4714
4727
|
const rawExp = exp.loc.source;
|
|
4715
|
-
const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
|
|
4728
|
+
const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
|
|
4716
4729
|
// im SFC <script setup> inline mode, the exp may have been transformed into
|
|
4717
4730
|
// _unref(exp)
|
|
4718
4731
|
context.bindingMetadata[rawExp];
|
|
4719
|
-
const maybeRef = !true /* SETUP_CONST */;
|
|
4732
|
+
const maybeRef = !true /* BindingTypes.SETUP_CONST */;
|
|
4720
4733
|
if (!expString.trim() ||
|
|
4721
4734
|
(!isMemberExpression(expString) && !maybeRef)) {
|
|
4722
|
-
context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
|
4735
|
+
context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
|
|
4723
4736
|
return createTransformProps();
|
|
4724
4737
|
}
|
|
4725
4738
|
const propName = arg ? arg : createSimpleExpression('modelValue', true);
|
|
@@ -4744,7 +4757,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4744
4757
|
createObjectProperty(eventName, assignmentExp)
|
|
4745
4758
|
];
|
|
4746
4759
|
// modelModifiers: { foo: true, "bar-baz": true }
|
|
4747
|
-
if (dir.modifiers.length && node.tagType === 1 /* COMPONENT */) {
|
|
4760
|
+
if (dir.modifiers.length && node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
4748
4761
|
const modifiers = dir.modifiers
|
|
4749
4762
|
.map(m => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`)
|
|
4750
4763
|
.join(`, `);
|
|
@@ -4753,7 +4766,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4753
4766
|
? `${arg.content}Modifiers`
|
|
4754
4767
|
: createCompoundExpression([arg, ' + "Modifiers"'])
|
|
4755
4768
|
: `modelModifiers`;
|
|
4756
|
-
props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* CAN_HOIST */)));
|
|
4769
|
+
props.push(createObjectProperty(modifiersKey, createSimpleExpression(`{ ${modifiers} }`, false, dir.loc, 2 /* ConstantTypes.CAN_HOIST */)));
|
|
4757
4770
|
}
|
|
4758
4771
|
return createTransformProps(props);
|
|
4759
4772
|
};
|
|
@@ -4763,17 +4776,17 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4763
4776
|
|
|
4764
4777
|
const validDivisionCharRE = /[\w).+\-_$\]]/;
|
|
4765
4778
|
const transformFilter = (node, context) => {
|
|
4766
|
-
if (!isCompatEnabled("COMPILER_FILTER" /* COMPILER_FILTERS */, context)) {
|
|
4779
|
+
if (!isCompatEnabled("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context)) {
|
|
4767
4780
|
return;
|
|
4768
4781
|
}
|
|
4769
|
-
if (node.type === 5 /* INTERPOLATION */) {
|
|
4782
|
+
if (node.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
4770
4783
|
// filter rewrite is applied before expression transform so only
|
|
4771
4784
|
// simple expressions are possible at this stage
|
|
4772
4785
|
rewriteFilter(node.content, context);
|
|
4773
4786
|
}
|
|
4774
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
4787
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
4775
4788
|
node.props.forEach((prop) => {
|
|
4776
|
-
if (prop.type === 7 /* DIRECTIVE */ &&
|
|
4789
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */ &&
|
|
4777
4790
|
prop.name !== 'for' &&
|
|
4778
4791
|
prop.exp) {
|
|
4779
4792
|
rewriteFilter(prop.exp, context);
|
|
@@ -4782,7 +4795,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4782
4795
|
}
|
|
4783
4796
|
};
|
|
4784
4797
|
function rewriteFilter(node, context) {
|
|
4785
|
-
if (node.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
4798
|
+
if (node.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4786
4799
|
parseFilter(node, context);
|
|
4787
4800
|
}
|
|
4788
4801
|
else {
|
|
@@ -4790,13 +4803,13 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4790
4803
|
const child = node.children[i];
|
|
4791
4804
|
if (typeof child !== 'object')
|
|
4792
4805
|
continue;
|
|
4793
|
-
if (child.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
4806
|
+
if (child.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
|
|
4794
4807
|
parseFilter(child, context);
|
|
4795
4808
|
}
|
|
4796
|
-
else if (child.type === 8 /* COMPOUND_EXPRESSION */) {
|
|
4809
|
+
else if (child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
|
|
4797
4810
|
rewriteFilter(node, context);
|
|
4798
4811
|
}
|
|
4799
|
-
else if (child.type === 5 /* INTERPOLATION */) {
|
|
4812
|
+
else if (child.type === 5 /* NodeTypes.INTERPOLATION */) {
|
|
4800
4813
|
rewriteFilter(child.content, context);
|
|
4801
4814
|
}
|
|
4802
4815
|
}
|
|
@@ -4904,7 +4917,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4904
4917
|
lastFilterIndex = i + 1;
|
|
4905
4918
|
}
|
|
4906
4919
|
if (filters.length) {
|
|
4907
|
-
warnDeprecation("COMPILER_FILTER" /* COMPILER_FILTERS */, context, node.loc);
|
|
4920
|
+
warnDeprecation("COMPILER_FILTER" /* CompilerDeprecationTypes.COMPILER_FILTERS */, context, node.loc);
|
|
4908
4921
|
for (i = 0; i < filters.length; i++) {
|
|
4909
4922
|
expression = wrapFilter(expression, filters[i], context);
|
|
4910
4923
|
}
|
|
@@ -4928,7 +4941,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4928
4941
|
|
|
4929
4942
|
const seen$1 = new WeakSet();
|
|
4930
4943
|
const transformMemo = (node, context) => {
|
|
4931
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
4944
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
4932
4945
|
const dir = findDir(node, 'memo');
|
|
4933
4946
|
if (!dir || seen$1.has(node)) {
|
|
4934
4947
|
return;
|
|
@@ -4937,9 +4950,9 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4937
4950
|
return () => {
|
|
4938
4951
|
const codegenNode = node.codegenNode ||
|
|
4939
4952
|
context.currentNode.codegenNode;
|
|
4940
|
-
if (codegenNode && codegenNode.type === 13 /* VNODE_CALL */) {
|
|
4953
|
+
if (codegenNode && codegenNode.type === 13 /* NodeTypes.VNODE_CALL */) {
|
|
4941
4954
|
// non-component sub tree should be turned into a block
|
|
4942
|
-
if (node.tagType !== 1 /* COMPONENT */) {
|
|
4955
|
+
if (node.tagType !== 1 /* ElementTypes.COMPONENT */) {
|
|
4943
4956
|
makeBlock(codegenNode, context);
|
|
4944
4957
|
}
|
|
4945
4958
|
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
@@ -4983,18 +4996,18 @@ var VueCompilerDOM = (function (exports) {
|
|
|
4983
4996
|
/* istanbul ignore if */
|
|
4984
4997
|
{
|
|
4985
4998
|
if (options.prefixIdentifiers === true) {
|
|
4986
|
-
onError(createCompilerError(46 /* X_PREFIX_ID_NOT_SUPPORTED */));
|
|
4999
|
+
onError(createCompilerError(46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */));
|
|
4987
5000
|
}
|
|
4988
5001
|
else if (isModuleMode) {
|
|
4989
|
-
onError(createCompilerError(47 /* X_MODULE_MODE_NOT_SUPPORTED */));
|
|
5002
|
+
onError(createCompilerError(47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */));
|
|
4990
5003
|
}
|
|
4991
5004
|
}
|
|
4992
5005
|
const prefixIdentifiers = !true ;
|
|
4993
5006
|
if (options.cacheHandlers) {
|
|
4994
|
-
onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
|
|
5007
|
+
onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
|
|
4995
5008
|
}
|
|
4996
5009
|
if (options.scopeId && !isModuleMode) {
|
|
4997
|
-
onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
|
|
5010
|
+
onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
|
|
4998
5011
|
}
|
|
4999
5012
|
const ast = isString(template) ? baseParse(template, options) : template;
|
|
5000
5013
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
@@ -5069,54 +5082,54 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5069
5082
|
},
|
|
5070
5083
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
5071
5084
|
getNamespace(tag, parent) {
|
|
5072
|
-
let ns = parent ? parent.ns : 0 /* HTML */;
|
|
5073
|
-
if (parent && ns === 2 /* MATH_ML */) {
|
|
5085
|
+
let ns = parent ? parent.ns : 0 /* DOMNamespaces.HTML */;
|
|
5086
|
+
if (parent && ns === 2 /* DOMNamespaces.MATH_ML */) {
|
|
5074
5087
|
if (parent.tag === 'annotation-xml') {
|
|
5075
5088
|
if (tag === 'svg') {
|
|
5076
|
-
return 1 /* SVG */;
|
|
5089
|
+
return 1 /* DOMNamespaces.SVG */;
|
|
5077
5090
|
}
|
|
5078
|
-
if (parent.props.some(a => a.type === 6 /* ATTRIBUTE */ &&
|
|
5091
|
+
if (parent.props.some(a => a.type === 6 /* NodeTypes.ATTRIBUTE */ &&
|
|
5079
5092
|
a.name === 'encoding' &&
|
|
5080
5093
|
a.value != null &&
|
|
5081
5094
|
(a.value.content === 'text/html' ||
|
|
5082
5095
|
a.value.content === 'application/xhtml+xml'))) {
|
|
5083
|
-
ns = 0 /* HTML */;
|
|
5096
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
5084
5097
|
}
|
|
5085
5098
|
}
|
|
5086
5099
|
else if (/^m(?:[ions]|text)$/.test(parent.tag) &&
|
|
5087
5100
|
tag !== 'mglyph' &&
|
|
5088
5101
|
tag !== 'malignmark') {
|
|
5089
|
-
ns = 0 /* HTML */;
|
|
5102
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
5090
5103
|
}
|
|
5091
5104
|
}
|
|
5092
|
-
else if (parent && ns === 1 /* SVG */) {
|
|
5105
|
+
else if (parent && ns === 1 /* DOMNamespaces.SVG */) {
|
|
5093
5106
|
if (parent.tag === 'foreignObject' ||
|
|
5094
5107
|
parent.tag === 'desc' ||
|
|
5095
5108
|
parent.tag === 'title') {
|
|
5096
|
-
ns = 0 /* HTML */;
|
|
5109
|
+
ns = 0 /* DOMNamespaces.HTML */;
|
|
5097
5110
|
}
|
|
5098
5111
|
}
|
|
5099
|
-
if (ns === 0 /* HTML */) {
|
|
5112
|
+
if (ns === 0 /* DOMNamespaces.HTML */) {
|
|
5100
5113
|
if (tag === 'svg') {
|
|
5101
|
-
return 1 /* SVG */;
|
|
5114
|
+
return 1 /* DOMNamespaces.SVG */;
|
|
5102
5115
|
}
|
|
5103
5116
|
if (tag === 'math') {
|
|
5104
|
-
return 2 /* MATH_ML */;
|
|
5117
|
+
return 2 /* DOMNamespaces.MATH_ML */;
|
|
5105
5118
|
}
|
|
5106
5119
|
}
|
|
5107
5120
|
return ns;
|
|
5108
5121
|
},
|
|
5109
5122
|
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
|
5110
5123
|
getTextMode({ tag, ns }) {
|
|
5111
|
-
if (ns === 0 /* HTML */) {
|
|
5124
|
+
if (ns === 0 /* DOMNamespaces.HTML */) {
|
|
5112
5125
|
if (tag === 'textarea' || tag === 'title') {
|
|
5113
|
-
return 1 /* RCDATA */;
|
|
5126
|
+
return 1 /* TextModes.RCDATA */;
|
|
5114
5127
|
}
|
|
5115
5128
|
if (isRawTextContainer(tag)) {
|
|
5116
|
-
return 2 /* RAWTEXT */;
|
|
5129
|
+
return 2 /* TextModes.RAWTEXT */;
|
|
5117
5130
|
}
|
|
5118
5131
|
}
|
|
5119
|
-
return 0 /* DATA */;
|
|
5132
|
+
return 0 /* TextModes.DATA */;
|
|
5120
5133
|
}
|
|
5121
5134
|
};
|
|
5122
5135
|
|
|
@@ -5127,12 +5140,12 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5127
5140
|
// It is then processed by `transformElement` and included in the generated
|
|
5128
5141
|
// props.
|
|
5129
5142
|
const transformStyle = node => {
|
|
5130
|
-
if (node.type === 1 /* ELEMENT */) {
|
|
5143
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */) {
|
|
5131
5144
|
node.props.forEach((p, i) => {
|
|
5132
|
-
if (p.type === 6 /* ATTRIBUTE */ && p.name === 'style' && p.value) {
|
|
5145
|
+
if (p.type === 6 /* NodeTypes.ATTRIBUTE */ && p.name === 'style' && p.value) {
|
|
5133
5146
|
// replace p with an expression node
|
|
5134
5147
|
node.props[i] = {
|
|
5135
|
-
type: 7 /* DIRECTIVE */,
|
|
5148
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
5136
5149
|
name: `bind`,
|
|
5137
5150
|
arg: createSimpleExpression(`style`, true, p.loc),
|
|
5138
5151
|
exp: parseInlineCSS(p.value.content, p.loc),
|
|
@@ -5145,33 +5158,33 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5145
5158
|
};
|
|
5146
5159
|
const parseInlineCSS = (cssText, loc) => {
|
|
5147
5160
|
const normalized = parseStringStyle(cssText);
|
|
5148
|
-
return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
|
|
5161
|
+
return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* ConstantTypes.CAN_STRINGIFY */);
|
|
5149
5162
|
};
|
|
5150
5163
|
|
|
5151
5164
|
function createDOMCompilerError(code, loc) {
|
|
5152
5165
|
return createCompilerError(code, loc, DOMErrorMessages );
|
|
5153
5166
|
}
|
|
5154
5167
|
const DOMErrorMessages = {
|
|
5155
|
-
[50 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
|
|
5156
|
-
[51 /* X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
|
|
5157
|
-
[52 /* X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
|
|
5158
|
-
[53 /* X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
|
|
5159
|
-
[54 /* X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
5160
|
-
[55 /* X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
|
|
5161
|
-
[56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
5162
|
-
[57 /* X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
5163
|
-
[58 /* X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
|
|
5164
|
-
[59 /* X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
|
|
5165
|
-
[60 /* X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
|
5168
|
+
[50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
|
|
5169
|
+
[51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
|
|
5170
|
+
[52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
|
|
5171
|
+
[53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
|
|
5172
|
+
[54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
|
5173
|
+
[55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
|
|
5174
|
+
[56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
|
5175
|
+
[57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
|
5176
|
+
[58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
|
|
5177
|
+
[59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
|
|
5178
|
+
[60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
|
5166
5179
|
};
|
|
5167
5180
|
|
|
5168
5181
|
const transformVHtml = (dir, node, context) => {
|
|
5169
5182
|
const { exp, loc } = dir;
|
|
5170
5183
|
if (!exp) {
|
|
5171
|
-
context.onError(createDOMCompilerError(50 /* X_V_HTML_NO_EXPRESSION */, loc));
|
|
5184
|
+
context.onError(createDOMCompilerError(50 /* DOMErrorCodes.X_V_HTML_NO_EXPRESSION */, loc));
|
|
5172
5185
|
}
|
|
5173
5186
|
if (node.children.length) {
|
|
5174
|
-
context.onError(createDOMCompilerError(51 /* X_V_HTML_WITH_CHILDREN */, loc));
|
|
5187
|
+
context.onError(createDOMCompilerError(51 /* DOMErrorCodes.X_V_HTML_WITH_CHILDREN */, loc));
|
|
5175
5188
|
node.children.length = 0;
|
|
5176
5189
|
}
|
|
5177
5190
|
return {
|
|
@@ -5184,10 +5197,10 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5184
5197
|
const transformVText = (dir, node, context) => {
|
|
5185
5198
|
const { exp, loc } = dir;
|
|
5186
5199
|
if (!exp) {
|
|
5187
|
-
context.onError(createDOMCompilerError(52 /* X_V_TEXT_NO_EXPRESSION */, loc));
|
|
5200
|
+
context.onError(createDOMCompilerError(52 /* DOMErrorCodes.X_V_TEXT_NO_EXPRESSION */, loc));
|
|
5188
5201
|
}
|
|
5189
5202
|
if (node.children.length) {
|
|
5190
|
-
context.onError(createDOMCompilerError(53 /* X_V_TEXT_WITH_CHILDREN */, loc));
|
|
5203
|
+
context.onError(createDOMCompilerError(53 /* DOMErrorCodes.X_V_TEXT_WITH_CHILDREN */, loc));
|
|
5191
5204
|
node.children.length = 0;
|
|
5192
5205
|
}
|
|
5193
5206
|
return {
|
|
@@ -5204,16 +5217,16 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5204
5217
|
const transformModel$1 = (dir, node, context) => {
|
|
5205
5218
|
const baseResult = transformModel(dir, node, context);
|
|
5206
5219
|
// base transform has errors OR component v-model (only need props)
|
|
5207
|
-
if (!baseResult.props.length || node.tagType === 1 /* COMPONENT */) {
|
|
5220
|
+
if (!baseResult.props.length || node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
5208
5221
|
return baseResult;
|
|
5209
5222
|
}
|
|
5210
5223
|
if (dir.arg) {
|
|
5211
|
-
context.onError(createDOMCompilerError(55 /* X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
|
|
5224
|
+
context.onError(createDOMCompilerError(55 /* DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
|
|
5212
5225
|
}
|
|
5213
5226
|
function checkDuplicatedValue() {
|
|
5214
5227
|
const value = findProp(node, 'value');
|
|
5215
5228
|
if (value) {
|
|
5216
|
-
context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
5229
|
+
context.onError(createDOMCompilerError(57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
5217
5230
|
}
|
|
5218
5231
|
}
|
|
5219
5232
|
const { tag } = node;
|
|
@@ -5227,7 +5240,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5227
5240
|
if (tag === 'input' || isCustomElement) {
|
|
5228
5241
|
const type = findProp(node, `type`);
|
|
5229
5242
|
if (type) {
|
|
5230
|
-
if (type.type === 7 /* DIRECTIVE */) {
|
|
5243
|
+
if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
5231
5244
|
// :type="foo"
|
|
5232
5245
|
directiveToUse = V_MODEL_DYNAMIC;
|
|
5233
5246
|
}
|
|
@@ -5241,7 +5254,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5241
5254
|
break;
|
|
5242
5255
|
case 'file':
|
|
5243
5256
|
isInvalidType = true;
|
|
5244
|
-
context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
5257
|
+
context.onError(createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
5245
5258
|
break;
|
|
5246
5259
|
default:
|
|
5247
5260
|
// text type
|
|
@@ -5275,11 +5288,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5275
5288
|
}
|
|
5276
5289
|
}
|
|
5277
5290
|
else {
|
|
5278
|
-
context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
5291
|
+
context.onError(createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
5279
5292
|
}
|
|
5280
5293
|
// native vmodel doesn't need the `modelValue` props since they are also
|
|
5281
5294
|
// passed to the runtime as `binding.value`. removing it reduces code size.
|
|
5282
|
-
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
5295
|
+
baseResult.props = baseResult.props.filter(p => !(p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
|
|
5283
5296
|
p.key.content === 'modelValue'));
|
|
5284
5297
|
return baseResult;
|
|
5285
5298
|
};
|
|
@@ -5302,7 +5315,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5302
5315
|
for (let i = 0; i < modifiers.length; i++) {
|
|
5303
5316
|
const modifier = modifiers[i];
|
|
5304
5317
|
if (modifier === 'native' &&
|
|
5305
|
-
checkCompatEnabled("COMPILER_V_ON_NATIVE" /* COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
5318
|
+
checkCompatEnabled("COMPILER_V_ON_NATIVE" /* CompilerDeprecationTypes.COMPILER_V_ON_NATIVE */, context, loc)) {
|
|
5306
5319
|
eventOptionModifiers.push(modifier);
|
|
5307
5320
|
}
|
|
5308
5321
|
else if (isEventOptionModifier(modifier)) {
|
|
@@ -5346,7 +5359,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5346
5359
|
const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === 'onclick';
|
|
5347
5360
|
return isStaticClick
|
|
5348
5361
|
? createSimpleExpression(event, true)
|
|
5349
|
-
: key.type !== 4 /* SIMPLE_EXPRESSION */
|
|
5362
|
+
: key.type !== 4 /* NodeTypes.SIMPLE_EXPRESSION */
|
|
5350
5363
|
? createCompoundExpression([
|
|
5351
5364
|
`(`,
|
|
5352
5365
|
key,
|
|
@@ -5399,7 +5412,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5399
5412
|
const transformShow = (dir, node, context) => {
|
|
5400
5413
|
const { exp, loc } = dir;
|
|
5401
5414
|
if (!exp) {
|
|
5402
|
-
context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */, loc));
|
|
5415
|
+
context.onError(createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */, loc));
|
|
5403
5416
|
}
|
|
5404
5417
|
return {
|
|
5405
5418
|
props: [],
|
|
@@ -5408,8 +5421,8 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5408
5421
|
};
|
|
5409
5422
|
|
|
5410
5423
|
const transformTransition = (node, context) => {
|
|
5411
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
5412
|
-
node.tagType === 1 /* COMPONENT */) {
|
|
5424
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
5425
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */) {
|
|
5413
5426
|
const component = context.isBuiltInComponent(node.tag);
|
|
5414
5427
|
if (component === TRANSITION) {
|
|
5415
5428
|
return () => {
|
|
@@ -5418,7 +5431,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5418
5431
|
}
|
|
5419
5432
|
// warn multiple transition children
|
|
5420
5433
|
if (hasMultipleChildren(node)) {
|
|
5421
|
-
context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
|
|
5434
|
+
context.onError(createDOMCompilerError(59 /* DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN */, {
|
|
5422
5435
|
start: node.children[0].loc.start,
|
|
5423
5436
|
end: node.children[node.children.length - 1].loc.end,
|
|
5424
5437
|
source: ''
|
|
@@ -5427,11 +5440,11 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5427
5440
|
// check if it's s single child w/ v-show
|
|
5428
5441
|
// if yes, inject "persisted: true" to the transition props
|
|
5429
5442
|
const child = node.children[0];
|
|
5430
|
-
if (child.type === 1 /* ELEMENT */) {
|
|
5443
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */) {
|
|
5431
5444
|
for (const p of child.props) {
|
|
5432
|
-
if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
|
|
5445
|
+
if (p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'show') {
|
|
5433
5446
|
node.props.push({
|
|
5434
|
-
type: 6 /* ATTRIBUTE */,
|
|
5447
|
+
type: 6 /* NodeTypes.ATTRIBUTE */,
|
|
5435
5448
|
name: 'persisted',
|
|
5436
5449
|
value: undefined,
|
|
5437
5450
|
loc: node.loc
|
|
@@ -5445,19 +5458,19 @@ var VueCompilerDOM = (function (exports) {
|
|
|
5445
5458
|
};
|
|
5446
5459
|
function hasMultipleChildren(node) {
|
|
5447
5460
|
// #1352 filter out potential comment nodes.
|
|
5448
|
-
const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
|
|
5449
|
-
!(c.type === 2 /* TEXT */ && !c.content.trim())));
|
|
5461
|
+
const children = (node.children = node.children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */ &&
|
|
5462
|
+
!(c.type === 2 /* NodeTypes.TEXT */ && !c.content.trim())));
|
|
5450
5463
|
const child = children[0];
|
|
5451
5464
|
return (children.length !== 1 ||
|
|
5452
|
-
child.type === 11 /* FOR */ ||
|
|
5453
|
-
(child.type === 9 /* IF */ && child.branches.some(hasMultipleChildren)));
|
|
5465
|
+
child.type === 11 /* NodeTypes.FOR */ ||
|
|
5466
|
+
(child.type === 9 /* NodeTypes.IF */ && child.branches.some(hasMultipleChildren)));
|
|
5454
5467
|
}
|
|
5455
5468
|
|
|
5456
5469
|
const ignoreSideEffectTags = (node, context) => {
|
|
5457
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
5458
|
-
node.tagType === 0 /* ELEMENT */ &&
|
|
5470
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
5471
|
+
node.tagType === 0 /* ElementTypes.ELEMENT */ &&
|
|
5459
5472
|
(node.tag === 'script' || node.tag === 'style')) {
|
|
5460
|
-
context.onError(createDOMCompilerError(60 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
5473
|
+
context.onError(createDOMCompilerError(60 /* DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
|
|
5461
5474
|
context.removeNode();
|
|
5462
5475
|
}
|
|
5463
5476
|
};
|