@vue/compiler-core 3.3.9 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-core.cjs.js +1775 -992
- package/dist/compiler-core.cjs.prod.js +1740 -952
- package/dist/compiler-core.d.ts +99 -89
- package/dist/compiler-core.esm-bundler.js +1674 -977
- package/package.json +3 -2
|
@@ -1,83 +1,6 @@
|
|
|
1
|
-
import { isString,
|
|
1
|
+
import { isString, NOOP, isObject, NO, extend, isSymbol, isArray, capitalize, camelize, EMPTY_OBJ, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
|
|
2
2
|
export { generateCodeFrame } from '@vue/shared';
|
|
3
3
|
|
|
4
|
-
function defaultOnError(error) {
|
|
5
|
-
throw error;
|
|
6
|
-
}
|
|
7
|
-
function defaultOnWarn(msg) {
|
|
8
|
-
!!(process.env.NODE_ENV !== "production") && console.warn(`[Vue warn] ${msg.message}`);
|
|
9
|
-
}
|
|
10
|
-
function createCompilerError(code, loc, messages, additionalMessage) {
|
|
11
|
-
const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
|
|
12
|
-
const error = new SyntaxError(String(msg));
|
|
13
|
-
error.code = code;
|
|
14
|
-
error.loc = loc;
|
|
15
|
-
return error;
|
|
16
|
-
}
|
|
17
|
-
const errorMessages = {
|
|
18
|
-
// parse errors
|
|
19
|
-
[0]: "Illegal comment.",
|
|
20
|
-
[1]: "CDATA section is allowed only in XML context.",
|
|
21
|
-
[2]: "Duplicate attribute.",
|
|
22
|
-
[3]: "End tag cannot have attributes.",
|
|
23
|
-
[4]: "Illegal '/' in tags.",
|
|
24
|
-
[5]: "Unexpected EOF in tag.",
|
|
25
|
-
[6]: "Unexpected EOF in CDATA section.",
|
|
26
|
-
[7]: "Unexpected EOF in comment.",
|
|
27
|
-
[8]: "Unexpected EOF in script.",
|
|
28
|
-
[9]: "Unexpected EOF in tag.",
|
|
29
|
-
[10]: "Incorrectly closed comment.",
|
|
30
|
-
[11]: "Incorrectly opened comment.",
|
|
31
|
-
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
32
|
-
[13]: "Attribute value was expected.",
|
|
33
|
-
[14]: "End tag name was expected.",
|
|
34
|
-
[15]: "Whitespace was expected.",
|
|
35
|
-
[16]: "Unexpected '<!--' in comment.",
|
|
36
|
-
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
37
|
-
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
38
|
-
[19]: "Attribute name cannot start with '='.",
|
|
39
|
-
[21]: "'<?' is allowed only in XML context.",
|
|
40
|
-
[20]: `Unexpected null character.`,
|
|
41
|
-
[22]: "Illegal '/' in tags.",
|
|
42
|
-
// Vue-specific parse errors
|
|
43
|
-
[23]: "Invalid end tag.",
|
|
44
|
-
[24]: "Element is missing end tag.",
|
|
45
|
-
[25]: "Interpolation end sign was not found.",
|
|
46
|
-
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
47
|
-
[26]: "Legal directive name was expected.",
|
|
48
|
-
// transform errors
|
|
49
|
-
[28]: `v-if/v-else-if is missing expression.`,
|
|
50
|
-
[29]: `v-if/else branches must use unique keys.`,
|
|
51
|
-
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
52
|
-
[31]: `v-for is missing expression.`,
|
|
53
|
-
[32]: `v-for has invalid expression.`,
|
|
54
|
-
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
55
|
-
[34]: `v-bind is missing expression.`,
|
|
56
|
-
[35]: `v-on is missing expression.`,
|
|
57
|
-
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
58
|
-
[37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
|
59
|
-
[38]: `Duplicate slot names found. `,
|
|
60
|
-
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
61
|
-
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
62
|
-
[41]: `v-model is missing expression.`,
|
|
63
|
-
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
64
|
-
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
65
|
-
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
66
|
-
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
67
|
-
[45]: `Error parsing JavaScript expression: `,
|
|
68
|
-
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
69
|
-
// generic errors
|
|
70
|
-
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
71
|
-
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
72
|
-
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
73
|
-
[50]: `"scopeId" option is only supported in module mode.`,
|
|
74
|
-
// deprecations
|
|
75
|
-
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
76
|
-
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
77
|
-
// just to fulfill types
|
|
78
|
-
[53]: ``
|
|
79
|
-
};
|
|
80
|
-
|
|
81
4
|
const FRAGMENT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Fragment` : ``);
|
|
82
5
|
const TELEPORT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Teleport` : ``);
|
|
83
6
|
const SUSPENSE = Symbol(!!(process.env.NODE_ENV !== "production") ? `Suspense` : ``);
|
|
@@ -167,13 +90,14 @@ function registerRuntimeHelpers(helpers) {
|
|
|
167
90
|
}
|
|
168
91
|
|
|
169
92
|
const locStub = {
|
|
170
|
-
source: "",
|
|
171
93
|
start: { line: 1, column: 1, offset: 0 },
|
|
172
|
-
end: { line: 1, column: 1, offset: 0 }
|
|
94
|
+
end: { line: 1, column: 1, offset: 0 },
|
|
95
|
+
source: ""
|
|
173
96
|
};
|
|
174
|
-
function createRoot(children,
|
|
97
|
+
function createRoot(children, source = "") {
|
|
175
98
|
return {
|
|
176
99
|
type: 0,
|
|
100
|
+
source,
|
|
177
101
|
children,
|
|
178
102
|
helpers: /* @__PURE__ */ new Set(),
|
|
179
103
|
components: [],
|
|
@@ -183,7 +107,7 @@ function createRoot(children, loc = locStub) {
|
|
|
183
107
|
cached: 0,
|
|
184
108
|
temps: 0,
|
|
185
109
|
codegenNode: void 0,
|
|
186
|
-
loc
|
|
110
|
+
loc: locStub
|
|
187
111
|
};
|
|
188
112
|
}
|
|
189
113
|
function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
|
@@ -354,17 +278,970 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
|
|
354
278
|
}
|
|
355
279
|
}
|
|
356
280
|
|
|
281
|
+
const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
|
282
|
+
const defaultDelimitersClose = new Uint8Array([125, 125]);
|
|
283
|
+
function isTagStartChar(c) {
|
|
284
|
+
return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
|
285
|
+
}
|
|
286
|
+
function isWhitespace(c) {
|
|
287
|
+
return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
|
288
|
+
}
|
|
289
|
+
function isEndOfTagSection(c) {
|
|
290
|
+
return c === 47 || c === 62 || isWhitespace(c);
|
|
291
|
+
}
|
|
292
|
+
function toCharCodes(str) {
|
|
293
|
+
const ret = new Uint8Array(str.length);
|
|
294
|
+
for (let i = 0; i < str.length; i++) {
|
|
295
|
+
ret[i] = str.charCodeAt(i);
|
|
296
|
+
}
|
|
297
|
+
return ret;
|
|
298
|
+
}
|
|
299
|
+
const Sequences = {
|
|
300
|
+
Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
|
301
|
+
// CDATA[
|
|
302
|
+
CdataEnd: new Uint8Array([93, 93, 62]),
|
|
303
|
+
// ]]>
|
|
304
|
+
CommentEnd: new Uint8Array([45, 45, 62]),
|
|
305
|
+
// `-->`
|
|
306
|
+
ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
|
307
|
+
// `<\/script`
|
|
308
|
+
StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
|
309
|
+
// `</style`
|
|
310
|
+
TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
|
311
|
+
// `</title`
|
|
312
|
+
TextareaEnd: new Uint8Array([
|
|
313
|
+
60,
|
|
314
|
+
47,
|
|
315
|
+
116,
|
|
316
|
+
101,
|
|
317
|
+
120,
|
|
318
|
+
116,
|
|
319
|
+
97,
|
|
320
|
+
114,
|
|
321
|
+
101,
|
|
322
|
+
97
|
|
323
|
+
])
|
|
324
|
+
// `</textarea
|
|
325
|
+
};
|
|
326
|
+
class Tokenizer {
|
|
327
|
+
constructor(stack, cbs) {
|
|
328
|
+
this.stack = stack;
|
|
329
|
+
this.cbs = cbs;
|
|
330
|
+
/** The current state the tokenizer is in. */
|
|
331
|
+
this.state = 1;
|
|
332
|
+
/** The read buffer. */
|
|
333
|
+
this.buffer = "";
|
|
334
|
+
/** The beginning of the section that is currently being read. */
|
|
335
|
+
this.sectionStart = 0;
|
|
336
|
+
/** The index within the buffer that we are currently looking at. */
|
|
337
|
+
this.index = 0;
|
|
338
|
+
/** The start of the last entity. */
|
|
339
|
+
this.entityStart = 0;
|
|
340
|
+
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
341
|
+
this.baseState = 1;
|
|
342
|
+
/** For special parsing behavior inside of script and style tags. */
|
|
343
|
+
this.inRCDATA = false;
|
|
344
|
+
/** For disabling RCDATA tags handling */
|
|
345
|
+
this.inXML = false;
|
|
346
|
+
/** Reocrd newline positions for fast line / column calculation */
|
|
347
|
+
this.newlines = [];
|
|
348
|
+
this.mode = 0;
|
|
349
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
350
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
351
|
+
this.delimiterIndex = -1;
|
|
352
|
+
this.currentSequence = void 0;
|
|
353
|
+
this.sequenceIndex = 0;
|
|
354
|
+
}
|
|
355
|
+
get inSFCRoot() {
|
|
356
|
+
return this.mode === 2 && this.stack.length === 0;
|
|
357
|
+
}
|
|
358
|
+
reset() {
|
|
359
|
+
this.state = 1;
|
|
360
|
+
this.mode = 0;
|
|
361
|
+
this.buffer = "";
|
|
362
|
+
this.sectionStart = 0;
|
|
363
|
+
this.index = 0;
|
|
364
|
+
this.baseState = 1;
|
|
365
|
+
this.currentSequence = void 0;
|
|
366
|
+
this.newlines.length = 0;
|
|
367
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
368
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Generate Position object with line / column information using recorded
|
|
372
|
+
* newline positions. We know the index is always going to be an already
|
|
373
|
+
* processed index, so all the newlines up to this index should have been
|
|
374
|
+
* recorded.
|
|
375
|
+
*/
|
|
376
|
+
getPos(index) {
|
|
377
|
+
let line = 1;
|
|
378
|
+
let column = index + 1;
|
|
379
|
+
for (let i = this.newlines.length - 1; i >= 0; i--) {
|
|
380
|
+
const newlineIndex = this.newlines[i];
|
|
381
|
+
if (index > newlineIndex) {
|
|
382
|
+
line = i + 2;
|
|
383
|
+
column = index - newlineIndex;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return {
|
|
388
|
+
column,
|
|
389
|
+
line,
|
|
390
|
+
offset: index
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
peek() {
|
|
394
|
+
return this.buffer.charCodeAt(this.index + 1);
|
|
395
|
+
}
|
|
396
|
+
stateText(c) {
|
|
397
|
+
if (c === 60) {
|
|
398
|
+
if (this.index > this.sectionStart) {
|
|
399
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
400
|
+
}
|
|
401
|
+
this.state = 5;
|
|
402
|
+
this.sectionStart = this.index;
|
|
403
|
+
} else if (c === this.delimiterOpen[0]) {
|
|
404
|
+
this.state = 2;
|
|
405
|
+
this.delimiterIndex = 0;
|
|
406
|
+
this.stateInterpolationOpen(c);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
stateInterpolationOpen(c) {
|
|
410
|
+
if (c === this.delimiterOpen[this.delimiterIndex]) {
|
|
411
|
+
if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
|
412
|
+
const start = this.index + 1 - this.delimiterOpen.length;
|
|
413
|
+
if (start > this.sectionStart) {
|
|
414
|
+
this.cbs.ontext(this.sectionStart, start);
|
|
415
|
+
}
|
|
416
|
+
this.state = 3;
|
|
417
|
+
this.sectionStart = start;
|
|
418
|
+
} else {
|
|
419
|
+
this.delimiterIndex++;
|
|
420
|
+
}
|
|
421
|
+
} else if (this.inRCDATA) {
|
|
422
|
+
this.state = 32;
|
|
423
|
+
this.stateInRCDATA(c);
|
|
424
|
+
} else {
|
|
425
|
+
this.state = 1;
|
|
426
|
+
this.stateText(c);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
stateInterpolation(c) {
|
|
430
|
+
if (c === this.delimiterClose[0]) {
|
|
431
|
+
this.state = 4;
|
|
432
|
+
this.delimiterIndex = 0;
|
|
433
|
+
this.stateInterpolationClose(c);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
stateInterpolationClose(c) {
|
|
437
|
+
if (c === this.delimiterClose[this.delimiterIndex]) {
|
|
438
|
+
if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
|
439
|
+
this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
|
440
|
+
if (this.inRCDATA) {
|
|
441
|
+
this.state = 32;
|
|
442
|
+
} else {
|
|
443
|
+
this.state = 1;
|
|
444
|
+
}
|
|
445
|
+
this.sectionStart = this.index + 1;
|
|
446
|
+
} else {
|
|
447
|
+
this.delimiterIndex++;
|
|
448
|
+
}
|
|
449
|
+
} else {
|
|
450
|
+
this.state = 3;
|
|
451
|
+
this.stateInterpolation(c);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
stateSpecialStartSequence(c) {
|
|
455
|
+
const isEnd = this.sequenceIndex === this.currentSequence.length;
|
|
456
|
+
const isMatch = isEnd ? (
|
|
457
|
+
// If we are at the end of the sequence, make sure the tag name has ended
|
|
458
|
+
isEndOfTagSection(c)
|
|
459
|
+
) : (
|
|
460
|
+
// Otherwise, do a case-insensitive comparison
|
|
461
|
+
(c | 32) === this.currentSequence[this.sequenceIndex]
|
|
462
|
+
);
|
|
463
|
+
if (!isMatch) {
|
|
464
|
+
this.inRCDATA = false;
|
|
465
|
+
} else if (!isEnd) {
|
|
466
|
+
this.sequenceIndex++;
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
this.sequenceIndex = 0;
|
|
470
|
+
this.state = 6;
|
|
471
|
+
this.stateInTagName(c);
|
|
472
|
+
}
|
|
473
|
+
/** Look for an end tag. For <title> and <textarea>, also decode entities. */
|
|
474
|
+
stateInRCDATA(c) {
|
|
475
|
+
if (this.sequenceIndex === this.currentSequence.length) {
|
|
476
|
+
if (c === 62 || isWhitespace(c)) {
|
|
477
|
+
const endOfText = this.index - this.currentSequence.length;
|
|
478
|
+
if (this.sectionStart < endOfText) {
|
|
479
|
+
const actualIndex = this.index;
|
|
480
|
+
this.index = endOfText;
|
|
481
|
+
this.cbs.ontext(this.sectionStart, endOfText);
|
|
482
|
+
this.index = actualIndex;
|
|
483
|
+
}
|
|
484
|
+
this.sectionStart = endOfText + 2;
|
|
485
|
+
this.stateInClosingTagName(c);
|
|
486
|
+
this.inRCDATA = false;
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
this.sequenceIndex = 0;
|
|
490
|
+
}
|
|
491
|
+
if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
|
492
|
+
this.sequenceIndex += 1;
|
|
493
|
+
} else if (this.sequenceIndex === 0) {
|
|
494
|
+
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
|
495
|
+
if (c === this.delimiterOpen[0]) {
|
|
496
|
+
this.state = 2;
|
|
497
|
+
this.delimiterIndex = 0;
|
|
498
|
+
this.stateInterpolationOpen(c);
|
|
499
|
+
}
|
|
500
|
+
} else if (this.fastForwardTo(60)) {
|
|
501
|
+
this.sequenceIndex = 1;
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
this.sequenceIndex = Number(c === 60);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
stateCDATASequence(c) {
|
|
508
|
+
if (c === Sequences.Cdata[this.sequenceIndex]) {
|
|
509
|
+
if (++this.sequenceIndex === Sequences.Cdata.length) {
|
|
510
|
+
this.state = 28;
|
|
511
|
+
this.currentSequence = Sequences.CdataEnd;
|
|
512
|
+
this.sequenceIndex = 0;
|
|
513
|
+
this.sectionStart = this.index + 1;
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
this.sequenceIndex = 0;
|
|
517
|
+
this.state = 23;
|
|
518
|
+
this.stateInDeclaration(c);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* When we wait for one specific character, we can speed things up
|
|
523
|
+
* by skipping through the buffer until we find it.
|
|
524
|
+
*
|
|
525
|
+
* @returns Whether the character was found.
|
|
526
|
+
*/
|
|
527
|
+
fastForwardTo(c) {
|
|
528
|
+
while (++this.index < this.buffer.length) {
|
|
529
|
+
const cc = this.buffer.charCodeAt(this.index);
|
|
530
|
+
if (cc === 10) {
|
|
531
|
+
this.newlines.push(this.index);
|
|
532
|
+
}
|
|
533
|
+
if (cc === c) {
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
this.index = this.buffer.length - 1;
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Comments and CDATA end with `-->` and `]]>`.
|
|
542
|
+
*
|
|
543
|
+
* Their common qualities are:
|
|
544
|
+
* - Their end sequences have a distinct character they start with.
|
|
545
|
+
* - That character is then repeated, so we have to check multiple repeats.
|
|
546
|
+
* - All characters but the start character of the sequence can be skipped.
|
|
547
|
+
*/
|
|
548
|
+
stateInCommentLike(c) {
|
|
549
|
+
if (c === this.currentSequence[this.sequenceIndex]) {
|
|
550
|
+
if (++this.sequenceIndex === this.currentSequence.length) {
|
|
551
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
552
|
+
this.cbs.oncdata(this.sectionStart, this.index - 2);
|
|
553
|
+
} else {
|
|
554
|
+
this.cbs.oncomment(this.sectionStart, this.index - 2);
|
|
555
|
+
}
|
|
556
|
+
this.sequenceIndex = 0;
|
|
557
|
+
this.sectionStart = this.index + 1;
|
|
558
|
+
this.state = 1;
|
|
559
|
+
}
|
|
560
|
+
} else if (this.sequenceIndex === 0) {
|
|
561
|
+
if (this.fastForwardTo(this.currentSequence[0])) {
|
|
562
|
+
this.sequenceIndex = 1;
|
|
563
|
+
}
|
|
564
|
+
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
|
565
|
+
this.sequenceIndex = 0;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
startSpecial(sequence, offset) {
|
|
569
|
+
this.enterRCDATA(sequence, offset);
|
|
570
|
+
this.state = 31;
|
|
571
|
+
}
|
|
572
|
+
enterRCDATA(sequence, offset) {
|
|
573
|
+
this.inRCDATA = true;
|
|
574
|
+
this.currentSequence = sequence;
|
|
575
|
+
this.sequenceIndex = offset;
|
|
576
|
+
}
|
|
577
|
+
stateBeforeTagName(c) {
|
|
578
|
+
if (c === 33) {
|
|
579
|
+
this.state = 22;
|
|
580
|
+
this.sectionStart = this.index + 1;
|
|
581
|
+
} else if (c === 63) {
|
|
582
|
+
this.state = 24;
|
|
583
|
+
this.sectionStart = this.index + 1;
|
|
584
|
+
} else if (isTagStartChar(c)) {
|
|
585
|
+
this.sectionStart = this.index;
|
|
586
|
+
if (this.mode === 0) {
|
|
587
|
+
this.state = 6;
|
|
588
|
+
} else if (this.inSFCRoot) {
|
|
589
|
+
this.state = 34;
|
|
590
|
+
} else if (!this.inXML) {
|
|
591
|
+
const lower = c | 32;
|
|
592
|
+
if (lower === 116) {
|
|
593
|
+
this.state = 30;
|
|
594
|
+
} else {
|
|
595
|
+
this.state = lower === 115 ? 29 : 6;
|
|
596
|
+
}
|
|
597
|
+
} else {
|
|
598
|
+
this.state = 6;
|
|
599
|
+
}
|
|
600
|
+
} else if (c === 47) {
|
|
601
|
+
this.state = 8;
|
|
602
|
+
} else {
|
|
603
|
+
this.state = 1;
|
|
604
|
+
this.stateText(c);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
stateInTagName(c) {
|
|
608
|
+
if (isEndOfTagSection(c)) {
|
|
609
|
+
this.handleTagName(c);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
stateInSFCRootTagName(c) {
|
|
613
|
+
if (isEndOfTagSection(c)) {
|
|
614
|
+
const tag = this.buffer.slice(this.sectionStart, this.index);
|
|
615
|
+
if (tag !== "template") {
|
|
616
|
+
this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
|
617
|
+
}
|
|
618
|
+
this.handleTagName(c);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
handleTagName(c) {
|
|
622
|
+
this.cbs.onopentagname(this.sectionStart, this.index);
|
|
623
|
+
this.sectionStart = -1;
|
|
624
|
+
this.state = 11;
|
|
625
|
+
this.stateBeforeAttrName(c);
|
|
626
|
+
}
|
|
627
|
+
stateBeforeClosingTagName(c) {
|
|
628
|
+
if (isWhitespace(c)) ; else if (c === 62) {
|
|
629
|
+
if (!!(process.env.NODE_ENV !== "production") || false) {
|
|
630
|
+
this.cbs.onerr(14, this.index);
|
|
631
|
+
}
|
|
632
|
+
this.state = 1;
|
|
633
|
+
this.sectionStart = this.index + 1;
|
|
634
|
+
} else {
|
|
635
|
+
this.state = isTagStartChar(c) ? 9 : 27;
|
|
636
|
+
this.sectionStart = this.index;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
stateInClosingTagName(c) {
|
|
640
|
+
if (c === 62 || isWhitespace(c)) {
|
|
641
|
+
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
642
|
+
this.sectionStart = -1;
|
|
643
|
+
this.state = 10;
|
|
644
|
+
this.stateAfterClosingTagName(c);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
stateAfterClosingTagName(c) {
|
|
648
|
+
if (c === 62) {
|
|
649
|
+
this.state = 1;
|
|
650
|
+
this.sectionStart = this.index + 1;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
stateBeforeAttrName(c) {
|
|
654
|
+
if (c === 62) {
|
|
655
|
+
this.cbs.onopentagend(this.index);
|
|
656
|
+
if (this.inRCDATA) {
|
|
657
|
+
this.state = 32;
|
|
658
|
+
} else {
|
|
659
|
+
this.state = 1;
|
|
660
|
+
}
|
|
661
|
+
this.sectionStart = this.index + 1;
|
|
662
|
+
} else if (c === 47) {
|
|
663
|
+
this.state = 7;
|
|
664
|
+
if ((!!(process.env.NODE_ENV !== "production") || false) && this.peek() !== 62) {
|
|
665
|
+
this.cbs.onerr(22, this.index);
|
|
666
|
+
}
|
|
667
|
+
} else if (c === 60 && this.peek() === 47) {
|
|
668
|
+
this.cbs.onopentagend(this.index);
|
|
669
|
+
this.state = 5;
|
|
670
|
+
this.sectionStart = this.index;
|
|
671
|
+
} else if (!isWhitespace(c)) {
|
|
672
|
+
if ((!!(process.env.NODE_ENV !== "production") || false) && c === 61) {
|
|
673
|
+
this.cbs.onerr(
|
|
674
|
+
19,
|
|
675
|
+
this.index
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
this.handleAttrStart(c);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
handleAttrStart(c) {
|
|
682
|
+
if (c === 118 && this.peek() === 45) {
|
|
683
|
+
this.state = 13;
|
|
684
|
+
this.sectionStart = this.index;
|
|
685
|
+
} else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
|
686
|
+
this.cbs.ondirname(this.index, this.index + 1);
|
|
687
|
+
this.state = 14;
|
|
688
|
+
this.sectionStart = this.index + 1;
|
|
689
|
+
} else {
|
|
690
|
+
this.state = 12;
|
|
691
|
+
this.sectionStart = this.index;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
stateInSelfClosingTag(c) {
|
|
695
|
+
if (c === 62) {
|
|
696
|
+
this.cbs.onselfclosingtag(this.index);
|
|
697
|
+
this.state = 1;
|
|
698
|
+
this.sectionStart = this.index + 1;
|
|
699
|
+
this.inRCDATA = false;
|
|
700
|
+
} else if (!isWhitespace(c)) {
|
|
701
|
+
this.state = 11;
|
|
702
|
+
this.stateBeforeAttrName(c);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
stateInAttrName(c) {
|
|
706
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
707
|
+
this.cbs.onattribname(this.sectionStart, this.index);
|
|
708
|
+
this.handleAttrNameEnd(c);
|
|
709
|
+
} else if ((!!(process.env.NODE_ENV !== "production") || false) && (c === 34 || c === 39 || c === 60)) {
|
|
710
|
+
this.cbs.onerr(
|
|
711
|
+
17,
|
|
712
|
+
this.index
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
stateInDirName(c) {
|
|
717
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
718
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
719
|
+
this.handleAttrNameEnd(c);
|
|
720
|
+
} else if (c === 58) {
|
|
721
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
722
|
+
this.state = 14;
|
|
723
|
+
this.sectionStart = this.index + 1;
|
|
724
|
+
} else if (c === 46) {
|
|
725
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
726
|
+
this.state = 16;
|
|
727
|
+
this.sectionStart = this.index + 1;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
stateInDirArg(c) {
|
|
731
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
732
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
733
|
+
this.handleAttrNameEnd(c);
|
|
734
|
+
} else if (c === 91) {
|
|
735
|
+
this.state = 15;
|
|
736
|
+
} else if (c === 46) {
|
|
737
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
738
|
+
this.state = 16;
|
|
739
|
+
this.sectionStart = this.index + 1;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
stateInDynamicDirArg(c) {
|
|
743
|
+
if (c === 93) {
|
|
744
|
+
this.state = 14;
|
|
745
|
+
} else if (c === 61 || isEndOfTagSection(c)) {
|
|
746
|
+
this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
|
747
|
+
this.handleAttrNameEnd(c);
|
|
748
|
+
if (!!(process.env.NODE_ENV !== "production") || false) {
|
|
749
|
+
this.cbs.onerr(
|
|
750
|
+
27,
|
|
751
|
+
this.index
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
stateInDirModifier(c) {
|
|
757
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
758
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
759
|
+
this.handleAttrNameEnd(c);
|
|
760
|
+
} else if (c === 46) {
|
|
761
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
762
|
+
this.sectionStart = this.index + 1;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
handleAttrNameEnd(c) {
|
|
766
|
+
this.sectionStart = this.index;
|
|
767
|
+
this.state = 17;
|
|
768
|
+
this.cbs.onattribnameend(this.index);
|
|
769
|
+
this.stateAfterAttrName(c);
|
|
770
|
+
}
|
|
771
|
+
stateAfterAttrName(c) {
|
|
772
|
+
if (c === 61) {
|
|
773
|
+
this.state = 18;
|
|
774
|
+
} else if (c === 47 || c === 62) {
|
|
775
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
776
|
+
this.sectionStart = -1;
|
|
777
|
+
this.state = 11;
|
|
778
|
+
this.stateBeforeAttrName(c);
|
|
779
|
+
} else if (!isWhitespace(c)) {
|
|
780
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
781
|
+
this.handleAttrStart(c);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
stateBeforeAttrValue(c) {
|
|
785
|
+
if (c === 34) {
|
|
786
|
+
this.state = 19;
|
|
787
|
+
this.sectionStart = this.index + 1;
|
|
788
|
+
} else if (c === 39) {
|
|
789
|
+
this.state = 20;
|
|
790
|
+
this.sectionStart = this.index + 1;
|
|
791
|
+
} else if (!isWhitespace(c)) {
|
|
792
|
+
this.sectionStart = this.index;
|
|
793
|
+
this.state = 21;
|
|
794
|
+
this.stateInAttrValueNoQuotes(c);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
handleInAttrValue(c, quote) {
|
|
798
|
+
if (c === quote || this.fastForwardTo(quote)) {
|
|
799
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
800
|
+
this.sectionStart = -1;
|
|
801
|
+
this.cbs.onattribend(
|
|
802
|
+
quote === 34 ? 3 : 2,
|
|
803
|
+
this.index + 1
|
|
804
|
+
);
|
|
805
|
+
this.state = 11;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
stateInAttrValueDoubleQuotes(c) {
|
|
809
|
+
this.handleInAttrValue(c, 34);
|
|
810
|
+
}
|
|
811
|
+
stateInAttrValueSingleQuotes(c) {
|
|
812
|
+
this.handleInAttrValue(c, 39);
|
|
813
|
+
}
|
|
814
|
+
stateInAttrValueNoQuotes(c) {
|
|
815
|
+
if (isWhitespace(c) || c === 62) {
|
|
816
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
817
|
+
this.sectionStart = -1;
|
|
818
|
+
this.cbs.onattribend(1, this.index);
|
|
819
|
+
this.state = 11;
|
|
820
|
+
this.stateBeforeAttrName(c);
|
|
821
|
+
} else if ((!!(process.env.NODE_ENV !== "production") || false) && c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
|
|
822
|
+
this.cbs.onerr(
|
|
823
|
+
18,
|
|
824
|
+
this.index
|
|
825
|
+
);
|
|
826
|
+
} else ;
|
|
827
|
+
}
|
|
828
|
+
stateBeforeDeclaration(c) {
|
|
829
|
+
if (c === 91) {
|
|
830
|
+
this.state = 26;
|
|
831
|
+
this.sequenceIndex = 0;
|
|
832
|
+
} else {
|
|
833
|
+
this.state = c === 45 ? 25 : 23;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
stateInDeclaration(c) {
|
|
837
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
838
|
+
this.state = 1;
|
|
839
|
+
this.sectionStart = this.index + 1;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
stateInProcessingInstruction(c) {
|
|
843
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
844
|
+
this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
|
845
|
+
this.state = 1;
|
|
846
|
+
this.sectionStart = this.index + 1;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
stateBeforeComment(c) {
|
|
850
|
+
if (c === 45) {
|
|
851
|
+
this.state = 28;
|
|
852
|
+
this.currentSequence = Sequences.CommentEnd;
|
|
853
|
+
this.sequenceIndex = 2;
|
|
854
|
+
this.sectionStart = this.index + 1;
|
|
855
|
+
} else {
|
|
856
|
+
this.state = 23;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
stateInSpecialComment(c) {
|
|
860
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
861
|
+
this.cbs.oncomment(this.sectionStart, this.index);
|
|
862
|
+
this.state = 1;
|
|
863
|
+
this.sectionStart = this.index + 1;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
stateBeforeSpecialS(c) {
|
|
867
|
+
const lower = c | 32;
|
|
868
|
+
if (lower === Sequences.ScriptEnd[3]) {
|
|
869
|
+
this.startSpecial(Sequences.ScriptEnd, 4);
|
|
870
|
+
} else if (lower === Sequences.StyleEnd[3]) {
|
|
871
|
+
this.startSpecial(Sequences.StyleEnd, 4);
|
|
872
|
+
} else {
|
|
873
|
+
this.state = 6;
|
|
874
|
+
this.stateInTagName(c);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
stateBeforeSpecialT(c) {
|
|
878
|
+
const lower = c | 32;
|
|
879
|
+
if (lower === Sequences.TitleEnd[3]) {
|
|
880
|
+
this.startSpecial(Sequences.TitleEnd, 4);
|
|
881
|
+
} else if (lower === Sequences.TextareaEnd[3]) {
|
|
882
|
+
this.startSpecial(Sequences.TextareaEnd, 4);
|
|
883
|
+
} else {
|
|
884
|
+
this.state = 6;
|
|
885
|
+
this.stateInTagName(c);
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
startEntity() {
|
|
889
|
+
}
|
|
890
|
+
stateInEntity() {
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
894
|
+
*
|
|
895
|
+
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
896
|
+
*/
|
|
897
|
+
parse(input) {
|
|
898
|
+
this.buffer = input;
|
|
899
|
+
while (this.index < this.buffer.length) {
|
|
900
|
+
const c = this.buffer.charCodeAt(this.index);
|
|
901
|
+
if (c === 10) {
|
|
902
|
+
this.newlines.push(this.index);
|
|
903
|
+
}
|
|
904
|
+
switch (this.state) {
|
|
905
|
+
case 1: {
|
|
906
|
+
this.stateText(c);
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
case 2: {
|
|
910
|
+
this.stateInterpolationOpen(c);
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
case 3: {
|
|
914
|
+
this.stateInterpolation(c);
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
case 4: {
|
|
918
|
+
this.stateInterpolationClose(c);
|
|
919
|
+
break;
|
|
920
|
+
}
|
|
921
|
+
case 31: {
|
|
922
|
+
this.stateSpecialStartSequence(c);
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
case 32: {
|
|
926
|
+
this.stateInRCDATA(c);
|
|
927
|
+
break;
|
|
928
|
+
}
|
|
929
|
+
case 26: {
|
|
930
|
+
this.stateCDATASequence(c);
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
case 19: {
|
|
934
|
+
this.stateInAttrValueDoubleQuotes(c);
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
case 12: {
|
|
938
|
+
this.stateInAttrName(c);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
case 13: {
|
|
942
|
+
this.stateInDirName(c);
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
case 14: {
|
|
946
|
+
this.stateInDirArg(c);
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
case 15: {
|
|
950
|
+
this.stateInDynamicDirArg(c);
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
case 16: {
|
|
954
|
+
this.stateInDirModifier(c);
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
957
|
+
case 28: {
|
|
958
|
+
this.stateInCommentLike(c);
|
|
959
|
+
break;
|
|
960
|
+
}
|
|
961
|
+
case 27: {
|
|
962
|
+
this.stateInSpecialComment(c);
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
case 11: {
|
|
966
|
+
this.stateBeforeAttrName(c);
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case 6: {
|
|
970
|
+
this.stateInTagName(c);
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
case 34: {
|
|
974
|
+
this.stateInSFCRootTagName(c);
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
case 9: {
|
|
978
|
+
this.stateInClosingTagName(c);
|
|
979
|
+
break;
|
|
980
|
+
}
|
|
981
|
+
case 5: {
|
|
982
|
+
this.stateBeforeTagName(c);
|
|
983
|
+
break;
|
|
984
|
+
}
|
|
985
|
+
case 17: {
|
|
986
|
+
this.stateAfterAttrName(c);
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
case 20: {
|
|
990
|
+
this.stateInAttrValueSingleQuotes(c);
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
993
|
+
case 18: {
|
|
994
|
+
this.stateBeforeAttrValue(c);
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
case 8: {
|
|
998
|
+
this.stateBeforeClosingTagName(c);
|
|
999
|
+
break;
|
|
1000
|
+
}
|
|
1001
|
+
case 10: {
|
|
1002
|
+
this.stateAfterClosingTagName(c);
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1005
|
+
case 29: {
|
|
1006
|
+
this.stateBeforeSpecialS(c);
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
case 30: {
|
|
1010
|
+
this.stateBeforeSpecialT(c);
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
case 21: {
|
|
1014
|
+
this.stateInAttrValueNoQuotes(c);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
case 7: {
|
|
1018
|
+
this.stateInSelfClosingTag(c);
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
case 23: {
|
|
1022
|
+
this.stateInDeclaration(c);
|
|
1023
|
+
break;
|
|
1024
|
+
}
|
|
1025
|
+
case 22: {
|
|
1026
|
+
this.stateBeforeDeclaration(c);
|
|
1027
|
+
break;
|
|
1028
|
+
}
|
|
1029
|
+
case 25: {
|
|
1030
|
+
this.stateBeforeComment(c);
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
case 24: {
|
|
1034
|
+
this.stateInProcessingInstruction(c);
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
case 33: {
|
|
1038
|
+
this.stateInEntity();
|
|
1039
|
+
break;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
this.index++;
|
|
1043
|
+
}
|
|
1044
|
+
this.cleanup();
|
|
1045
|
+
this.finish();
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Remove data that has already been consumed from the buffer.
|
|
1049
|
+
*/
|
|
1050
|
+
cleanup() {
|
|
1051
|
+
if (this.sectionStart !== this.index) {
|
|
1052
|
+
if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
|
1053
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
1054
|
+
this.sectionStart = this.index;
|
|
1055
|
+
} else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
|
1056
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
1057
|
+
this.sectionStart = this.index;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
finish() {
|
|
1062
|
+
this.handleTrailingData();
|
|
1063
|
+
this.cbs.onend();
|
|
1064
|
+
}
|
|
1065
|
+
/** Handle any trailing data. */
|
|
1066
|
+
handleTrailingData() {
|
|
1067
|
+
const endIndex = this.buffer.length;
|
|
1068
|
+
if (this.sectionStart >= endIndex) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
if (this.state === 28) {
|
|
1072
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
1073
|
+
this.cbs.oncdata(this.sectionStart, endIndex);
|
|
1074
|
+
} else {
|
|
1075
|
+
this.cbs.oncomment(this.sectionStart, endIndex);
|
|
1076
|
+
}
|
|
1077
|
+
} else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) ; else {
|
|
1078
|
+
this.cbs.ontext(this.sectionStart, endIndex);
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
emitCodePoint(cp, consumed) {
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
const deprecationData = {
|
|
1086
|
+
["COMPILER_IS_ON_ELEMENT"]: {
|
|
1087
|
+
message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
|
|
1088
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
1089
|
+
},
|
|
1090
|
+
["COMPILER_V_BIND_SYNC"]: {
|
|
1091
|
+
message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
|
|
1092
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
1093
|
+
},
|
|
1094
|
+
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
1095
|
+
message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
|
|
1096
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
1097
|
+
},
|
|
1098
|
+
["COMPILER_V_ON_NATIVE"]: {
|
|
1099
|
+
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
1100
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
1101
|
+
},
|
|
1102
|
+
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
1103
|
+
message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
|
|
1104
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
1105
|
+
},
|
|
1106
|
+
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
1107
|
+
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
1108
|
+
},
|
|
1109
|
+
["COMPILER_INLINE_TEMPLATE"]: {
|
|
1110
|
+
message: `"inline-template" has been removed in Vue 3.`,
|
|
1111
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
1112
|
+
},
|
|
1113
|
+
["COMPILER_FILTER"]: {
|
|
1114
|
+
message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
|
|
1115
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
function getCompatValue(key, { compatConfig }) {
|
|
1119
|
+
const value = compatConfig && compatConfig[key];
|
|
1120
|
+
if (key === "MODE") {
|
|
1121
|
+
return value || 3;
|
|
1122
|
+
} else {
|
|
1123
|
+
return value;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
function isCompatEnabled(key, context) {
|
|
1127
|
+
const mode = getCompatValue("MODE", context);
|
|
1128
|
+
const value = getCompatValue(key, context);
|
|
1129
|
+
return mode === 3 ? value === true : value !== false;
|
|
1130
|
+
}
|
|
1131
|
+
function checkCompatEnabled(key, context, loc, ...args) {
|
|
1132
|
+
const enabled = isCompatEnabled(key, context);
|
|
1133
|
+
if (!!(process.env.NODE_ENV !== "production") && enabled) {
|
|
1134
|
+
warnDeprecation(key, context, loc, ...args);
|
|
1135
|
+
}
|
|
1136
|
+
return enabled;
|
|
1137
|
+
}
|
|
1138
|
+
function warnDeprecation(key, context, loc, ...args) {
|
|
1139
|
+
const val = getCompatValue(key, context);
|
|
1140
|
+
if (val === "suppress-warning") {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
const { message, link } = deprecationData[key];
|
|
1144
|
+
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
1145
|
+
Details: ${link}` : ``}`;
|
|
1146
|
+
const err = new SyntaxError(msg);
|
|
1147
|
+
err.code = key;
|
|
1148
|
+
if (loc)
|
|
1149
|
+
err.loc = loc;
|
|
1150
|
+
context.onWarn(err);
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function defaultOnError(error) {
|
|
1154
|
+
throw error;
|
|
1155
|
+
}
|
|
1156
|
+
function defaultOnWarn(msg) {
|
|
1157
|
+
!!(process.env.NODE_ENV !== "production") && console.warn(`[Vue warn] ${msg.message}`);
|
|
1158
|
+
}
|
|
1159
|
+
function createCompilerError(code, loc, messages, additionalMessage) {
|
|
1160
|
+
const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
|
|
1161
|
+
const error = new SyntaxError(String(msg));
|
|
1162
|
+
error.code = code;
|
|
1163
|
+
error.loc = loc;
|
|
1164
|
+
return error;
|
|
1165
|
+
}
|
|
1166
|
+
const errorMessages = {
|
|
1167
|
+
// parse errors
|
|
1168
|
+
[0]: "Illegal comment.",
|
|
1169
|
+
[1]: "CDATA section is allowed only in XML context.",
|
|
1170
|
+
[2]: "Duplicate attribute.",
|
|
1171
|
+
[3]: "End tag cannot have attributes.",
|
|
1172
|
+
[4]: "Illegal '/' in tags.",
|
|
1173
|
+
[5]: "Unexpected EOF in tag.",
|
|
1174
|
+
[6]: "Unexpected EOF in CDATA section.",
|
|
1175
|
+
[7]: "Unexpected EOF in comment.",
|
|
1176
|
+
[8]: "Unexpected EOF in script.",
|
|
1177
|
+
[9]: "Unexpected EOF in tag.",
|
|
1178
|
+
[10]: "Incorrectly closed comment.",
|
|
1179
|
+
[11]: "Incorrectly opened comment.",
|
|
1180
|
+
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
1181
|
+
[13]: "Attribute value was expected.",
|
|
1182
|
+
[14]: "End tag name was expected.",
|
|
1183
|
+
[15]: "Whitespace was expected.",
|
|
1184
|
+
[16]: "Unexpected '<!--' in comment.",
|
|
1185
|
+
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
1186
|
+
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
1187
|
+
[19]: "Attribute name cannot start with '='.",
|
|
1188
|
+
[21]: "'<?' is allowed only in XML context.",
|
|
1189
|
+
[20]: `Unexpected null character.`,
|
|
1190
|
+
[22]: "Illegal '/' in tags.",
|
|
1191
|
+
// Vue-specific parse errors
|
|
1192
|
+
[23]: "Invalid end tag.",
|
|
1193
|
+
[24]: "Element is missing end tag.",
|
|
1194
|
+
[25]: "Interpolation end sign was not found.",
|
|
1195
|
+
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
1196
|
+
[26]: "Legal directive name was expected.",
|
|
1197
|
+
// transform errors
|
|
1198
|
+
[28]: `v-if/v-else-if is missing expression.`,
|
|
1199
|
+
[29]: `v-if/else branches must use unique keys.`,
|
|
1200
|
+
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
1201
|
+
[31]: `v-for is missing expression.`,
|
|
1202
|
+
[32]: `v-for has invalid expression.`,
|
|
1203
|
+
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
1204
|
+
[34]: `v-bind is missing expression.`,
|
|
1205
|
+
[35]: `v-on is missing expression.`,
|
|
1206
|
+
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
1207
|
+
[37]: `Mixed v-slot usage on both the component and nested <template>. When there are multiple named slots, all slots should use <template> syntax to avoid scope ambiguity.`,
|
|
1208
|
+
[38]: `Duplicate slot names found. `,
|
|
1209
|
+
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
1210
|
+
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
1211
|
+
[41]: `v-model is missing expression.`,
|
|
1212
|
+
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
1213
|
+
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
1214
|
+
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
1215
|
+
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
1216
|
+
[45]: `Error parsing JavaScript expression: `,
|
|
1217
|
+
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
1218
|
+
// generic errors
|
|
1219
|
+
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
1220
|
+
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
1221
|
+
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
1222
|
+
[50]: `"scopeId" option is only supported in module mode.`,
|
|
1223
|
+
// deprecations
|
|
1224
|
+
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
1225
|
+
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
1226
|
+
// just to fulfill types
|
|
1227
|
+
[53]: ``
|
|
1228
|
+
};
|
|
1229
|
+
|
|
357
1230
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
358
|
-
const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
|
|
359
1231
|
function isCoreComponent(tag) {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
1232
|
+
switch (tag) {
|
|
1233
|
+
case "Teleport":
|
|
1234
|
+
case "teleport":
|
|
1235
|
+
return TELEPORT;
|
|
1236
|
+
case "Suspense":
|
|
1237
|
+
case "suspense":
|
|
1238
|
+
return SUSPENSE;
|
|
1239
|
+
case "KeepAlive":
|
|
1240
|
+
case "keep-alive":
|
|
1241
|
+
return KEEP_ALIVE;
|
|
1242
|
+
case "BaseTransition":
|
|
1243
|
+
case "base-transition":
|
|
1244
|
+
return BASE_TRANSITION;
|
|
368
1245
|
}
|
|
369
1246
|
}
|
|
370
1247
|
const nonIdentifierRE = /^\d|[^\$\w]/;
|
|
@@ -436,25 +1313,13 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
436
1313
|
};
|
|
437
1314
|
const isMemberExpressionNode = NOOP ;
|
|
438
1315
|
const isMemberExpression = isMemberExpressionBrowser ;
|
|
439
|
-
function getInnerRange(loc, offset, length) {
|
|
440
|
-
const source = loc.source.slice(offset, offset + length);
|
|
441
|
-
const newLoc = {
|
|
442
|
-
source,
|
|
443
|
-
start: advancePositionWithClone(loc.start, loc.source, offset),
|
|
444
|
-
end: loc.end
|
|
445
|
-
};
|
|
446
|
-
if (length != null) {
|
|
447
|
-
newLoc.end = advancePositionWithClone(
|
|
448
|
-
loc.start,
|
|
449
|
-
loc.source,
|
|
450
|
-
offset + length
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
return newLoc;
|
|
454
|
-
}
|
|
455
1316
|
function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
|
|
456
1317
|
return advancePositionWithMutation(
|
|
457
|
-
|
|
1318
|
+
{
|
|
1319
|
+
offset: pos.offset,
|
|
1320
|
+
line: pos.line,
|
|
1321
|
+
column: pos.column
|
|
1322
|
+
},
|
|
458
1323
|
source,
|
|
459
1324
|
numberOfCharacters
|
|
460
1325
|
);
|
|
@@ -658,470 +1523,558 @@ function getMemoedVNodeCall(node) {
|
|
|
658
1523
|
}
|
|
659
1524
|
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
660
1525
|
|
|
661
|
-
const deprecationData = {
|
|
662
|
-
["COMPILER_IS_ON_ELEMENT"]: {
|
|
663
|
-
message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
|
|
664
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
665
|
-
},
|
|
666
|
-
["COMPILER_V_BIND_SYNC"]: {
|
|
667
|
-
message: (key) => `.sync modifier for v-bind has been removed. Use v-model with argument instead. \`v-bind:${key}.sync\` should be changed to \`v-model:${key}\`.`,
|
|
668
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
669
|
-
},
|
|
670
|
-
["COMPILER_V_BIND_PROP"]: {
|
|
671
|
-
message: `.prop modifier for v-bind has been removed and no longer necessary. Vue 3 will automatically set a binding as DOM property when appropriate.`
|
|
672
|
-
},
|
|
673
|
-
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
674
|
-
message: `v-bind="obj" usage is now order sensitive and behaves like JavaScript object spread: it will now overwrite an existing non-mergeable attribute that appears before v-bind in the case of conflict. To retain 2.x behavior, move v-bind to make it the first attribute. You can also suppress this warning if the usage is intended.`,
|
|
675
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
676
|
-
},
|
|
677
|
-
["COMPILER_V_ON_NATIVE"]: {
|
|
678
|
-
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
679
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
680
|
-
},
|
|
681
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
682
|
-
message: `v-if / v-for precedence when used on the same element has changed in Vue 3: v-if now takes higher precedence and will no longer have access to v-for scope variables. It is best to avoid the ambiguity with <template> tags or use a computed property that filters v-for data source.`,
|
|
683
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
684
|
-
},
|
|
685
|
-
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
686
|
-
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
687
|
-
},
|
|
688
|
-
["COMPILER_INLINE_TEMPLATE"]: {
|
|
689
|
-
message: `"inline-template" has been removed in Vue 3.`,
|
|
690
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
691
|
-
},
|
|
692
|
-
["COMPILER_FILTER"]: {
|
|
693
|
-
message: `filters have been removed in Vue 3. The "|" symbol will be treated as native JavaScript bitwise OR operator. Use method calls or computed properties instead.`,
|
|
694
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
695
|
-
}
|
|
696
|
-
};
|
|
697
|
-
function getCompatValue(key, context) {
|
|
698
|
-
const config = context.options ? context.options.compatConfig : context.compatConfig;
|
|
699
|
-
const value = config && config[key];
|
|
700
|
-
if (key === "MODE") {
|
|
701
|
-
return value || 3;
|
|
702
|
-
} else {
|
|
703
|
-
return value;
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
function isCompatEnabled(key, context) {
|
|
707
|
-
const mode = getCompatValue("MODE", context);
|
|
708
|
-
const value = getCompatValue(key, context);
|
|
709
|
-
return mode === 3 ? value === true : value !== false;
|
|
710
|
-
}
|
|
711
|
-
function checkCompatEnabled(key, context, loc, ...args) {
|
|
712
|
-
const enabled = isCompatEnabled(key, context);
|
|
713
|
-
if (!!(process.env.NODE_ENV !== "production") && enabled) {
|
|
714
|
-
warnDeprecation(key, context, loc, ...args);
|
|
715
|
-
}
|
|
716
|
-
return enabled;
|
|
717
|
-
}
|
|
718
|
-
function warnDeprecation(key, context, loc, ...args) {
|
|
719
|
-
const val = getCompatValue(key, context);
|
|
720
|
-
if (val === "suppress-warning") {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
const { message, link } = deprecationData[key];
|
|
724
|
-
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
725
|
-
Details: ${link}` : ``}`;
|
|
726
|
-
const err = new SyntaxError(msg);
|
|
727
|
-
err.code = key;
|
|
728
|
-
if (loc)
|
|
729
|
-
err.loc = loc;
|
|
730
|
-
context.onWarn(err);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
|
734
|
-
const decodeMap = {
|
|
735
|
-
gt: ">",
|
|
736
|
-
lt: "<",
|
|
737
|
-
amp: "&",
|
|
738
|
-
apos: "'",
|
|
739
|
-
quot: '"'
|
|
740
|
-
};
|
|
741
1526
|
const defaultParserOptions = {
|
|
1527
|
+
parseMode: "base",
|
|
1528
|
+
ns: 0,
|
|
742
1529
|
delimiters: [`{{`, `}}`],
|
|
743
1530
|
getNamespace: () => 0,
|
|
744
|
-
getTextMode: () => 0,
|
|
745
1531
|
isVoidTag: NO,
|
|
746
1532
|
isPreTag: NO,
|
|
747
1533
|
isCustomElement: NO,
|
|
748
|
-
decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
|
749
1534
|
onError: defaultOnError,
|
|
750
1535
|
onWarn: defaultOnWarn,
|
|
751
1536
|
comments: !!(process.env.NODE_ENV !== "production")
|
|
752
1537
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
let
|
|
786
|
-
if (
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
1538
|
+
let currentOptions = defaultParserOptions;
|
|
1539
|
+
let currentRoot = null;
|
|
1540
|
+
let currentInput = "";
|
|
1541
|
+
let currentOpenTag = null;
|
|
1542
|
+
let currentProp = null;
|
|
1543
|
+
let currentAttrValue = "";
|
|
1544
|
+
let currentAttrStartIndex = -1;
|
|
1545
|
+
let currentAttrEndIndex = -1;
|
|
1546
|
+
let inPre = 0;
|
|
1547
|
+
let inVPre = false;
|
|
1548
|
+
let currentVPreBoundary = null;
|
|
1549
|
+
const stack = [];
|
|
1550
|
+
const tokenizer = new Tokenizer(stack, {
|
|
1551
|
+
onerr: emitError,
|
|
1552
|
+
ontext(start, end) {
|
|
1553
|
+
onText(getSlice(start, end), start, end);
|
|
1554
|
+
},
|
|
1555
|
+
ontextentity(char, start, end) {
|
|
1556
|
+
onText(char, start, end);
|
|
1557
|
+
},
|
|
1558
|
+
oninterpolation(start, end) {
|
|
1559
|
+
if (inVPre) {
|
|
1560
|
+
return onText(getSlice(start, end), start, end);
|
|
1561
|
+
}
|
|
1562
|
+
let innerStart = start + tokenizer.delimiterOpen.length;
|
|
1563
|
+
let innerEnd = end - tokenizer.delimiterClose.length;
|
|
1564
|
+
while (isWhitespace(currentInput.charCodeAt(innerStart))) {
|
|
1565
|
+
innerStart++;
|
|
1566
|
+
}
|
|
1567
|
+
while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
|
|
1568
|
+
innerEnd--;
|
|
1569
|
+
}
|
|
1570
|
+
let exp = getSlice(innerStart, innerEnd);
|
|
1571
|
+
if (exp.includes("&")) {
|
|
1572
|
+
{
|
|
1573
|
+
exp = currentOptions.decodeEntities(exp, false);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
addNode({
|
|
1577
|
+
type: 5,
|
|
1578
|
+
content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
|
|
1579
|
+
loc: getLoc(start, end)
|
|
1580
|
+
});
|
|
1581
|
+
},
|
|
1582
|
+
onopentagname(start, end) {
|
|
1583
|
+
const name = getSlice(start, end);
|
|
1584
|
+
currentOpenTag = {
|
|
1585
|
+
type: 1,
|
|
1586
|
+
tag: name,
|
|
1587
|
+
ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
|
1588
|
+
tagType: 0,
|
|
1589
|
+
// will be refined on tag close
|
|
1590
|
+
props: [],
|
|
1591
|
+
children: [],
|
|
1592
|
+
loc: getLoc(start - 1, end),
|
|
1593
|
+
codegenNode: void 0
|
|
1594
|
+
};
|
|
1595
|
+
if (tokenizer.inSFCRoot) {
|
|
1596
|
+
currentOpenTag.innerLoc = getLoc(
|
|
1597
|
+
end + fastForward(end) + 1,
|
|
1598
|
+
end
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
onopentagend(end) {
|
|
1603
|
+
endOpenTag(end);
|
|
1604
|
+
},
|
|
1605
|
+
onclosetag(start, end) {
|
|
1606
|
+
const name = getSlice(start, end);
|
|
1607
|
+
if (!currentOptions.isVoidTag(name)) {
|
|
1608
|
+
let found = false;
|
|
1609
|
+
for (let i = 0; i < stack.length; i++) {
|
|
1610
|
+
const e = stack[i];
|
|
1611
|
+
if (e.tag.toLowerCase() === name.toLowerCase()) {
|
|
1612
|
+
found = true;
|
|
1613
|
+
if (i > 0) {
|
|
1614
|
+
emitError(24, stack[0].loc.start.offset);
|
|
807
1615
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
} else if (s[2] === ">") {
|
|
812
|
-
emitError(context, 14, 2);
|
|
813
|
-
advanceBy(context, 3);
|
|
814
|
-
continue;
|
|
815
|
-
} else if (/[a-z]/i.test(s[2])) {
|
|
816
|
-
emitError(context, 23);
|
|
817
|
-
parseTag(context, 1 /* End */, parent);
|
|
818
|
-
continue;
|
|
819
|
-
} else {
|
|
820
|
-
emitError(
|
|
821
|
-
context,
|
|
822
|
-
12,
|
|
823
|
-
2
|
|
824
|
-
);
|
|
825
|
-
node = parseBogusComment(context);
|
|
1616
|
+
for (let j = 0; j <= i; j++) {
|
|
1617
|
+
const el = stack.shift();
|
|
1618
|
+
onCloseTag(el, end, j < i);
|
|
826
1619
|
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1620
|
+
break;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
if (!found) {
|
|
1624
|
+
emitError(23, backTrack(start, 60));
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
onselfclosingtag(end) {
|
|
1629
|
+
var _a;
|
|
1630
|
+
const name = currentOpenTag.tag;
|
|
1631
|
+
currentOpenTag.isSelfClosing = true;
|
|
1632
|
+
endOpenTag(end);
|
|
1633
|
+
if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
|
|
1634
|
+
onCloseTag(stack.shift(), end);
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
onattribname(start, end) {
|
|
1638
|
+
currentProp = {
|
|
1639
|
+
type: 6,
|
|
1640
|
+
name: getSlice(start, end),
|
|
1641
|
+
nameLoc: getLoc(start, end),
|
|
1642
|
+
value: void 0,
|
|
1643
|
+
loc: getLoc(start)
|
|
1644
|
+
};
|
|
1645
|
+
},
|
|
1646
|
+
ondirname(start, end) {
|
|
1647
|
+
const raw = getSlice(start, end);
|
|
1648
|
+
const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
|
1649
|
+
if (!inVPre && name === "") {
|
|
1650
|
+
emitError(26, start);
|
|
1651
|
+
}
|
|
1652
|
+
if (inVPre || name === "") {
|
|
1653
|
+
currentProp = {
|
|
1654
|
+
type: 6,
|
|
1655
|
+
name: raw,
|
|
1656
|
+
nameLoc: getLoc(start, end),
|
|
1657
|
+
value: void 0,
|
|
1658
|
+
loc: getLoc(start)
|
|
1659
|
+
};
|
|
1660
|
+
} else {
|
|
1661
|
+
currentProp = {
|
|
1662
|
+
type: 7,
|
|
1663
|
+
name,
|
|
1664
|
+
rawName: raw,
|
|
1665
|
+
exp: void 0,
|
|
1666
|
+
arg: void 0,
|
|
1667
|
+
modifiers: raw === "." ? ["prop"] : [],
|
|
1668
|
+
loc: getLoc(start)
|
|
1669
|
+
};
|
|
1670
|
+
if (name === "pre") {
|
|
1671
|
+
inVPre = true;
|
|
1672
|
+
currentVPreBoundary = currentOpenTag;
|
|
1673
|
+
const props = currentOpenTag.props;
|
|
1674
|
+
for (let i = 0; i < props.length; i++) {
|
|
1675
|
+
if (props[i].type === 7) {
|
|
1676
|
+
props[i] = dirToAttr(props[i]);
|
|
841
1677
|
}
|
|
842
|
-
} else if (s[1] === "?") {
|
|
843
|
-
emitError(
|
|
844
|
-
context,
|
|
845
|
-
21,
|
|
846
|
-
1
|
|
847
|
-
);
|
|
848
|
-
node = parseBogusComment(context);
|
|
849
|
-
} else {
|
|
850
|
-
emitError(context, 12, 1);
|
|
851
1678
|
}
|
|
852
1679
|
}
|
|
853
1680
|
}
|
|
854
|
-
|
|
855
|
-
|
|
1681
|
+
},
|
|
1682
|
+
ondirarg(start, end) {
|
|
1683
|
+
const arg = getSlice(start, end);
|
|
1684
|
+
if (inVPre) {
|
|
1685
|
+
currentProp.name += arg;
|
|
1686
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1687
|
+
} else {
|
|
1688
|
+
const isStatic = arg[0] !== `[`;
|
|
1689
|
+
currentProp.arg = createSimpleExpression(
|
|
1690
|
+
isStatic ? arg : arg.slice(1, -1),
|
|
1691
|
+
isStatic,
|
|
1692
|
+
getLoc(start, end),
|
|
1693
|
+
isStatic ? 3 : 0
|
|
1694
|
+
);
|
|
856
1695
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
1696
|
+
},
|
|
1697
|
+
ondirmodifier(start, end) {
|
|
1698
|
+
const mod = getSlice(start, end);
|
|
1699
|
+
if (inVPre) {
|
|
1700
|
+
currentProp.name += "." + mod;
|
|
1701
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1702
|
+
} else if (currentProp.name === "slot") {
|
|
1703
|
+
const arg = currentProp.arg;
|
|
1704
|
+
if (arg) {
|
|
1705
|
+
arg.content += "." + mod;
|
|
1706
|
+
setLocEnd(arg.loc, end);
|
|
860
1707
|
}
|
|
861
1708
|
} else {
|
|
862
|
-
|
|
1709
|
+
currentProp.modifiers.push(mod);
|
|
863
1710
|
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1711
|
+
},
|
|
1712
|
+
onattribdata(start, end) {
|
|
1713
|
+
currentAttrValue += getSlice(start, end);
|
|
1714
|
+
if (currentAttrStartIndex < 0)
|
|
1715
|
+
currentAttrStartIndex = start;
|
|
1716
|
+
currentAttrEndIndex = end;
|
|
1717
|
+
},
|
|
1718
|
+
onattribentity(char, start, end) {
|
|
1719
|
+
currentAttrValue += char;
|
|
1720
|
+
if (currentAttrStartIndex < 0)
|
|
1721
|
+
currentAttrStartIndex = start;
|
|
1722
|
+
currentAttrEndIndex = end;
|
|
1723
|
+
},
|
|
1724
|
+
onattribnameend(end) {
|
|
1725
|
+
const start = currentProp.loc.start.offset;
|
|
1726
|
+
const name = getSlice(start, end);
|
|
1727
|
+
if (currentProp.type === 7) {
|
|
1728
|
+
currentProp.rawName = name;
|
|
1729
|
+
}
|
|
1730
|
+
if (currentOpenTag.props.some(
|
|
1731
|
+
(p) => (p.type === 7 ? p.rawName : p.name) === name
|
|
1732
|
+
)) {
|
|
1733
|
+
emitError(2, start);
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
onattribend(quote, end) {
|
|
1737
|
+
if (currentOpenTag && currentProp) {
|
|
1738
|
+
setLocEnd(currentProp.loc, end);
|
|
1739
|
+
if (quote !== 0) {
|
|
1740
|
+
if (currentAttrValue.includes("&")) {
|
|
1741
|
+
currentAttrValue = currentOptions.decodeEntities(
|
|
1742
|
+
currentAttrValue,
|
|
1743
|
+
true
|
|
1744
|
+
);
|
|
1745
|
+
}
|
|
1746
|
+
if (currentProp.type === 6) {
|
|
1747
|
+
if (currentProp.name === "class") {
|
|
1748
|
+
currentAttrValue = condense(currentAttrValue).trim();
|
|
1749
|
+
}
|
|
1750
|
+
if (quote === 1 && !currentAttrValue) {
|
|
1751
|
+
emitError(13, end);
|
|
1752
|
+
}
|
|
1753
|
+
currentProp.value = {
|
|
1754
|
+
type: 2,
|
|
1755
|
+
content: currentAttrValue,
|
|
1756
|
+
loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
|
1757
|
+
};
|
|
1758
|
+
if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
|
1759
|
+
tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
883
1760
|
}
|
|
884
1761
|
} else {
|
|
885
|
-
|
|
1762
|
+
currentProp.exp = createSimpleExpression(
|
|
1763
|
+
currentAttrValue,
|
|
1764
|
+
false,
|
|
1765
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
1766
|
+
);
|
|
1767
|
+
if (currentProp.name === "for") {
|
|
1768
|
+
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
1769
|
+
}
|
|
1770
|
+
let syncIndex = -1;
|
|
1771
|
+
if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
|
|
1772
|
+
"COMPILER_V_BIND_SYNC",
|
|
1773
|
+
currentOptions,
|
|
1774
|
+
currentProp.loc,
|
|
1775
|
+
currentProp.rawName
|
|
1776
|
+
)) {
|
|
1777
|
+
currentProp.name = "model";
|
|
1778
|
+
currentProp.modifiers.splice(syncIndex, 1);
|
|
1779
|
+
}
|
|
886
1780
|
}
|
|
887
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
888
|
-
removedWhitespace = true;
|
|
889
|
-
nodes[i] = null;
|
|
890
1781
|
}
|
|
1782
|
+
if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
|
1783
|
+
currentOpenTag.props.push(currentProp);
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
currentAttrValue = "";
|
|
1787
|
+
currentAttrStartIndex = currentAttrEndIndex = -1;
|
|
1788
|
+
},
|
|
1789
|
+
oncomment(start, end) {
|
|
1790
|
+
if (currentOptions.comments) {
|
|
1791
|
+
addNode({
|
|
1792
|
+
type: 3,
|
|
1793
|
+
content: getSlice(start, end),
|
|
1794
|
+
loc: getLoc(start - 4, end + 3)
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
},
|
|
1798
|
+
onend() {
|
|
1799
|
+
const end = currentInput.length;
|
|
1800
|
+
if ((!!(process.env.NODE_ENV !== "production") || false) && tokenizer.state !== 1) {
|
|
1801
|
+
switch (tokenizer.state) {
|
|
1802
|
+
case 5:
|
|
1803
|
+
case 8:
|
|
1804
|
+
emitError(5, end);
|
|
1805
|
+
break;
|
|
1806
|
+
case 3:
|
|
1807
|
+
case 4:
|
|
1808
|
+
emitError(
|
|
1809
|
+
25,
|
|
1810
|
+
tokenizer.sectionStart
|
|
1811
|
+
);
|
|
1812
|
+
break;
|
|
1813
|
+
case 28:
|
|
1814
|
+
if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
|
1815
|
+
emitError(6, end);
|
|
1816
|
+
} else {
|
|
1817
|
+
emitError(7, end);
|
|
1818
|
+
}
|
|
1819
|
+
break;
|
|
1820
|
+
case 6:
|
|
1821
|
+
case 7:
|
|
1822
|
+
case 9:
|
|
1823
|
+
case 11:
|
|
1824
|
+
case 12:
|
|
1825
|
+
case 13:
|
|
1826
|
+
case 14:
|
|
1827
|
+
case 15:
|
|
1828
|
+
case 16:
|
|
1829
|
+
case 17:
|
|
1830
|
+
case 18:
|
|
1831
|
+
case 19:
|
|
1832
|
+
case 20:
|
|
1833
|
+
case 21:
|
|
1834
|
+
emitError(9, end);
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
for (let index = 0; index < stack.length; index++) {
|
|
1839
|
+
onCloseTag(stack[index], end - 1);
|
|
1840
|
+
emitError(24, stack[index].loc.start.offset);
|
|
1841
|
+
}
|
|
1842
|
+
},
|
|
1843
|
+
oncdata(start, end) {
|
|
1844
|
+
if (stack[0].ns !== 0) {
|
|
1845
|
+
onText(getSlice(start, end), start, end);
|
|
1846
|
+
} else {
|
|
1847
|
+
emitError(1, start - 9);
|
|
1848
|
+
}
|
|
1849
|
+
},
|
|
1850
|
+
onprocessinginstruction(start) {
|
|
1851
|
+
if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
1852
|
+
emitError(
|
|
1853
|
+
21,
|
|
1854
|
+
start - 1
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1859
|
+
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
|
1860
|
+
const stripParensRE = /^\(|\)$/g;
|
|
1861
|
+
function parseForExpression(input) {
|
|
1862
|
+
const loc = input.loc;
|
|
1863
|
+
const exp = input.content;
|
|
1864
|
+
const inMatch = exp.match(forAliasRE);
|
|
1865
|
+
if (!inMatch)
|
|
1866
|
+
return;
|
|
1867
|
+
const [, LHS, RHS] = inMatch;
|
|
1868
|
+
const createAliasExpression = (content, offset) => {
|
|
1869
|
+
const start = loc.start.offset + offset;
|
|
1870
|
+
const end = start + content.length;
|
|
1871
|
+
return createSimpleExpression(content, false, getLoc(start, end));
|
|
1872
|
+
};
|
|
1873
|
+
const result = {
|
|
1874
|
+
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
1875
|
+
value: void 0,
|
|
1876
|
+
key: void 0,
|
|
1877
|
+
index: void 0,
|
|
1878
|
+
finalized: false
|
|
1879
|
+
};
|
|
1880
|
+
let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
|
1881
|
+
const trimmedOffset = LHS.indexOf(valueContent);
|
|
1882
|
+
const iteratorMatch = valueContent.match(forIteratorRE);
|
|
1883
|
+
if (iteratorMatch) {
|
|
1884
|
+
valueContent = valueContent.replace(forIteratorRE, "").trim();
|
|
1885
|
+
const keyContent = iteratorMatch[1].trim();
|
|
1886
|
+
let keyOffset;
|
|
1887
|
+
if (keyContent) {
|
|
1888
|
+
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
1889
|
+
result.key = createAliasExpression(keyContent, keyOffset);
|
|
891
1890
|
}
|
|
892
|
-
if (
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
|
|
1891
|
+
if (iteratorMatch[2]) {
|
|
1892
|
+
const indexContent = iteratorMatch[2].trim();
|
|
1893
|
+
if (indexContent) {
|
|
1894
|
+
result.index = createAliasExpression(
|
|
1895
|
+
indexContent,
|
|
1896
|
+
exp.indexOf(
|
|
1897
|
+
indexContent,
|
|
1898
|
+
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
1899
|
+
)
|
|
1900
|
+
);
|
|
896
1901
|
}
|
|
897
1902
|
}
|
|
898
1903
|
}
|
|
899
|
-
|
|
1904
|
+
if (valueContent) {
|
|
1905
|
+
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
1906
|
+
}
|
|
1907
|
+
return result;
|
|
900
1908
|
}
|
|
901
|
-
function
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1909
|
+
function getSlice(start, end) {
|
|
1910
|
+
return currentInput.slice(start, end);
|
|
1911
|
+
}
|
|
1912
|
+
function endOpenTag(end) {
|
|
1913
|
+
addNode(currentOpenTag);
|
|
1914
|
+
const { tag, ns } = currentOpenTag;
|
|
1915
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
1916
|
+
inPre++;
|
|
1917
|
+
}
|
|
1918
|
+
if (currentOptions.isVoidTag(tag)) {
|
|
1919
|
+
onCloseTag(currentOpenTag, end);
|
|
1920
|
+
} else {
|
|
1921
|
+
stack.unshift(currentOpenTag);
|
|
1922
|
+
if (ns === 1 || ns === 2) {
|
|
1923
|
+
tokenizer.inXML = true;
|
|
909
1924
|
}
|
|
910
1925
|
}
|
|
911
|
-
|
|
1926
|
+
currentOpenTag = null;
|
|
912
1927
|
}
|
|
913
|
-
function
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1928
|
+
function onText(content, start, end) {
|
|
1929
|
+
var _a;
|
|
1930
|
+
{
|
|
1931
|
+
const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
|
1932
|
+
if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
|
1933
|
+
content = currentOptions.decodeEntities(content, false);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
const parent = stack[0] || currentRoot;
|
|
1937
|
+
const lastNode = parent.children[parent.children.length - 1];
|
|
1938
|
+
if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
|
1939
|
+
lastNode.content += content;
|
|
1940
|
+
setLocEnd(lastNode.loc, end);
|
|
918
1941
|
} else {
|
|
919
|
-
|
|
1942
|
+
parent.children.push({
|
|
1943
|
+
type: 2,
|
|
1944
|
+
content,
|
|
1945
|
+
loc: getLoc(start, end)
|
|
1946
|
+
});
|
|
920
1947
|
}
|
|
921
|
-
return nodes;
|
|
922
1948
|
}
|
|
923
|
-
function
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
const match = /--(\!)?>/.exec(context.source);
|
|
927
|
-
if (!match) {
|
|
928
|
-
content = context.source.slice(4);
|
|
929
|
-
advanceBy(context, context.source.length);
|
|
930
|
-
emitError(context, 7);
|
|
1949
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
1950
|
+
if (isImplied) {
|
|
1951
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
931
1952
|
} else {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
if (
|
|
936
|
-
|
|
1953
|
+
setLocEnd(el.loc, end + fastForward(end) + 1);
|
|
1954
|
+
}
|
|
1955
|
+
if (tokenizer.inSFCRoot) {
|
|
1956
|
+
if (el.children.length) {
|
|
1957
|
+
el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
|
1958
|
+
} else {
|
|
1959
|
+
el.innerLoc.end = extend({}, el.innerLoc.start);
|
|
937
1960
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1961
|
+
el.innerLoc.source = getSlice(
|
|
1962
|
+
el.innerLoc.start.offset,
|
|
1963
|
+
el.innerLoc.end.offset
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
const { tag, ns } = el;
|
|
1967
|
+
if (!inVPre) {
|
|
1968
|
+
if (tag === "slot") {
|
|
1969
|
+
el.tagType = 2;
|
|
1970
|
+
} else if (isFragmentTemplate(el)) {
|
|
1971
|
+
el.tagType = 3;
|
|
1972
|
+
} else if (isComponent(el)) {
|
|
1973
|
+
el.tagType = 1;
|
|
947
1974
|
}
|
|
948
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
949
1975
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
content = context.source.slice(contentStart);
|
|
963
|
-
advanceBy(context, context.source.length);
|
|
964
|
-
} else {
|
|
965
|
-
content = context.source.slice(contentStart, closeIndex);
|
|
966
|
-
advanceBy(context, closeIndex + 1);
|
|
1976
|
+
if (!tokenizer.inRCDATA) {
|
|
1977
|
+
el.children = condenseWhitespace(el.children, el.tag);
|
|
1978
|
+
}
|
|
1979
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
1980
|
+
inPre--;
|
|
1981
|
+
}
|
|
1982
|
+
if (currentVPreBoundary === el) {
|
|
1983
|
+
inVPre = false;
|
|
1984
|
+
currentVPreBoundary = null;
|
|
1985
|
+
}
|
|
1986
|
+
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
1987
|
+
tokenizer.inXML = false;
|
|
967
1988
|
}
|
|
968
|
-
return {
|
|
969
|
-
type: 3,
|
|
970
|
-
content,
|
|
971
|
-
loc: getSelection(context, start)
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
function parseElement(context, ancestors) {
|
|
975
|
-
const wasInPre = context.inPre;
|
|
976
|
-
const wasInVPre = context.inVPre;
|
|
977
|
-
const parent = last(ancestors);
|
|
978
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
979
|
-
const isPreBoundary = context.inPre && !wasInPre;
|
|
980
|
-
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
981
|
-
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
982
|
-
if (isPreBoundary) {
|
|
983
|
-
context.inPre = false;
|
|
984
|
-
}
|
|
985
|
-
if (isVPreBoundary) {
|
|
986
|
-
context.inVPre = false;
|
|
987
|
-
}
|
|
988
|
-
return element;
|
|
989
|
-
}
|
|
990
|
-
ancestors.push(element);
|
|
991
|
-
const mode = context.options.getTextMode(element, parent);
|
|
992
|
-
const children = parseChildren(context, mode, ancestors);
|
|
993
|
-
ancestors.pop();
|
|
994
1989
|
{
|
|
995
|
-
const
|
|
1990
|
+
const props = el.props;
|
|
1991
|
+
if (!!(process.env.NODE_ENV !== "production") && isCompatEnabled(
|
|
1992
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1993
|
+
currentOptions
|
|
1994
|
+
)) {
|
|
1995
|
+
let hasIf = false;
|
|
1996
|
+
let hasFor = false;
|
|
1997
|
+
for (let i = 0; i < props.length; i++) {
|
|
1998
|
+
const p = props[i];
|
|
1999
|
+
if (p.type === 7) {
|
|
2000
|
+
if (p.name === "if") {
|
|
2001
|
+
hasIf = true;
|
|
2002
|
+
} else if (p.name === "for") {
|
|
2003
|
+
hasFor = true;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
if (hasIf && hasFor) {
|
|
2007
|
+
warnDeprecation(
|
|
2008
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2009
|
+
currentOptions,
|
|
2010
|
+
el.loc
|
|
2011
|
+
);
|
|
2012
|
+
break;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
if (isCompatEnabled(
|
|
2017
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2018
|
+
currentOptions
|
|
2019
|
+
) && el.tag === "template" && !isFragmentTemplate(el)) {
|
|
2020
|
+
!!(process.env.NODE_ENV !== "production") && warnDeprecation(
|
|
2021
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2022
|
+
currentOptions,
|
|
2023
|
+
el.loc
|
|
2024
|
+
);
|
|
2025
|
+
const parent = stack[0] || currentRoot;
|
|
2026
|
+
const index = parent.children.indexOf(el);
|
|
2027
|
+
parent.children.splice(index, 1, ...el.children);
|
|
2028
|
+
}
|
|
2029
|
+
const inlineTemplateProp = props.find(
|
|
996
2030
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
997
2031
|
);
|
|
998
2032
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
999
2033
|
"COMPILER_INLINE_TEMPLATE",
|
|
1000
|
-
|
|
2034
|
+
currentOptions,
|
|
1001
2035
|
inlineTemplateProp.loc
|
|
1002
|
-
)) {
|
|
1003
|
-
const loc = getSelection(context, element.loc.end);
|
|
2036
|
+
) && el.children.length) {
|
|
1004
2037
|
inlineTemplateProp.value = {
|
|
1005
2038
|
type: 2,
|
|
1006
|
-
content:
|
|
1007
|
-
|
|
2039
|
+
content: getSlice(
|
|
2040
|
+
el.children[0].loc.start.offset,
|
|
2041
|
+
el.children[el.children.length - 1].loc.end.offset
|
|
2042
|
+
),
|
|
2043
|
+
loc: inlineTemplateProp.loc
|
|
1008
2044
|
};
|
|
1009
2045
|
}
|
|
1010
2046
|
}
|
|
1011
|
-
element.children = children;
|
|
1012
|
-
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1013
|
-
parseTag(context, 1 /* End */, parent);
|
|
1014
|
-
} else {
|
|
1015
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1016
|
-
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1017
|
-
const first = children[0];
|
|
1018
|
-
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1019
|
-
emitError(context, 8);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
element.loc = getSelection(context, element.loc.start);
|
|
1024
|
-
if (isPreBoundary) {
|
|
1025
|
-
context.inPre = false;
|
|
1026
|
-
}
|
|
1027
|
-
if (isVPreBoundary) {
|
|
1028
|
-
context.inVPre = false;
|
|
1029
|
-
}
|
|
1030
|
-
return element;
|
|
1031
2047
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
)
|
|
1035
|
-
|
|
1036
|
-
const start = getCursor(context);
|
|
1037
|
-
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
|
1038
|
-
const tag = match[1];
|
|
1039
|
-
const ns = context.options.getNamespace(tag, parent);
|
|
1040
|
-
advanceBy(context, match[0].length);
|
|
1041
|
-
advanceSpaces(context);
|
|
1042
|
-
const cursor = getCursor(context);
|
|
1043
|
-
const currentSource = context.source;
|
|
1044
|
-
if (context.options.isPreTag(tag)) {
|
|
1045
|
-
context.inPre = true;
|
|
1046
|
-
}
|
|
1047
|
-
let props = parseAttributes(context, type);
|
|
1048
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1049
|
-
context.inVPre = true;
|
|
1050
|
-
extend(context, cursor);
|
|
1051
|
-
context.source = currentSource;
|
|
1052
|
-
props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
|
|
1053
|
-
}
|
|
1054
|
-
let isSelfClosing = false;
|
|
1055
|
-
if (context.source.length === 0) {
|
|
1056
|
-
emitError(context, 9);
|
|
1057
|
-
} else {
|
|
1058
|
-
isSelfClosing = startsWith(context.source, "/>");
|
|
1059
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1060
|
-
emitError(context, 4);
|
|
1061
|
-
}
|
|
1062
|
-
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1063
|
-
}
|
|
1064
|
-
if (type === 1 /* End */) {
|
|
1065
|
-
return;
|
|
2048
|
+
function fastForward(start, c) {
|
|
2049
|
+
let offset = 0;
|
|
2050
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2051
|
+
offset++;
|
|
1066
2052
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
2053
|
+
return offset;
|
|
2054
|
+
}
|
|
2055
|
+
function backTrack(index, c) {
|
|
2056
|
+
let i = index;
|
|
2057
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2058
|
+
i--;
|
|
2059
|
+
return i;
|
|
2060
|
+
}
|
|
2061
|
+
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
2062
|
+
function isFragmentTemplate({ tag, props }) {
|
|
2063
|
+
if (tag === "template") {
|
|
1073
2064
|
for (let i = 0; i < props.length; i++) {
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
if (p.name === "if") {
|
|
1077
|
-
hasIf = true;
|
|
1078
|
-
} else if (p.name === "for") {
|
|
1079
|
-
hasFor = true;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
if (hasIf && hasFor) {
|
|
1083
|
-
warnDeprecation(
|
|
1084
|
-
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1085
|
-
context,
|
|
1086
|
-
getSelection(context, start)
|
|
1087
|
-
);
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
let tagType = 0;
|
|
1093
|
-
if (!context.inVPre) {
|
|
1094
|
-
if (tag === "slot") {
|
|
1095
|
-
tagType = 2;
|
|
1096
|
-
} else if (tag === "template") {
|
|
1097
|
-
if (props.some(
|
|
1098
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1099
|
-
)) {
|
|
1100
|
-
tagType = 3;
|
|
2065
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2066
|
+
return true;
|
|
1101
2067
|
}
|
|
1102
|
-
} else if (isComponent(tag, props, context)) {
|
|
1103
|
-
tagType = 1;
|
|
1104
2068
|
}
|
|
1105
2069
|
}
|
|
1106
|
-
return
|
|
1107
|
-
type: 1,
|
|
1108
|
-
ns,
|
|
1109
|
-
tag,
|
|
1110
|
-
tagType,
|
|
1111
|
-
props,
|
|
1112
|
-
isSelfClosing,
|
|
1113
|
-
children: [],
|
|
1114
|
-
loc: getSelection(context, start),
|
|
1115
|
-
codegenNode: void 0
|
|
1116
|
-
// to be created during transform phase
|
|
1117
|
-
};
|
|
2070
|
+
return false;
|
|
1118
2071
|
}
|
|
1119
|
-
function isComponent(tag, props
|
|
1120
|
-
|
|
1121
|
-
if (
|
|
2072
|
+
function isComponent({ tag, props }) {
|
|
2073
|
+
var _a;
|
|
2074
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1122
2075
|
return false;
|
|
1123
2076
|
}
|
|
1124
|
-
if (tag === "component" ||
|
|
2077
|
+
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
|
1125
2078
|
return true;
|
|
1126
2079
|
}
|
|
1127
2080
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1132,374 +2085,179 @@ function isComponent(tag, props, context) {
|
|
|
1132
2085
|
return true;
|
|
1133
2086
|
} else if (checkCompatEnabled(
|
|
1134
2087
|
"COMPILER_IS_ON_ELEMENT",
|
|
1135
|
-
|
|
2088
|
+
currentOptions,
|
|
1136
2089
|
p.loc
|
|
1137
2090
|
)) {
|
|
1138
2091
|
return true;
|
|
1139
2092
|
}
|
|
1140
2093
|
}
|
|
1141
|
-
} else
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
context,
|
|
1149
|
-
p.loc
|
|
1150
|
-
)
|
|
1151
|
-
) {
|
|
1152
|
-
return true;
|
|
1153
|
-
}
|
|
2094
|
+
} else if (// :is on plain element - only treat as component in compat mode
|
|
2095
|
+
p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
|
|
2096
|
+
"COMPILER_IS_ON_ELEMENT",
|
|
2097
|
+
currentOptions,
|
|
2098
|
+
p.loc
|
|
2099
|
+
)) {
|
|
2100
|
+
return true;
|
|
1154
2101
|
}
|
|
1155
2102
|
}
|
|
2103
|
+
return false;
|
|
1156
2104
|
}
|
|
1157
|
-
function
|
|
1158
|
-
|
|
1159
|
-
const attributeNames = /* @__PURE__ */ new Set();
|
|
1160
|
-
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1161
|
-
if (startsWith(context.source, "/")) {
|
|
1162
|
-
emitError(context, 22);
|
|
1163
|
-
advanceBy(context, 1);
|
|
1164
|
-
advanceSpaces(context);
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
if (type === 1 /* End */) {
|
|
1168
|
-
emitError(context, 3);
|
|
1169
|
-
}
|
|
1170
|
-
const attr = parseAttribute(context, attributeNames);
|
|
1171
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1172
|
-
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1173
|
-
}
|
|
1174
|
-
if (type === 0 /* Start */) {
|
|
1175
|
-
props.push(attr);
|
|
1176
|
-
}
|
|
1177
|
-
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1178
|
-
emitError(context, 15);
|
|
1179
|
-
}
|
|
1180
|
-
advanceSpaces(context);
|
|
1181
|
-
}
|
|
1182
|
-
return props;
|
|
2105
|
+
function isUpperCase(c) {
|
|
2106
|
+
return c > 64 && c < 91;
|
|
1183
2107
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
);
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
advanceBy(context, name.length);
|
|
1208
|
-
let value = void 0;
|
|
1209
|
-
if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
|
1210
|
-
advanceSpaces(context);
|
|
1211
|
-
advanceBy(context, 1);
|
|
1212
|
-
advanceSpaces(context);
|
|
1213
|
-
value = parseAttributeValue(context);
|
|
1214
|
-
if (!value) {
|
|
1215
|
-
emitError(context, 13);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
const loc = getSelection(context, start);
|
|
1219
|
-
if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
|
1220
|
-
const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
|
|
1221
|
-
name
|
|
1222
|
-
);
|
|
1223
|
-
let isPropShorthand = startsWith(name, ".");
|
|
1224
|
-
let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
|
|
1225
|
-
let arg;
|
|
1226
|
-
if (match2[2]) {
|
|
1227
|
-
const isSlot = dirName === "slot";
|
|
1228
|
-
const startOffset = name.lastIndexOf(
|
|
1229
|
-
match2[2],
|
|
1230
|
-
name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
|
|
1231
|
-
);
|
|
1232
|
-
const loc2 = getSelection(
|
|
1233
|
-
context,
|
|
1234
|
-
getNewPosition(context, start, startOffset),
|
|
1235
|
-
getNewPosition(
|
|
1236
|
-
context,
|
|
1237
|
-
start,
|
|
1238
|
-
startOffset + match2[2].length + (isSlot && match2[3] || "").length
|
|
1239
|
-
)
|
|
1240
|
-
);
|
|
1241
|
-
let content = match2[2];
|
|
1242
|
-
let isStatic = true;
|
|
1243
|
-
if (content.startsWith("[")) {
|
|
1244
|
-
isStatic = false;
|
|
1245
|
-
if (!content.endsWith("]")) {
|
|
1246
|
-
emitError(
|
|
1247
|
-
context,
|
|
1248
|
-
27
|
|
1249
|
-
);
|
|
1250
|
-
content = content.slice(1);
|
|
1251
|
-
} else {
|
|
1252
|
-
content = content.slice(1, content.length - 1);
|
|
2108
|
+
const windowsNewlineRE = /\r\n/g;
|
|
2109
|
+
function condenseWhitespace(nodes, tag) {
|
|
2110
|
+
var _a, _b;
|
|
2111
|
+
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2112
|
+
let removedWhitespace = false;
|
|
2113
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2114
|
+
const node = nodes[i];
|
|
2115
|
+
if (node.type === 2) {
|
|
2116
|
+
if (!inPre) {
|
|
2117
|
+
if (isAllWhitespace(node.content)) {
|
|
2118
|
+
const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
|
2119
|
+
const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
|
2120
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2121
|
+
removedWhitespace = true;
|
|
2122
|
+
nodes[i] = null;
|
|
2123
|
+
} else {
|
|
2124
|
+
node.content = " ";
|
|
2125
|
+
}
|
|
2126
|
+
} else if (shouldCondense) {
|
|
2127
|
+
node.content = condense(node.content);
|
|
1253
2128
|
}
|
|
1254
|
-
} else
|
|
1255
|
-
content
|
|
1256
|
-
}
|
|
1257
|
-
arg = {
|
|
1258
|
-
type: 4,
|
|
1259
|
-
content,
|
|
1260
|
-
isStatic,
|
|
1261
|
-
constType: isStatic ? 3 : 0,
|
|
1262
|
-
loc: loc2
|
|
1263
|
-
};
|
|
1264
|
-
}
|
|
1265
|
-
if (value && value.isQuoted) {
|
|
1266
|
-
const valueLoc = value.loc;
|
|
1267
|
-
valueLoc.start.offset++;
|
|
1268
|
-
valueLoc.start.column++;
|
|
1269
|
-
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1270
|
-
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1271
|
-
}
|
|
1272
|
-
const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
|
|
1273
|
-
if (isPropShorthand)
|
|
1274
|
-
modifiers.push("prop");
|
|
1275
|
-
if (dirName === "bind" && arg) {
|
|
1276
|
-
if (modifiers.includes("sync") && checkCompatEnabled(
|
|
1277
|
-
"COMPILER_V_BIND_SYNC",
|
|
1278
|
-
context,
|
|
1279
|
-
loc,
|
|
1280
|
-
arg.loc.source
|
|
1281
|
-
)) {
|
|
1282
|
-
dirName = "model";
|
|
1283
|
-
modifiers.splice(modifiers.indexOf("sync"), 1);
|
|
1284
|
-
}
|
|
1285
|
-
if (!!(process.env.NODE_ENV !== "production") && modifiers.includes("prop")) {
|
|
1286
|
-
checkCompatEnabled(
|
|
1287
|
-
"COMPILER_V_BIND_PROP",
|
|
1288
|
-
context,
|
|
1289
|
-
loc
|
|
1290
|
-
);
|
|
2129
|
+
} else {
|
|
2130
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1291
2131
|
}
|
|
1292
2132
|
}
|
|
1293
|
-
return {
|
|
1294
|
-
type: 7,
|
|
1295
|
-
name: dirName,
|
|
1296
|
-
exp: value && {
|
|
1297
|
-
type: 4,
|
|
1298
|
-
content: value.content,
|
|
1299
|
-
isStatic: false,
|
|
1300
|
-
// Treat as non-constant by default. This can be potentially set to
|
|
1301
|
-
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1302
|
-
constType: 0,
|
|
1303
|
-
loc: value.loc
|
|
1304
|
-
},
|
|
1305
|
-
arg,
|
|
1306
|
-
modifiers,
|
|
1307
|
-
loc
|
|
1308
|
-
};
|
|
1309
2133
|
}
|
|
1310
|
-
if (
|
|
1311
|
-
|
|
2134
|
+
if (inPre && tag && currentOptions.isPreTag(tag)) {
|
|
2135
|
+
const first = nodes[0];
|
|
2136
|
+
if (first && first.type === 2) {
|
|
2137
|
+
first.content = first.content.replace(/^\r?\n/, "");
|
|
2138
|
+
}
|
|
1312
2139
|
}
|
|
1313
|
-
return
|
|
1314
|
-
type: 6,
|
|
1315
|
-
name,
|
|
1316
|
-
value: value && {
|
|
1317
|
-
type: 2,
|
|
1318
|
-
content: value.content,
|
|
1319
|
-
loc: value.loc
|
|
1320
|
-
},
|
|
1321
|
-
loc
|
|
1322
|
-
};
|
|
2140
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1323
2141
|
}
|
|
1324
|
-
function
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
const isQuoted = quote === `"` || quote === `'`;
|
|
1329
|
-
if (isQuoted) {
|
|
1330
|
-
advanceBy(context, 1);
|
|
1331
|
-
const endIndex = context.source.indexOf(quote);
|
|
1332
|
-
if (endIndex === -1) {
|
|
1333
|
-
content = parseTextData(
|
|
1334
|
-
context,
|
|
1335
|
-
context.source.length,
|
|
1336
|
-
4
|
|
1337
|
-
);
|
|
1338
|
-
} else {
|
|
1339
|
-
content = parseTextData(context, endIndex, 4);
|
|
1340
|
-
advanceBy(context, 1);
|
|
1341
|
-
}
|
|
1342
|
-
} else {
|
|
1343
|
-
const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
|
1344
|
-
if (!match) {
|
|
1345
|
-
return void 0;
|
|
1346
|
-
}
|
|
1347
|
-
const unexpectedChars = /["'<=`]/g;
|
|
1348
|
-
let m;
|
|
1349
|
-
while (m = unexpectedChars.exec(match[0])) {
|
|
1350
|
-
emitError(
|
|
1351
|
-
context,
|
|
1352
|
-
18,
|
|
1353
|
-
m.index
|
|
1354
|
-
);
|
|
2142
|
+
function isAllWhitespace(str) {
|
|
2143
|
+
for (let i = 0; i < str.length; i++) {
|
|
2144
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2145
|
+
return false;
|
|
1355
2146
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1359
|
-
}
|
|
1360
|
-
function parseInterpolation(context, mode) {
|
|
1361
|
-
const [open, close] = context.options.delimiters;
|
|
1362
|
-
const closeIndex = context.source.indexOf(close, open.length);
|
|
1363
|
-
if (closeIndex === -1) {
|
|
1364
|
-
emitError(context, 25);
|
|
1365
|
-
return void 0;
|
|
1366
|
-
}
|
|
1367
|
-
const start = getCursor(context);
|
|
1368
|
-
advanceBy(context, open.length);
|
|
1369
|
-
const innerStart = getCursor(context);
|
|
1370
|
-
const innerEnd = getCursor(context);
|
|
1371
|
-
const rawContentLength = closeIndex - open.length;
|
|
1372
|
-
const rawContent = context.source.slice(0, rawContentLength);
|
|
1373
|
-
const preTrimContent = parseTextData(context, rawContentLength, mode);
|
|
1374
|
-
const content = preTrimContent.trim();
|
|
1375
|
-
const startOffset = preTrimContent.indexOf(content);
|
|
1376
|
-
if (startOffset > 0) {
|
|
1377
|
-
advancePositionWithMutation(innerStart, rawContent, startOffset);
|
|
1378
|
-
}
|
|
1379
|
-
const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
|
1380
|
-
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1381
|
-
advanceBy(context, close.length);
|
|
1382
|
-
return {
|
|
1383
|
-
type: 5,
|
|
1384
|
-
content: {
|
|
1385
|
-
type: 4,
|
|
1386
|
-
isStatic: false,
|
|
1387
|
-
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1388
|
-
constType: 0,
|
|
1389
|
-
content,
|
|
1390
|
-
loc: getSelection(context, innerStart, innerEnd)
|
|
1391
|
-
},
|
|
1392
|
-
loc: getSelection(context, start)
|
|
1393
|
-
};
|
|
2147
|
+
}
|
|
2148
|
+
return true;
|
|
1394
2149
|
}
|
|
1395
|
-
function
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
if (index !== -1 && endIndex > index) {
|
|
1401
|
-
endIndex = index;
|
|
2150
|
+
function hasNewlineChar(str) {
|
|
2151
|
+
for (let i = 0; i < str.length; i++) {
|
|
2152
|
+
const c = str.charCodeAt(i);
|
|
2153
|
+
if (c === 10 || c === 13) {
|
|
2154
|
+
return true;
|
|
1402
2155
|
}
|
|
1403
2156
|
}
|
|
1404
|
-
|
|
1405
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1406
|
-
return {
|
|
1407
|
-
type: 2,
|
|
1408
|
-
content,
|
|
1409
|
-
loc: getSelection(context, start)
|
|
1410
|
-
};
|
|
2157
|
+
return false;
|
|
1411
2158
|
}
|
|
1412
|
-
function
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
2159
|
+
function condense(str) {
|
|
2160
|
+
let ret = "";
|
|
2161
|
+
let prevCharIsWhitespace = false;
|
|
2162
|
+
for (let i = 0; i < str.length; i++) {
|
|
2163
|
+
if (isWhitespace(str.charCodeAt(i))) {
|
|
2164
|
+
if (!prevCharIsWhitespace) {
|
|
2165
|
+
ret += " ";
|
|
2166
|
+
prevCharIsWhitespace = true;
|
|
2167
|
+
}
|
|
2168
|
+
} else {
|
|
2169
|
+
ret += str[i];
|
|
2170
|
+
prevCharIsWhitespace = false;
|
|
2171
|
+
}
|
|
1422
2172
|
}
|
|
2173
|
+
return ret;
|
|
1423
2174
|
}
|
|
1424
|
-
function
|
|
1425
|
-
|
|
1426
|
-
return { column, line, offset };
|
|
2175
|
+
function addNode(node) {
|
|
2176
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1427
2177
|
}
|
|
1428
|
-
function
|
|
1429
|
-
end = end || getCursor(context);
|
|
2178
|
+
function getLoc(start, end) {
|
|
1430
2179
|
return {
|
|
1431
|
-
start,
|
|
1432
|
-
|
|
1433
|
-
|
|
2180
|
+
start: tokenizer.getPos(start),
|
|
2181
|
+
// @ts-expect-error allow late attachment
|
|
2182
|
+
end: end == null ? end : tokenizer.getPos(end),
|
|
2183
|
+
// @ts-expect-error allow late attachment
|
|
2184
|
+
source: end == null ? end : getSlice(start, end)
|
|
1434
2185
|
};
|
|
1435
2186
|
}
|
|
1436
|
-
function
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
function startsWith(source, searchString) {
|
|
1440
|
-
return source.startsWith(searchString);
|
|
1441
|
-
}
|
|
1442
|
-
function advanceBy(context, numberOfCharacters) {
|
|
1443
|
-
const { source } = context;
|
|
1444
|
-
advancePositionWithMutation(context, source, numberOfCharacters);
|
|
1445
|
-
context.source = source.slice(numberOfCharacters);
|
|
1446
|
-
}
|
|
1447
|
-
function advanceSpaces(context) {
|
|
1448
|
-
const match = /^[\t\r\n\f ]+/.exec(context.source);
|
|
1449
|
-
if (match) {
|
|
1450
|
-
advanceBy(context, match[0].length);
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
function getNewPosition(context, start, numberOfCharacters) {
|
|
1454
|
-
return advancePositionWithClone(
|
|
1455
|
-
start,
|
|
1456
|
-
context.originalSource.slice(start.offset, numberOfCharacters),
|
|
1457
|
-
numberOfCharacters
|
|
1458
|
-
);
|
|
2187
|
+
function setLocEnd(loc, end) {
|
|
2188
|
+
loc.end = tokenizer.getPos(end);
|
|
2189
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1459
2190
|
}
|
|
1460
|
-
function
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
2191
|
+
function dirToAttr(dir) {
|
|
2192
|
+
const attr = {
|
|
2193
|
+
type: 6,
|
|
2194
|
+
name: dir.rawName,
|
|
2195
|
+
nameLoc: getLoc(
|
|
2196
|
+
dir.loc.start.offset,
|
|
2197
|
+
dir.loc.start.offset + dir.rawName.length
|
|
2198
|
+
),
|
|
2199
|
+
value: void 0,
|
|
2200
|
+
loc: dir.loc
|
|
2201
|
+
};
|
|
2202
|
+
if (dir.exp) {
|
|
2203
|
+
const loc = dir.exp.loc;
|
|
2204
|
+
if (loc.end.offset < dir.loc.end.offset) {
|
|
2205
|
+
loc.start.offset--;
|
|
2206
|
+
loc.start.column--;
|
|
2207
|
+
loc.end.offset++;
|
|
2208
|
+
loc.end.column++;
|
|
2209
|
+
}
|
|
2210
|
+
attr.value = {
|
|
2211
|
+
type: 2,
|
|
2212
|
+
content: dir.exp.content,
|
|
2213
|
+
loc
|
|
2214
|
+
};
|
|
1464
2215
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
);
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
2216
|
+
return attr;
|
|
2217
|
+
}
|
|
2218
|
+
function emitError(code, index) {
|
|
2219
|
+
currentOptions.onError(createCompilerError(code, getLoc(index, index)));
|
|
2220
|
+
}
|
|
2221
|
+
function reset() {
|
|
2222
|
+
tokenizer.reset();
|
|
2223
|
+
currentOpenTag = null;
|
|
2224
|
+
currentProp = null;
|
|
2225
|
+
currentAttrValue = "";
|
|
2226
|
+
currentAttrStartIndex = -1;
|
|
2227
|
+
currentAttrEndIndex = -1;
|
|
2228
|
+
stack.length = 0;
|
|
2229
|
+
}
|
|
2230
|
+
function baseParse(input, options) {
|
|
2231
|
+
reset();
|
|
2232
|
+
currentInput = input;
|
|
2233
|
+
currentOptions = extend({}, defaultParserOptions);
|
|
2234
|
+
if (options) {
|
|
2235
|
+
let key;
|
|
2236
|
+
for (key in options) {
|
|
2237
|
+
if (options[key] != null) {
|
|
2238
|
+
currentOptions[key] = options[key];
|
|
1483
2239
|
}
|
|
1484
|
-
break;
|
|
1485
|
-
case 1:
|
|
1486
|
-
case 2: {
|
|
1487
|
-
const parent = last(ancestors);
|
|
1488
|
-
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1489
|
-
return true;
|
|
1490
|
-
}
|
|
1491
|
-
break;
|
|
1492
2240
|
}
|
|
1493
|
-
case 3:
|
|
1494
|
-
if (startsWith(s, "]]>")) {
|
|
1495
|
-
return true;
|
|
1496
|
-
}
|
|
1497
|
-
break;
|
|
1498
2241
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
2242
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
2243
|
+
if (!currentOptions.decodeEntities) {
|
|
2244
|
+
throw new Error(
|
|
2245
|
+
`[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
|
2246
|
+
);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2250
|
+
const delimiters = options == null ? void 0 : options.delimiters;
|
|
2251
|
+
if (delimiters) {
|
|
2252
|
+
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2253
|
+
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
2254
|
+
}
|
|
2255
|
+
const root = currentRoot = createRoot([], input);
|
|
2256
|
+
tokenizer.parse(currentInput);
|
|
2257
|
+
root.loc = getLoc(0, input.length);
|
|
2258
|
+
root.children = condenseWhitespace(root.children);
|
|
2259
|
+
currentRoot = null;
|
|
2260
|
+
return root;
|
|
1503
2261
|
}
|
|
1504
2262
|
|
|
1505
2263
|
function hoistStatic(root, context) {
|
|
@@ -1912,6 +2670,7 @@ function transform(root, options) {
|
|
|
1912
2670
|
root.hoists = context.hoists;
|
|
1913
2671
|
root.temps = context.temps;
|
|
1914
2672
|
root.cached = context.cached;
|
|
2673
|
+
root.transformed = true;
|
|
1915
2674
|
{
|
|
1916
2675
|
root.filters = [...context.filters];
|
|
1917
2676
|
}
|
|
@@ -2068,7 +2827,7 @@ function createCodegenContext(ast, {
|
|
|
2068
2827
|
ssr,
|
|
2069
2828
|
isTS,
|
|
2070
2829
|
inSSR,
|
|
2071
|
-
source: ast.
|
|
2830
|
+
source: ast.source,
|
|
2072
2831
|
code: ``,
|
|
2073
2832
|
column: 1,
|
|
2074
2833
|
line: 1,
|
|
@@ -2079,7 +2838,7 @@ function createCodegenContext(ast, {
|
|
|
2079
2838
|
helper(key) {
|
|
2080
2839
|
return `_${helperNameMap[key]}`;
|
|
2081
2840
|
},
|
|
2082
|
-
push(code, node) {
|
|
2841
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2083
2842
|
context.code += code;
|
|
2084
2843
|
},
|
|
2085
2844
|
indent() {
|
|
@@ -2097,7 +2856,7 @@ function createCodegenContext(ast, {
|
|
|
2097
2856
|
}
|
|
2098
2857
|
};
|
|
2099
2858
|
function newline(n) {
|
|
2100
|
-
context.push("\n" + ` `.repeat(n));
|
|
2859
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2101
2860
|
}
|
|
2102
2861
|
return context;
|
|
2103
2862
|
}
|
|
@@ -2134,9 +2893,11 @@ function generate(ast, options = {}) {
|
|
|
2134
2893
|
push(`with (_ctx) {`);
|
|
2135
2894
|
indent();
|
|
2136
2895
|
if (hasHelpers) {
|
|
2137
|
-
push(
|
|
2138
|
-
|
|
2139
|
-
|
|
2896
|
+
push(
|
|
2897
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
2898
|
+
`,
|
|
2899
|
+
-1 /* End */
|
|
2900
|
+
);
|
|
2140
2901
|
newline();
|
|
2141
2902
|
}
|
|
2142
2903
|
}
|
|
@@ -2165,7 +2926,7 @@ function generate(ast, options = {}) {
|
|
|
2165
2926
|
}
|
|
2166
2927
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2167
2928
|
push(`
|
|
2168
|
-
|
|
2929
|
+
`, 0 /* Start */);
|
|
2169
2930
|
newline();
|
|
2170
2931
|
}
|
|
2171
2932
|
if (!ssr) {
|
|
@@ -2186,7 +2947,6 @@ function generate(ast, options = {}) {
|
|
|
2186
2947
|
ast,
|
|
2187
2948
|
code: context.code,
|
|
2188
2949
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2189
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2190
2950
|
map: context.map ? context.map.toJSON() : void 0
|
|
2191
2951
|
};
|
|
2192
2952
|
}
|
|
@@ -2205,7 +2965,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2205
2965
|
if (helpers.length > 0) {
|
|
2206
2966
|
{
|
|
2207
2967
|
push(`const _Vue = ${VueBinding}
|
|
2208
|
-
|
|
2968
|
+
`, -1 /* End */);
|
|
2209
2969
|
if (ast.hoists.length) {
|
|
2210
2970
|
const staticHelpers = [
|
|
2211
2971
|
CREATE_VNODE,
|
|
@@ -2215,7 +2975,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2215
2975
|
CREATE_STATIC
|
|
2216
2976
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2217
2977
|
push(`const { ${staticHelpers} } = _Vue
|
|
2218
|
-
|
|
2978
|
+
`, -1 /* End */);
|
|
2219
2979
|
}
|
|
2220
2980
|
}
|
|
2221
2981
|
}
|
|
@@ -2276,7 +3036,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2276
3036
|
for (let i = 0; i < nodes.length; i++) {
|
|
2277
3037
|
const node = nodes[i];
|
|
2278
3038
|
if (isString(node)) {
|
|
2279
|
-
push(node);
|
|
3039
|
+
push(node, -3 /* Unknown */);
|
|
2280
3040
|
} else if (isArray(node)) {
|
|
2281
3041
|
genNodeListAsArray(node, context);
|
|
2282
3042
|
} else {
|
|
@@ -2294,7 +3054,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2294
3054
|
}
|
|
2295
3055
|
function genNode(node, context) {
|
|
2296
3056
|
if (isString(node)) {
|
|
2297
|
-
context.push(node);
|
|
3057
|
+
context.push(node, -3 /* Unknown */);
|
|
2298
3058
|
return;
|
|
2299
3059
|
}
|
|
2300
3060
|
if (isSymbol(node)) {
|
|
@@ -2374,11 +3134,15 @@ function genNode(node, context) {
|
|
|
2374
3134
|
}
|
|
2375
3135
|
}
|
|
2376
3136
|
function genText(node, context) {
|
|
2377
|
-
context.push(JSON.stringify(node.content), node);
|
|
3137
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2378
3138
|
}
|
|
2379
3139
|
function genExpression(node, context) {
|
|
2380
3140
|
const { content, isStatic } = node;
|
|
2381
|
-
context.push(
|
|
3141
|
+
context.push(
|
|
3142
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3143
|
+
-3 /* Unknown */,
|
|
3144
|
+
node
|
|
3145
|
+
);
|
|
2382
3146
|
}
|
|
2383
3147
|
function genInterpolation(node, context) {
|
|
2384
3148
|
const { push, helper, pure } = context;
|
|
@@ -2392,7 +3156,7 @@ function genCompoundExpression(node, context) {
|
|
|
2392
3156
|
for (let i = 0; i < node.children.length; i++) {
|
|
2393
3157
|
const child = node.children[i];
|
|
2394
3158
|
if (isString(child)) {
|
|
2395
|
-
context.push(child);
|
|
3159
|
+
context.push(child, -3 /* Unknown */);
|
|
2396
3160
|
} else {
|
|
2397
3161
|
genNode(child, context);
|
|
2398
3162
|
}
|
|
@@ -2406,9 +3170,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
2406
3170
|
push(`]`);
|
|
2407
3171
|
} else if (node.isStatic) {
|
|
2408
3172
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2409
|
-
push(text, node);
|
|
3173
|
+
push(text, -2 /* None */, node);
|
|
2410
3174
|
} else {
|
|
2411
|
-
push(`[${node.content}]`, node);
|
|
3175
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2412
3176
|
}
|
|
2413
3177
|
}
|
|
2414
3178
|
function genComment(node, context) {
|
|
@@ -2416,7 +3180,11 @@ function genComment(node, context) {
|
|
|
2416
3180
|
if (pure) {
|
|
2417
3181
|
push(PURE_ANNOTATION);
|
|
2418
3182
|
}
|
|
2419
|
-
push(
|
|
3183
|
+
push(
|
|
3184
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3185
|
+
-3 /* Unknown */,
|
|
3186
|
+
node
|
|
3187
|
+
);
|
|
2420
3188
|
}
|
|
2421
3189
|
function genVNodeCall(node, context) {
|
|
2422
3190
|
const { push, helper, pure } = context;
|
|
@@ -2441,7 +3209,7 @@ function genVNodeCall(node, context) {
|
|
|
2441
3209
|
push(PURE_ANNOTATION);
|
|
2442
3210
|
}
|
|
2443
3211
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2444
|
-
push(helper(callHelper) + `(`, node);
|
|
3212
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2445
3213
|
genNodeList(
|
|
2446
3214
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2447
3215
|
context
|
|
@@ -2470,7 +3238,7 @@ function genCallExpression(node, context) {
|
|
|
2470
3238
|
if (pure) {
|
|
2471
3239
|
push(PURE_ANNOTATION);
|
|
2472
3240
|
}
|
|
2473
|
-
push(callee + `(`, node);
|
|
3241
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2474
3242
|
genNodeList(node.arguments, context);
|
|
2475
3243
|
push(`)`);
|
|
2476
3244
|
}
|
|
@@ -2478,7 +3246,7 @@ function genObjectExpression(node, context) {
|
|
|
2478
3246
|
const { push, indent, deindent, newline } = context;
|
|
2479
3247
|
const { properties } = node;
|
|
2480
3248
|
if (!properties.length) {
|
|
2481
|
-
push(`{}`, node);
|
|
3249
|
+
push(`{}`, -2 /* None */, node);
|
|
2482
3250
|
return;
|
|
2483
3251
|
}
|
|
2484
3252
|
const multilines = properties.length > 1 || !!(process.env.NODE_ENV !== "production") && properties.some((p) => p.value.type !== 4);
|
|
@@ -2506,7 +3274,7 @@ function genFunctionExpression(node, context) {
|
|
|
2506
3274
|
if (isSlot) {
|
|
2507
3275
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2508
3276
|
}
|
|
2509
|
-
push(`(`, node);
|
|
3277
|
+
push(`(`, -2 /* None */, node);
|
|
2510
3278
|
if (isArray(params)) {
|
|
2511
3279
|
genNodeList(params, context);
|
|
2512
3280
|
} else if (params) {
|
|
@@ -2860,7 +3628,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2860
3628
|
context.removeNode();
|
|
2861
3629
|
const branch = createIfBranch(node, dir);
|
|
2862
3630
|
if (!!(process.env.NODE_ENV !== "production") && comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2863
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3631
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2864
3632
|
branch.children = [...comments, ...branch.children];
|
|
2865
3633
|
}
|
|
2866
3634
|
if (!!(process.env.NODE_ENV !== "production") || false) {
|
|
@@ -3142,18 +3910,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3142
3910
|
);
|
|
3143
3911
|
return;
|
|
3144
3912
|
}
|
|
3145
|
-
const parseResult =
|
|
3146
|
-
// can only be simple expression because vFor transform is applied
|
|
3147
|
-
// before expression transform.
|
|
3148
|
-
dir.exp,
|
|
3149
|
-
context
|
|
3150
|
-
);
|
|
3913
|
+
const parseResult = dir.forParseResult;
|
|
3151
3914
|
if (!parseResult) {
|
|
3152
3915
|
context.onError(
|
|
3153
3916
|
createCompilerError(32, dir.loc)
|
|
3154
3917
|
);
|
|
3155
3918
|
return;
|
|
3156
3919
|
}
|
|
3920
|
+
finalizeForParseResult(parseResult, context);
|
|
3157
3921
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3158
3922
|
const { source, value, key, index } = parseResult;
|
|
3159
3923
|
const forNode = {
|
|
@@ -3175,70 +3939,26 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3175
3939
|
onExit();
|
|
3176
3940
|
};
|
|
3177
3941
|
}
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
function parseForExpression(input, context) {
|
|
3181
|
-
const loc = input.loc;
|
|
3182
|
-
const exp = input.content;
|
|
3183
|
-
const inMatch = exp.match(forAliasRE);
|
|
3184
|
-
if (!inMatch)
|
|
3942
|
+
function finalizeForParseResult(result, context) {
|
|
3943
|
+
if (result.finalized)
|
|
3185
3944
|
return;
|
|
3186
|
-
const [, LHS, RHS] = inMatch;
|
|
3187
|
-
const result = {
|
|
3188
|
-
source: createAliasExpression(
|
|
3189
|
-
loc,
|
|
3190
|
-
RHS.trim(),
|
|
3191
|
-
exp.indexOf(RHS, LHS.length)
|
|
3192
|
-
),
|
|
3193
|
-
value: void 0,
|
|
3194
|
-
key: void 0,
|
|
3195
|
-
index: void 0
|
|
3196
|
-
};
|
|
3197
3945
|
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3198
3946
|
validateBrowserExpression(result.source, context);
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
const keyContent = iteratorMatch[1].trim();
|
|
3206
|
-
let keyOffset;
|
|
3207
|
-
if (keyContent) {
|
|
3208
|
-
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
3209
|
-
result.key = createAliasExpression(loc, keyContent, keyOffset);
|
|
3210
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3211
|
-
validateBrowserExpression(
|
|
3212
|
-
result.key,
|
|
3213
|
-
context,
|
|
3214
|
-
true
|
|
3215
|
-
);
|
|
3216
|
-
}
|
|
3947
|
+
if (result.key) {
|
|
3948
|
+
validateBrowserExpression(
|
|
3949
|
+
result.key,
|
|
3950
|
+
context,
|
|
3951
|
+
true
|
|
3952
|
+
);
|
|
3217
3953
|
}
|
|
3218
|
-
if (
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
exp.indexOf(
|
|
3225
|
-
indexContent,
|
|
3226
|
-
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
3227
|
-
)
|
|
3228
|
-
);
|
|
3229
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3230
|
-
validateBrowserExpression(
|
|
3231
|
-
result.index,
|
|
3232
|
-
context,
|
|
3233
|
-
true
|
|
3234
|
-
);
|
|
3235
|
-
}
|
|
3236
|
-
}
|
|
3954
|
+
if (result.index) {
|
|
3955
|
+
validateBrowserExpression(
|
|
3956
|
+
result.index,
|
|
3957
|
+
context,
|
|
3958
|
+
true
|
|
3959
|
+
);
|
|
3237
3960
|
}
|
|
3238
|
-
|
|
3239
|
-
if (valueContent) {
|
|
3240
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3241
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3961
|
+
if (result.value) {
|
|
3242
3962
|
validateBrowserExpression(
|
|
3243
3963
|
result.value,
|
|
3244
3964
|
context,
|
|
@@ -3246,14 +3966,7 @@ function parseForExpression(input, context) {
|
|
|
3246
3966
|
);
|
|
3247
3967
|
}
|
|
3248
3968
|
}
|
|
3249
|
-
|
|
3250
|
-
}
|
|
3251
|
-
function createAliasExpression(range, content, offset) {
|
|
3252
|
-
return createSimpleExpression(
|
|
3253
|
-
content,
|
|
3254
|
-
false,
|
|
3255
|
-
getInnerRange(range, offset, content.length)
|
|
3256
|
-
);
|
|
3969
|
+
result.finalized = true;
|
|
3257
3970
|
}
|
|
3258
3971
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3259
3972
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3283,11 +3996,9 @@ const trackSlotScopes = (node, context) => {
|
|
|
3283
3996
|
const trackVForSlotScopes = (node, context) => {
|
|
3284
3997
|
let vFor;
|
|
3285
3998
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3286
|
-
const result = vFor.
|
|
3287
|
-
vFor.exp,
|
|
3288
|
-
context
|
|
3289
|
-
);
|
|
3999
|
+
const result = vFor.forParseResult;
|
|
3290
4000
|
if (result) {
|
|
4001
|
+
finalizeForParseResult(result, context);
|
|
3291
4002
|
const { value, key, index } = result;
|
|
3292
4003
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3293
4004
|
value && addIdentifiers(value);
|
|
@@ -3361,12 +4072,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3361
4072
|
hasDynamicSlots = true;
|
|
3362
4073
|
}
|
|
3363
4074
|
const vFor = findDir(slotElement, "for");
|
|
3364
|
-
const slotFunction = buildSlotFn(
|
|
3365
|
-
slotProps,
|
|
3366
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3367
|
-
slotChildren,
|
|
3368
|
-
slotLoc
|
|
3369
|
-
);
|
|
4075
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3370
4076
|
let vIf;
|
|
3371
4077
|
let vElse;
|
|
3372
4078
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3415,8 +4121,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3415
4121
|
}
|
|
3416
4122
|
} else if (vFor) {
|
|
3417
4123
|
hasDynamicSlots = true;
|
|
3418
|
-
const parseResult = vFor.
|
|
4124
|
+
const parseResult = vFor.forParseResult;
|
|
3419
4125
|
if (parseResult) {
|
|
4126
|
+
finalizeForParseResult(parseResult, context);
|
|
3420
4127
|
dynamicSlots.push(
|
|
3421
4128
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3422
4129
|
parseResult.source,
|
|
@@ -3679,17 +4386,6 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3679
4386
|
tag = isProp.value.content.slice(4);
|
|
3680
4387
|
}
|
|
3681
4388
|
}
|
|
3682
|
-
const isDir = !isExplicitDynamic && findDir(node, "is");
|
|
3683
|
-
if (isDir && isDir.exp) {
|
|
3684
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
3685
|
-
context.onWarn(
|
|
3686
|
-
createCompilerError(52, isDir.loc)
|
|
3687
|
-
);
|
|
3688
|
-
}
|
|
3689
|
-
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
3690
|
-
isDir.exp
|
|
3691
|
-
]);
|
|
3692
|
-
}
|
|
3693
4389
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3694
4390
|
if (builtIn) {
|
|
3695
4391
|
if (!ssr)
|
|
@@ -3761,7 +4457,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3761
4457
|
for (let i = 0; i < props.length; i++) {
|
|
3762
4458
|
const prop = props[i];
|
|
3763
4459
|
if (prop.type === 6) {
|
|
3764
|
-
const { loc, name, value } = prop;
|
|
4460
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3765
4461
|
let isStatic = true;
|
|
3766
4462
|
if (name === "ref") {
|
|
3767
4463
|
hasRef = true;
|
|
@@ -3782,11 +4478,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3782
4478
|
}
|
|
3783
4479
|
properties.push(
|
|
3784
4480
|
createObjectProperty(
|
|
3785
|
-
createSimpleExpression(
|
|
3786
|
-
name,
|
|
3787
|
-
true,
|
|
3788
|
-
getInnerRange(loc, 0, name.length)
|
|
3789
|
-
),
|
|
4481
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3790
4482
|
createSimpleExpression(
|
|
3791
4483
|
value ? value.content : "",
|
|
3792
4484
|
isStatic,
|
|
@@ -4268,8 +4960,13 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4268
4960
|
};
|
|
4269
4961
|
|
|
4270
4962
|
const transformBind = (dir, _node, context) => {
|
|
4271
|
-
const {
|
|
4963
|
+
const { modifiers, loc } = dir;
|
|
4272
4964
|
const arg = dir.arg;
|
|
4965
|
+
let { exp } = dir;
|
|
4966
|
+
if (!exp && arg.type === 4) {
|
|
4967
|
+
const propName = camelize(arg.content);
|
|
4968
|
+
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
4969
|
+
}
|
|
4273
4970
|
if (arg.type !== 4) {
|
|
4274
4971
|
arg.children.unshift(`(`);
|
|
4275
4972
|
arg.children.push(`) || ""`);
|
|
@@ -4668,7 +5365,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
|
|
|
4668
5365
|
}
|
|
4669
5366
|
];
|
|
4670
5367
|
}
|
|
4671
|
-
function baseCompile(
|
|
5368
|
+
function baseCompile(source, options = {}) {
|
|
4672
5369
|
const onError = options.onError || defaultOnError;
|
|
4673
5370
|
const isModuleMode = options.mode === "module";
|
|
4674
5371
|
{
|
|
@@ -4685,7 +5382,7 @@ function baseCompile(template, options = {}) {
|
|
|
4685
5382
|
if (options.scopeId && !isModuleMode) {
|
|
4686
5383
|
onError(createCompilerError(50));
|
|
4687
5384
|
}
|
|
4688
|
-
const ast = isString(
|
|
5385
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4689
5386
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4690
5387
|
transform(
|
|
4691
5388
|
ast,
|
|
@@ -4714,4 +5411,4 @@ function baseCompile(template, options = {}) {
|
|
|
4714
5411
|
|
|
4715
5412
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
4716
5413
|
|
|
4717
|
-
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType,
|
|
5414
|
+
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|