@vue/compiler-core 3.4.0-alpha.1 → 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 +1791 -996
- package/dist/compiler-core.cjs.prod.js +1756 -956
- package/dist/compiler-core.d.ts +99 -89
- package/dist/compiler-core.esm-bundler.js +1688 -979
- package/package.json +6 -5
|
@@ -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
|
);
|
|
@@ -656,471 +1521,560 @@ function getMemoedVNodeCall(node) {
|
|
|
656
1521
|
return node;
|
|
657
1522
|
}
|
|
658
1523
|
}
|
|
1524
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
659
1525
|
|
|
660
|
-
const deprecationData = {
|
|
661
|
-
["COMPILER_IS_ON_ELEMENT"]: {
|
|
662
|
-
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:".`,
|
|
663
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
664
|
-
},
|
|
665
|
-
["COMPILER_V_BIND_SYNC"]: {
|
|
666
|
-
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}\`.`,
|
|
667
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
668
|
-
},
|
|
669
|
-
["COMPILER_V_BIND_PROP"]: {
|
|
670
|
-
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.`
|
|
671
|
-
},
|
|
672
|
-
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
673
|
-
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.`,
|
|
674
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
675
|
-
},
|
|
676
|
-
["COMPILER_V_ON_NATIVE"]: {
|
|
677
|
-
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
678
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
679
|
-
},
|
|
680
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
681
|
-
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.`,
|
|
682
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
683
|
-
},
|
|
684
|
-
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
685
|
-
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
686
|
-
},
|
|
687
|
-
["COMPILER_INLINE_TEMPLATE"]: {
|
|
688
|
-
message: `"inline-template" has been removed in Vue 3.`,
|
|
689
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
690
|
-
},
|
|
691
|
-
["COMPILER_FILTER"]: {
|
|
692
|
-
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.`,
|
|
693
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
function getCompatValue(key, context) {
|
|
697
|
-
const config = context.options ? context.options.compatConfig : context.compatConfig;
|
|
698
|
-
const value = config && config[key];
|
|
699
|
-
if (key === "MODE") {
|
|
700
|
-
return value || 3;
|
|
701
|
-
} else {
|
|
702
|
-
return value;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function isCompatEnabled(key, context) {
|
|
706
|
-
const mode = getCompatValue("MODE", context);
|
|
707
|
-
const value = getCompatValue(key, context);
|
|
708
|
-
return mode === 3 ? value === true : value !== false;
|
|
709
|
-
}
|
|
710
|
-
function checkCompatEnabled(key, context, loc, ...args) {
|
|
711
|
-
const enabled = isCompatEnabled(key, context);
|
|
712
|
-
if (!!(process.env.NODE_ENV !== "production") && enabled) {
|
|
713
|
-
warnDeprecation(key, context, loc, ...args);
|
|
714
|
-
}
|
|
715
|
-
return enabled;
|
|
716
|
-
}
|
|
717
|
-
function warnDeprecation(key, context, loc, ...args) {
|
|
718
|
-
const val = getCompatValue(key, context);
|
|
719
|
-
if (val === "suppress-warning") {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
const { message, link } = deprecationData[key];
|
|
723
|
-
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
724
|
-
Details: ${link}` : ``}`;
|
|
725
|
-
const err = new SyntaxError(msg);
|
|
726
|
-
err.code = key;
|
|
727
|
-
if (loc)
|
|
728
|
-
err.loc = loc;
|
|
729
|
-
context.onWarn(err);
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
|
733
|
-
const decodeMap = {
|
|
734
|
-
gt: ">",
|
|
735
|
-
lt: "<",
|
|
736
|
-
amp: "&",
|
|
737
|
-
apos: "'",
|
|
738
|
-
quot: '"'
|
|
739
|
-
};
|
|
740
1526
|
const defaultParserOptions = {
|
|
1527
|
+
parseMode: "base",
|
|
1528
|
+
ns: 0,
|
|
741
1529
|
delimiters: [`{{`, `}}`],
|
|
742
1530
|
getNamespace: () => 0,
|
|
743
|
-
getTextMode: () => 0,
|
|
744
1531
|
isVoidTag: NO,
|
|
745
1532
|
isPreTag: NO,
|
|
746
1533
|
isCustomElement: NO,
|
|
747
|
-
decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
|
748
1534
|
onError: defaultOnError,
|
|
749
1535
|
onWarn: defaultOnWarn,
|
|
750
1536
|
comments: !!(process.env.NODE_ENV !== "production")
|
|
751
1537
|
};
|
|
752
|
-
|
|
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
|
-
let
|
|
785
|
-
if (
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
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);
|
|
806
1615
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
} else if (s[2] === ">") {
|
|
811
|
-
emitError(context, 14, 2);
|
|
812
|
-
advanceBy(context, 3);
|
|
813
|
-
continue;
|
|
814
|
-
} else if (/[a-z]/i.test(s[2])) {
|
|
815
|
-
emitError(context, 23);
|
|
816
|
-
parseTag(context, 1 /* End */, parent);
|
|
817
|
-
continue;
|
|
818
|
-
} else {
|
|
819
|
-
emitError(
|
|
820
|
-
context,
|
|
821
|
-
12,
|
|
822
|
-
2
|
|
823
|
-
);
|
|
824
|
-
node = parseBogusComment(context);
|
|
1616
|
+
for (let j = 0; j <= i; j++) {
|
|
1617
|
+
const el = stack.shift();
|
|
1618
|
+
onCloseTag(el, end, j < i);
|
|
825
1619
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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]);
|
|
840
1677
|
}
|
|
841
|
-
} else if (s[1] === "?") {
|
|
842
|
-
emitError(
|
|
843
|
-
context,
|
|
844
|
-
21,
|
|
845
|
-
1
|
|
846
|
-
);
|
|
847
|
-
node = parseBogusComment(context);
|
|
848
|
-
} else {
|
|
849
|
-
emitError(context, 12, 1);
|
|
850
1678
|
}
|
|
851
1679
|
}
|
|
852
1680
|
}
|
|
853
|
-
|
|
854
|
-
|
|
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
|
+
);
|
|
855
1695
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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);
|
|
859
1707
|
}
|
|
860
1708
|
} else {
|
|
861
|
-
|
|
1709
|
+
currentProp.modifiers.push(mod);
|
|
862
1710
|
}
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
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);
|
|
882
1760
|
}
|
|
883
1761
|
} else {
|
|
884
|
-
|
|
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
|
+
}
|
|
885
1780
|
}
|
|
886
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
887
|
-
removedWhitespace = true;
|
|
888
|
-
nodes[i] = null;
|
|
889
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
|
+
});
|
|
890
1796
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
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;
|
|
895
1836
|
}
|
|
896
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
|
+
}
|
|
897
1857
|
}
|
|
898
|
-
|
|
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);
|
|
1890
|
+
}
|
|
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
|
+
);
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
if (valueContent) {
|
|
1905
|
+
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
1906
|
+
}
|
|
1907
|
+
return result;
|
|
899
1908
|
}
|
|
900
|
-
function
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
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;
|
|
908
1924
|
}
|
|
909
1925
|
}
|
|
910
|
-
|
|
1926
|
+
currentOpenTag = null;
|
|
911
1927
|
}
|
|
912
|
-
function
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
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);
|
|
917
1941
|
} else {
|
|
918
|
-
|
|
1942
|
+
parent.children.push({
|
|
1943
|
+
type: 2,
|
|
1944
|
+
content,
|
|
1945
|
+
loc: getLoc(start, end)
|
|
1946
|
+
});
|
|
919
1947
|
}
|
|
920
|
-
return nodes;
|
|
921
1948
|
}
|
|
922
|
-
function
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
const match = /--(\!)?>/.exec(context.source);
|
|
926
|
-
if (!match) {
|
|
927
|
-
content = context.source.slice(4);
|
|
928
|
-
advanceBy(context, context.source.length);
|
|
929
|
-
emitError(context, 7);
|
|
1949
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
1950
|
+
if (isImplied) {
|
|
1951
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
930
1952
|
} else {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
if (
|
|
935
|
-
|
|
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);
|
|
936
1960
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
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;
|
|
946
1974
|
}
|
|
947
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
948
1975
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
content = context.source.slice(contentStart);
|
|
962
|
-
advanceBy(context, context.source.length);
|
|
963
|
-
} else {
|
|
964
|
-
content = context.source.slice(contentStart, closeIndex);
|
|
965
|
-
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;
|
|
966
1988
|
}
|
|
967
|
-
return {
|
|
968
|
-
type: 3,
|
|
969
|
-
content,
|
|
970
|
-
loc: getSelection(context, start)
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
function parseElement(context, ancestors) {
|
|
974
|
-
const wasInPre = context.inPre;
|
|
975
|
-
const wasInVPre = context.inVPre;
|
|
976
|
-
const parent = last(ancestors);
|
|
977
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
978
|
-
const isPreBoundary = context.inPre && !wasInPre;
|
|
979
|
-
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
980
|
-
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
981
|
-
if (isPreBoundary) {
|
|
982
|
-
context.inPre = false;
|
|
983
|
-
}
|
|
984
|
-
if (isVPreBoundary) {
|
|
985
|
-
context.inVPre = false;
|
|
986
|
-
}
|
|
987
|
-
return element;
|
|
988
|
-
}
|
|
989
|
-
ancestors.push(element);
|
|
990
|
-
const mode = context.options.getTextMode(element, parent);
|
|
991
|
-
const children = parseChildren(context, mode, ancestors);
|
|
992
|
-
ancestors.pop();
|
|
993
1989
|
{
|
|
994
|
-
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(
|
|
995
2030
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
996
2031
|
);
|
|
997
2032
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
998
2033
|
"COMPILER_INLINE_TEMPLATE",
|
|
999
|
-
|
|
2034
|
+
currentOptions,
|
|
1000
2035
|
inlineTemplateProp.loc
|
|
1001
|
-
)) {
|
|
1002
|
-
const loc = getSelection(context, element.loc.end);
|
|
2036
|
+
) && el.children.length) {
|
|
1003
2037
|
inlineTemplateProp.value = {
|
|
1004
2038
|
type: 2,
|
|
1005
|
-
content:
|
|
1006
|
-
|
|
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
|
|
1007
2044
|
};
|
|
1008
2045
|
}
|
|
1009
2046
|
}
|
|
1010
|
-
element.children = children;
|
|
1011
|
-
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1012
|
-
parseTag(context, 1 /* End */, parent);
|
|
1013
|
-
} else {
|
|
1014
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1015
|
-
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1016
|
-
const first = children[0];
|
|
1017
|
-
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1018
|
-
emitError(context, 8);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
element.loc = getSelection(context, element.loc.start);
|
|
1023
|
-
if (isPreBoundary) {
|
|
1024
|
-
context.inPre = false;
|
|
1025
|
-
}
|
|
1026
|
-
if (isVPreBoundary) {
|
|
1027
|
-
context.inVPre = false;
|
|
1028
|
-
}
|
|
1029
|
-
return element;
|
|
1030
2047
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
)
|
|
1034
|
-
|
|
1035
|
-
const start = getCursor(context);
|
|
1036
|
-
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
|
1037
|
-
const tag = match[1];
|
|
1038
|
-
const ns = context.options.getNamespace(tag, parent);
|
|
1039
|
-
advanceBy(context, match[0].length);
|
|
1040
|
-
advanceSpaces(context);
|
|
1041
|
-
const cursor = getCursor(context);
|
|
1042
|
-
const currentSource = context.source;
|
|
1043
|
-
if (context.options.isPreTag(tag)) {
|
|
1044
|
-
context.inPre = true;
|
|
1045
|
-
}
|
|
1046
|
-
let props = parseAttributes(context, type);
|
|
1047
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1048
|
-
context.inVPre = true;
|
|
1049
|
-
extend(context, cursor);
|
|
1050
|
-
context.source = currentSource;
|
|
1051
|
-
props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
|
|
1052
|
-
}
|
|
1053
|
-
let isSelfClosing = false;
|
|
1054
|
-
if (context.source.length === 0) {
|
|
1055
|
-
emitError(context, 9);
|
|
1056
|
-
} else {
|
|
1057
|
-
isSelfClosing = startsWith(context.source, "/>");
|
|
1058
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1059
|
-
emitError(context, 4);
|
|
1060
|
-
}
|
|
1061
|
-
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1062
|
-
}
|
|
1063
|
-
if (type === 1 /* End */) {
|
|
1064
|
-
return;
|
|
2048
|
+
function fastForward(start, c) {
|
|
2049
|
+
let offset = 0;
|
|
2050
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2051
|
+
offset++;
|
|
1065
2052
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
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") {
|
|
1072
2064
|
for (let i = 0; i < props.length; i++) {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if (p.name === "if") {
|
|
1076
|
-
hasIf = true;
|
|
1077
|
-
} else if (p.name === "for") {
|
|
1078
|
-
hasFor = true;
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
if (hasIf && hasFor) {
|
|
1082
|
-
warnDeprecation(
|
|
1083
|
-
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1084
|
-
context,
|
|
1085
|
-
getSelection(context, start)
|
|
1086
|
-
);
|
|
1087
|
-
break;
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
let tagType = 0;
|
|
1092
|
-
if (!context.inVPre) {
|
|
1093
|
-
if (tag === "slot") {
|
|
1094
|
-
tagType = 2;
|
|
1095
|
-
} else if (tag === "template") {
|
|
1096
|
-
if (props.some(
|
|
1097
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1098
|
-
)) {
|
|
1099
|
-
tagType = 3;
|
|
2065
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2066
|
+
return true;
|
|
1100
2067
|
}
|
|
1101
|
-
} else if (isComponent(tag, props, context)) {
|
|
1102
|
-
tagType = 1;
|
|
1103
2068
|
}
|
|
1104
2069
|
}
|
|
1105
|
-
return
|
|
1106
|
-
type: 1,
|
|
1107
|
-
ns,
|
|
1108
|
-
tag,
|
|
1109
|
-
tagType,
|
|
1110
|
-
props,
|
|
1111
|
-
isSelfClosing,
|
|
1112
|
-
children: [],
|
|
1113
|
-
loc: getSelection(context, start),
|
|
1114
|
-
codegenNode: void 0
|
|
1115
|
-
// to be created during transform phase
|
|
1116
|
-
};
|
|
2070
|
+
return false;
|
|
1117
2071
|
}
|
|
1118
|
-
function isComponent(tag, props
|
|
1119
|
-
|
|
1120
|
-
if (
|
|
2072
|
+
function isComponent({ tag, props }) {
|
|
2073
|
+
var _a;
|
|
2074
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1121
2075
|
return false;
|
|
1122
2076
|
}
|
|
1123
|
-
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)) {
|
|
1124
2078
|
return true;
|
|
1125
2079
|
}
|
|
1126
2080
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1131,374 +2085,179 @@ function isComponent(tag, props, context) {
|
|
|
1131
2085
|
return true;
|
|
1132
2086
|
} else if (checkCompatEnabled(
|
|
1133
2087
|
"COMPILER_IS_ON_ELEMENT",
|
|
1134
|
-
|
|
2088
|
+
currentOptions,
|
|
1135
2089
|
p.loc
|
|
1136
2090
|
)) {
|
|
1137
2091
|
return true;
|
|
1138
2092
|
}
|
|
1139
2093
|
}
|
|
1140
|
-
} else
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
context,
|
|
1148
|
-
p.loc
|
|
1149
|
-
)
|
|
1150
|
-
) {
|
|
1151
|
-
return true;
|
|
1152
|
-
}
|
|
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;
|
|
1153
2101
|
}
|
|
1154
2102
|
}
|
|
2103
|
+
return false;
|
|
1155
2104
|
}
|
|
1156
|
-
function
|
|
1157
|
-
|
|
1158
|
-
const attributeNames = /* @__PURE__ */ new Set();
|
|
1159
|
-
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1160
|
-
if (startsWith(context.source, "/")) {
|
|
1161
|
-
emitError(context, 22);
|
|
1162
|
-
advanceBy(context, 1);
|
|
1163
|
-
advanceSpaces(context);
|
|
1164
|
-
continue;
|
|
1165
|
-
}
|
|
1166
|
-
if (type === 1 /* End */) {
|
|
1167
|
-
emitError(context, 3);
|
|
1168
|
-
}
|
|
1169
|
-
const attr = parseAttribute(context, attributeNames);
|
|
1170
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1171
|
-
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1172
|
-
}
|
|
1173
|
-
if (type === 0 /* Start */) {
|
|
1174
|
-
props.push(attr);
|
|
1175
|
-
}
|
|
1176
|
-
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1177
|
-
emitError(context, 15);
|
|
1178
|
-
}
|
|
1179
|
-
advanceSpaces(context);
|
|
1180
|
-
}
|
|
1181
|
-
return props;
|
|
2105
|
+
function isUpperCase(c) {
|
|
2106
|
+
return c > 64 && c < 91;
|
|
1182
2107
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
advanceBy(context, name.length);
|
|
1207
|
-
let value = void 0;
|
|
1208
|
-
if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
|
1209
|
-
advanceSpaces(context);
|
|
1210
|
-
advanceBy(context, 1);
|
|
1211
|
-
advanceSpaces(context);
|
|
1212
|
-
value = parseAttributeValue(context);
|
|
1213
|
-
if (!value) {
|
|
1214
|
-
emitError(context, 13);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
const loc = getSelection(context, start);
|
|
1218
|
-
if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
|
1219
|
-
const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
|
|
1220
|
-
name
|
|
1221
|
-
);
|
|
1222
|
-
let isPropShorthand = startsWith(name, ".");
|
|
1223
|
-
let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
|
|
1224
|
-
let arg;
|
|
1225
|
-
if (match2[2]) {
|
|
1226
|
-
const isSlot = dirName === "slot";
|
|
1227
|
-
const startOffset = name.lastIndexOf(
|
|
1228
|
-
match2[2],
|
|
1229
|
-
name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
|
|
1230
|
-
);
|
|
1231
|
-
const loc2 = getSelection(
|
|
1232
|
-
context,
|
|
1233
|
-
getNewPosition(context, start, startOffset),
|
|
1234
|
-
getNewPosition(
|
|
1235
|
-
context,
|
|
1236
|
-
start,
|
|
1237
|
-
startOffset + match2[2].length + (isSlot && match2[3] || "").length
|
|
1238
|
-
)
|
|
1239
|
-
);
|
|
1240
|
-
let content = match2[2];
|
|
1241
|
-
let isStatic = true;
|
|
1242
|
-
if (content.startsWith("[")) {
|
|
1243
|
-
isStatic = false;
|
|
1244
|
-
if (!content.endsWith("]")) {
|
|
1245
|
-
emitError(
|
|
1246
|
-
context,
|
|
1247
|
-
27
|
|
1248
|
-
);
|
|
1249
|
-
content = content.slice(1);
|
|
1250
|
-
} else {
|
|
1251
|
-
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);
|
|
1252
2128
|
}
|
|
1253
|
-
} else
|
|
1254
|
-
content
|
|
1255
|
-
}
|
|
1256
|
-
arg = {
|
|
1257
|
-
type: 4,
|
|
1258
|
-
content,
|
|
1259
|
-
isStatic,
|
|
1260
|
-
constType: isStatic ? 3 : 0,
|
|
1261
|
-
loc: loc2
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
if (value && value.isQuoted) {
|
|
1265
|
-
const valueLoc = value.loc;
|
|
1266
|
-
valueLoc.start.offset++;
|
|
1267
|
-
valueLoc.start.column++;
|
|
1268
|
-
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1269
|
-
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1270
|
-
}
|
|
1271
|
-
const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
|
|
1272
|
-
if (isPropShorthand)
|
|
1273
|
-
modifiers.push("prop");
|
|
1274
|
-
if (dirName === "bind" && arg) {
|
|
1275
|
-
if (modifiers.includes("sync") && checkCompatEnabled(
|
|
1276
|
-
"COMPILER_V_BIND_SYNC",
|
|
1277
|
-
context,
|
|
1278
|
-
loc,
|
|
1279
|
-
arg.loc.source
|
|
1280
|
-
)) {
|
|
1281
|
-
dirName = "model";
|
|
1282
|
-
modifiers.splice(modifiers.indexOf("sync"), 1);
|
|
1283
|
-
}
|
|
1284
|
-
if (!!(process.env.NODE_ENV !== "production") && modifiers.includes("prop")) {
|
|
1285
|
-
checkCompatEnabled(
|
|
1286
|
-
"COMPILER_V_BIND_PROP",
|
|
1287
|
-
context,
|
|
1288
|
-
loc
|
|
1289
|
-
);
|
|
2129
|
+
} else {
|
|
2130
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1290
2131
|
}
|
|
1291
2132
|
}
|
|
1292
|
-
return {
|
|
1293
|
-
type: 7,
|
|
1294
|
-
name: dirName,
|
|
1295
|
-
exp: value && {
|
|
1296
|
-
type: 4,
|
|
1297
|
-
content: value.content,
|
|
1298
|
-
isStatic: false,
|
|
1299
|
-
// Treat as non-constant by default. This can be potentially set to
|
|
1300
|
-
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1301
|
-
constType: 0,
|
|
1302
|
-
loc: value.loc
|
|
1303
|
-
},
|
|
1304
|
-
arg,
|
|
1305
|
-
modifiers,
|
|
1306
|
-
loc
|
|
1307
|
-
};
|
|
1308
2133
|
}
|
|
1309
|
-
if (
|
|
1310
|
-
|
|
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
|
+
}
|
|
1311
2139
|
}
|
|
1312
|
-
return
|
|
1313
|
-
type: 6,
|
|
1314
|
-
name,
|
|
1315
|
-
value: value && {
|
|
1316
|
-
type: 2,
|
|
1317
|
-
content: value.content,
|
|
1318
|
-
loc: value.loc
|
|
1319
|
-
},
|
|
1320
|
-
loc
|
|
1321
|
-
};
|
|
2140
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1322
2141
|
}
|
|
1323
|
-
function
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
const isQuoted = quote === `"` || quote === `'`;
|
|
1328
|
-
if (isQuoted) {
|
|
1329
|
-
advanceBy(context, 1);
|
|
1330
|
-
const endIndex = context.source.indexOf(quote);
|
|
1331
|
-
if (endIndex === -1) {
|
|
1332
|
-
content = parseTextData(
|
|
1333
|
-
context,
|
|
1334
|
-
context.source.length,
|
|
1335
|
-
4
|
|
1336
|
-
);
|
|
1337
|
-
} else {
|
|
1338
|
-
content = parseTextData(context, endIndex, 4);
|
|
1339
|
-
advanceBy(context, 1);
|
|
1340
|
-
}
|
|
1341
|
-
} else {
|
|
1342
|
-
const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
|
1343
|
-
if (!match) {
|
|
1344
|
-
return void 0;
|
|
1345
|
-
}
|
|
1346
|
-
const unexpectedChars = /["'<=`]/g;
|
|
1347
|
-
let m;
|
|
1348
|
-
while (m = unexpectedChars.exec(match[0])) {
|
|
1349
|
-
emitError(
|
|
1350
|
-
context,
|
|
1351
|
-
18,
|
|
1352
|
-
m.index
|
|
1353
|
-
);
|
|
2142
|
+
function isAllWhitespace(str) {
|
|
2143
|
+
for (let i = 0; i < str.length; i++) {
|
|
2144
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2145
|
+
return false;
|
|
1354
2146
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1358
|
-
}
|
|
1359
|
-
function parseInterpolation(context, mode) {
|
|
1360
|
-
const [open, close] = context.options.delimiters;
|
|
1361
|
-
const closeIndex = context.source.indexOf(close, open.length);
|
|
1362
|
-
if (closeIndex === -1) {
|
|
1363
|
-
emitError(context, 25);
|
|
1364
|
-
return void 0;
|
|
1365
|
-
}
|
|
1366
|
-
const start = getCursor(context);
|
|
1367
|
-
advanceBy(context, open.length);
|
|
1368
|
-
const innerStart = getCursor(context);
|
|
1369
|
-
const innerEnd = getCursor(context);
|
|
1370
|
-
const rawContentLength = closeIndex - open.length;
|
|
1371
|
-
const rawContent = context.source.slice(0, rawContentLength);
|
|
1372
|
-
const preTrimContent = parseTextData(context, rawContentLength, mode);
|
|
1373
|
-
const content = preTrimContent.trim();
|
|
1374
|
-
const startOffset = preTrimContent.indexOf(content);
|
|
1375
|
-
if (startOffset > 0) {
|
|
1376
|
-
advancePositionWithMutation(innerStart, rawContent, startOffset);
|
|
1377
|
-
}
|
|
1378
|
-
const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
|
1379
|
-
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1380
|
-
advanceBy(context, close.length);
|
|
1381
|
-
return {
|
|
1382
|
-
type: 5,
|
|
1383
|
-
content: {
|
|
1384
|
-
type: 4,
|
|
1385
|
-
isStatic: false,
|
|
1386
|
-
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1387
|
-
constType: 0,
|
|
1388
|
-
content,
|
|
1389
|
-
loc: getSelection(context, innerStart, innerEnd)
|
|
1390
|
-
},
|
|
1391
|
-
loc: getSelection(context, start)
|
|
1392
|
-
};
|
|
2147
|
+
}
|
|
2148
|
+
return true;
|
|
1393
2149
|
}
|
|
1394
|
-
function
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
if (index !== -1 && endIndex > index) {
|
|
1400
|
-
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;
|
|
1401
2155
|
}
|
|
1402
2156
|
}
|
|
1403
|
-
|
|
1404
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1405
|
-
return {
|
|
1406
|
-
type: 2,
|
|
1407
|
-
content,
|
|
1408
|
-
loc: getSelection(context, start)
|
|
1409
|
-
};
|
|
2157
|
+
return false;
|
|
1410
2158
|
}
|
|
1411
|
-
function
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
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
|
+
}
|
|
1421
2172
|
}
|
|
2173
|
+
return ret;
|
|
1422
2174
|
}
|
|
1423
|
-
function
|
|
1424
|
-
|
|
1425
|
-
return { column, line, offset };
|
|
2175
|
+
function addNode(node) {
|
|
2176
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1426
2177
|
}
|
|
1427
|
-
function
|
|
1428
|
-
end = end || getCursor(context);
|
|
2178
|
+
function getLoc(start, end) {
|
|
1429
2179
|
return {
|
|
1430
|
-
start,
|
|
1431
|
-
|
|
1432
|
-
|
|
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)
|
|
1433
2185
|
};
|
|
1434
2186
|
}
|
|
1435
|
-
function
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
function startsWith(source, searchString) {
|
|
1439
|
-
return source.startsWith(searchString);
|
|
2187
|
+
function setLocEnd(loc, end) {
|
|
2188
|
+
loc.end = tokenizer.getPos(end);
|
|
2189
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1440
2190
|
}
|
|
1441
|
-
function
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
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
|
+
};
|
|
1463
2215
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
);
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1488
|
-
return true;
|
|
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];
|
|
1489
2239
|
}
|
|
1490
|
-
break;
|
|
1491
2240
|
}
|
|
1492
|
-
case 3:
|
|
1493
|
-
if (startsWith(s, "]]>")) {
|
|
1494
|
-
return true;
|
|
1495
|
-
}
|
|
1496
|
-
break;
|
|
1497
2241
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
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;
|
|
1502
2261
|
}
|
|
1503
2262
|
|
|
1504
2263
|
function hoistStatic(root, context) {
|
|
@@ -1911,6 +2670,7 @@ function transform(root, options) {
|
|
|
1911
2670
|
root.hoists = context.hoists;
|
|
1912
2671
|
root.temps = context.temps;
|
|
1913
2672
|
root.cached = context.cached;
|
|
2673
|
+
root.transformed = true;
|
|
1914
2674
|
{
|
|
1915
2675
|
root.filters = [...context.filters];
|
|
1916
2676
|
}
|
|
@@ -2067,7 +2827,7 @@ function createCodegenContext(ast, {
|
|
|
2067
2827
|
ssr,
|
|
2068
2828
|
isTS,
|
|
2069
2829
|
inSSR,
|
|
2070
|
-
source: ast.
|
|
2830
|
+
source: ast.source,
|
|
2071
2831
|
code: ``,
|
|
2072
2832
|
column: 1,
|
|
2073
2833
|
line: 1,
|
|
@@ -2078,7 +2838,7 @@ function createCodegenContext(ast, {
|
|
|
2078
2838
|
helper(key) {
|
|
2079
2839
|
return `_${helperNameMap[key]}`;
|
|
2080
2840
|
},
|
|
2081
|
-
push(code, node) {
|
|
2841
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2082
2842
|
context.code += code;
|
|
2083
2843
|
},
|
|
2084
2844
|
indent() {
|
|
@@ -2096,7 +2856,7 @@ function createCodegenContext(ast, {
|
|
|
2096
2856
|
}
|
|
2097
2857
|
};
|
|
2098
2858
|
function newline(n) {
|
|
2099
|
-
context.push("\n" + ` `.repeat(n));
|
|
2859
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2100
2860
|
}
|
|
2101
2861
|
return context;
|
|
2102
2862
|
}
|
|
@@ -2133,9 +2893,11 @@ function generate(ast, options = {}) {
|
|
|
2133
2893
|
push(`with (_ctx) {`);
|
|
2134
2894
|
indent();
|
|
2135
2895
|
if (hasHelpers) {
|
|
2136
|
-
push(
|
|
2137
|
-
|
|
2138
|
-
|
|
2896
|
+
push(
|
|
2897
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
2898
|
+
`,
|
|
2899
|
+
-1 /* End */
|
|
2900
|
+
);
|
|
2139
2901
|
newline();
|
|
2140
2902
|
}
|
|
2141
2903
|
}
|
|
@@ -2164,7 +2926,7 @@ function generate(ast, options = {}) {
|
|
|
2164
2926
|
}
|
|
2165
2927
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2166
2928
|
push(`
|
|
2167
|
-
|
|
2929
|
+
`, 0 /* Start */);
|
|
2168
2930
|
newline();
|
|
2169
2931
|
}
|
|
2170
2932
|
if (!ssr) {
|
|
@@ -2185,7 +2947,6 @@ function generate(ast, options = {}) {
|
|
|
2185
2947
|
ast,
|
|
2186
2948
|
code: context.code,
|
|
2187
2949
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2188
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2189
2950
|
map: context.map ? context.map.toJSON() : void 0
|
|
2190
2951
|
};
|
|
2191
2952
|
}
|
|
@@ -2204,7 +2965,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2204
2965
|
if (helpers.length > 0) {
|
|
2205
2966
|
{
|
|
2206
2967
|
push(`const _Vue = ${VueBinding}
|
|
2207
|
-
|
|
2968
|
+
`, -1 /* End */);
|
|
2208
2969
|
if (ast.hoists.length) {
|
|
2209
2970
|
const staticHelpers = [
|
|
2210
2971
|
CREATE_VNODE,
|
|
@@ -2214,7 +2975,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2214
2975
|
CREATE_STATIC
|
|
2215
2976
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2216
2977
|
push(`const { ${staticHelpers} } = _Vue
|
|
2217
|
-
|
|
2978
|
+
`, -1 /* End */);
|
|
2218
2979
|
}
|
|
2219
2980
|
}
|
|
2220
2981
|
}
|
|
@@ -2275,7 +3036,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2275
3036
|
for (let i = 0; i < nodes.length; i++) {
|
|
2276
3037
|
const node = nodes[i];
|
|
2277
3038
|
if (isString(node)) {
|
|
2278
|
-
push(node);
|
|
3039
|
+
push(node, -3 /* Unknown */);
|
|
2279
3040
|
} else if (isArray(node)) {
|
|
2280
3041
|
genNodeListAsArray(node, context);
|
|
2281
3042
|
} else {
|
|
@@ -2293,7 +3054,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2293
3054
|
}
|
|
2294
3055
|
function genNode(node, context) {
|
|
2295
3056
|
if (isString(node)) {
|
|
2296
|
-
context.push(node);
|
|
3057
|
+
context.push(node, -3 /* Unknown */);
|
|
2297
3058
|
return;
|
|
2298
3059
|
}
|
|
2299
3060
|
if (isSymbol(node)) {
|
|
@@ -2373,11 +3134,15 @@ function genNode(node, context) {
|
|
|
2373
3134
|
}
|
|
2374
3135
|
}
|
|
2375
3136
|
function genText(node, context) {
|
|
2376
|
-
context.push(JSON.stringify(node.content), node);
|
|
3137
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2377
3138
|
}
|
|
2378
3139
|
function genExpression(node, context) {
|
|
2379
3140
|
const { content, isStatic } = node;
|
|
2380
|
-
context.push(
|
|
3141
|
+
context.push(
|
|
3142
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3143
|
+
-3 /* Unknown */,
|
|
3144
|
+
node
|
|
3145
|
+
);
|
|
2381
3146
|
}
|
|
2382
3147
|
function genInterpolation(node, context) {
|
|
2383
3148
|
const { push, helper, pure } = context;
|
|
@@ -2391,7 +3156,7 @@ function genCompoundExpression(node, context) {
|
|
|
2391
3156
|
for (let i = 0; i < node.children.length; i++) {
|
|
2392
3157
|
const child = node.children[i];
|
|
2393
3158
|
if (isString(child)) {
|
|
2394
|
-
context.push(child);
|
|
3159
|
+
context.push(child, -3 /* Unknown */);
|
|
2395
3160
|
} else {
|
|
2396
3161
|
genNode(child, context);
|
|
2397
3162
|
}
|
|
@@ -2405,9 +3170,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
2405
3170
|
push(`]`);
|
|
2406
3171
|
} else if (node.isStatic) {
|
|
2407
3172
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2408
|
-
push(text, node);
|
|
3173
|
+
push(text, -2 /* None */, node);
|
|
2409
3174
|
} else {
|
|
2410
|
-
push(`[${node.content}]`, node);
|
|
3175
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2411
3176
|
}
|
|
2412
3177
|
}
|
|
2413
3178
|
function genComment(node, context) {
|
|
@@ -2415,7 +3180,11 @@ function genComment(node, context) {
|
|
|
2415
3180
|
if (pure) {
|
|
2416
3181
|
push(PURE_ANNOTATION);
|
|
2417
3182
|
}
|
|
2418
|
-
push(
|
|
3183
|
+
push(
|
|
3184
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3185
|
+
-3 /* Unknown */,
|
|
3186
|
+
node
|
|
3187
|
+
);
|
|
2419
3188
|
}
|
|
2420
3189
|
function genVNodeCall(node, context) {
|
|
2421
3190
|
const { push, helper, pure } = context;
|
|
@@ -2440,7 +3209,7 @@ function genVNodeCall(node, context) {
|
|
|
2440
3209
|
push(PURE_ANNOTATION);
|
|
2441
3210
|
}
|
|
2442
3211
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2443
|
-
push(helper(callHelper) + `(`, node);
|
|
3212
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2444
3213
|
genNodeList(
|
|
2445
3214
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2446
3215
|
context
|
|
@@ -2469,7 +3238,7 @@ function genCallExpression(node, context) {
|
|
|
2469
3238
|
if (pure) {
|
|
2470
3239
|
push(PURE_ANNOTATION);
|
|
2471
3240
|
}
|
|
2472
|
-
push(callee + `(`, node);
|
|
3241
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2473
3242
|
genNodeList(node.arguments, context);
|
|
2474
3243
|
push(`)`);
|
|
2475
3244
|
}
|
|
@@ -2477,7 +3246,7 @@ function genObjectExpression(node, context) {
|
|
|
2477
3246
|
const { push, indent, deindent, newline } = context;
|
|
2478
3247
|
const { properties } = node;
|
|
2479
3248
|
if (!properties.length) {
|
|
2480
|
-
push(`{}`, node);
|
|
3249
|
+
push(`{}`, -2 /* None */, node);
|
|
2481
3250
|
return;
|
|
2482
3251
|
}
|
|
2483
3252
|
const multilines = properties.length > 1 || !!(process.env.NODE_ENV !== "production") && properties.some((p) => p.value.type !== 4);
|
|
@@ -2505,7 +3274,7 @@ function genFunctionExpression(node, context) {
|
|
|
2505
3274
|
if (isSlot) {
|
|
2506
3275
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2507
3276
|
}
|
|
2508
|
-
push(`(`, node);
|
|
3277
|
+
push(`(`, -2 /* None */, node);
|
|
2509
3278
|
if (isArray(params)) {
|
|
2510
3279
|
genNodeList(params, context);
|
|
2511
3280
|
} else if (params) {
|
|
@@ -2640,6 +3409,15 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
2640
3409
|
if (stmt.declare || !stmt.id)
|
|
2641
3410
|
continue;
|
|
2642
3411
|
onIdent(stmt.id);
|
|
3412
|
+
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
3413
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
3414
|
+
if (variable && variable.type === "VariableDeclaration") {
|
|
3415
|
+
for (const decl of variable.declarations) {
|
|
3416
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
3417
|
+
onIdent(id);
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
2643
3421
|
}
|
|
2644
3422
|
}
|
|
2645
3423
|
}
|
|
@@ -2850,7 +3628,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2850
3628
|
context.removeNode();
|
|
2851
3629
|
const branch = createIfBranch(node, dir);
|
|
2852
3630
|
if (!!(process.env.NODE_ENV !== "production") && comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2853
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3631
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2854
3632
|
branch.children = [...comments, ...branch.children];
|
|
2855
3633
|
}
|
|
2856
3634
|
if (!!(process.env.NODE_ENV !== "production") || false) {
|
|
@@ -3132,18 +3910,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3132
3910
|
);
|
|
3133
3911
|
return;
|
|
3134
3912
|
}
|
|
3135
|
-
const parseResult =
|
|
3136
|
-
// can only be simple expression because vFor transform is applied
|
|
3137
|
-
// before expression transform.
|
|
3138
|
-
dir.exp,
|
|
3139
|
-
context
|
|
3140
|
-
);
|
|
3913
|
+
const parseResult = dir.forParseResult;
|
|
3141
3914
|
if (!parseResult) {
|
|
3142
3915
|
context.onError(
|
|
3143
3916
|
createCompilerError(32, dir.loc)
|
|
3144
3917
|
);
|
|
3145
3918
|
return;
|
|
3146
3919
|
}
|
|
3920
|
+
finalizeForParseResult(parseResult, context);
|
|
3147
3921
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3148
3922
|
const { source, value, key, index } = parseResult;
|
|
3149
3923
|
const forNode = {
|
|
@@ -3165,71 +3939,26 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3165
3939
|
onExit();
|
|
3166
3940
|
};
|
|
3167
3941
|
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
const stripParensRE = /^\(|\)$/g;
|
|
3171
|
-
function parseForExpression(input, context) {
|
|
3172
|
-
const loc = input.loc;
|
|
3173
|
-
const exp = input.content;
|
|
3174
|
-
const inMatch = exp.match(forAliasRE);
|
|
3175
|
-
if (!inMatch)
|
|
3942
|
+
function finalizeForParseResult(result, context) {
|
|
3943
|
+
if (result.finalized)
|
|
3176
3944
|
return;
|
|
3177
|
-
const [, LHS, RHS] = inMatch;
|
|
3178
|
-
const result = {
|
|
3179
|
-
source: createAliasExpression(
|
|
3180
|
-
loc,
|
|
3181
|
-
RHS.trim(),
|
|
3182
|
-
exp.indexOf(RHS, LHS.length)
|
|
3183
|
-
),
|
|
3184
|
-
value: void 0,
|
|
3185
|
-
key: void 0,
|
|
3186
|
-
index: void 0
|
|
3187
|
-
};
|
|
3188
3945
|
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3189
3946
|
validateBrowserExpression(result.source, context);
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
const keyContent = iteratorMatch[1].trim();
|
|
3197
|
-
let keyOffset;
|
|
3198
|
-
if (keyContent) {
|
|
3199
|
-
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
3200
|
-
result.key = createAliasExpression(loc, keyContent, keyOffset);
|
|
3201
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3202
|
-
validateBrowserExpression(
|
|
3203
|
-
result.key,
|
|
3204
|
-
context,
|
|
3205
|
-
true
|
|
3206
|
-
);
|
|
3207
|
-
}
|
|
3947
|
+
if (result.key) {
|
|
3948
|
+
validateBrowserExpression(
|
|
3949
|
+
result.key,
|
|
3950
|
+
context,
|
|
3951
|
+
true
|
|
3952
|
+
);
|
|
3208
3953
|
}
|
|
3209
|
-
if (
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
exp.indexOf(
|
|
3216
|
-
indexContent,
|
|
3217
|
-
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
3218
|
-
)
|
|
3219
|
-
);
|
|
3220
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3221
|
-
validateBrowserExpression(
|
|
3222
|
-
result.index,
|
|
3223
|
-
context,
|
|
3224
|
-
true
|
|
3225
|
-
);
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3954
|
+
if (result.index) {
|
|
3955
|
+
validateBrowserExpression(
|
|
3956
|
+
result.index,
|
|
3957
|
+
context,
|
|
3958
|
+
true
|
|
3959
|
+
);
|
|
3228
3960
|
}
|
|
3229
|
-
|
|
3230
|
-
if (valueContent) {
|
|
3231
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3232
|
-
if (!!(process.env.NODE_ENV !== "production") && true) {
|
|
3961
|
+
if (result.value) {
|
|
3233
3962
|
validateBrowserExpression(
|
|
3234
3963
|
result.value,
|
|
3235
3964
|
context,
|
|
@@ -3237,14 +3966,7 @@ function parseForExpression(input, context) {
|
|
|
3237
3966
|
);
|
|
3238
3967
|
}
|
|
3239
3968
|
}
|
|
3240
|
-
|
|
3241
|
-
}
|
|
3242
|
-
function createAliasExpression(range, content, offset) {
|
|
3243
|
-
return createSimpleExpression(
|
|
3244
|
-
content,
|
|
3245
|
-
false,
|
|
3246
|
-
getInnerRange(range, offset, content.length)
|
|
3247
|
-
);
|
|
3969
|
+
result.finalized = true;
|
|
3248
3970
|
}
|
|
3249
3971
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3250
3972
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3274,11 +3996,9 @@ const trackSlotScopes = (node, context) => {
|
|
|
3274
3996
|
const trackVForSlotScopes = (node, context) => {
|
|
3275
3997
|
let vFor;
|
|
3276
3998
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3277
|
-
const result = vFor.
|
|
3278
|
-
vFor.exp,
|
|
3279
|
-
context
|
|
3280
|
-
);
|
|
3999
|
+
const result = vFor.forParseResult;
|
|
3281
4000
|
if (result) {
|
|
4001
|
+
finalizeForParseResult(result, context);
|
|
3282
4002
|
const { value, key, index } = result;
|
|
3283
4003
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3284
4004
|
value && addIdentifiers(value);
|
|
@@ -3352,12 +4072,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3352
4072
|
hasDynamicSlots = true;
|
|
3353
4073
|
}
|
|
3354
4074
|
const vFor = findDir(slotElement, "for");
|
|
3355
|
-
const slotFunction = buildSlotFn(
|
|
3356
|
-
slotProps,
|
|
3357
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3358
|
-
slotChildren,
|
|
3359
|
-
slotLoc
|
|
3360
|
-
);
|
|
4075
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3361
4076
|
let vIf;
|
|
3362
4077
|
let vElse;
|
|
3363
4078
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3406,8 +4121,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3406
4121
|
}
|
|
3407
4122
|
} else if (vFor) {
|
|
3408
4123
|
hasDynamicSlots = true;
|
|
3409
|
-
const parseResult = vFor.
|
|
4124
|
+
const parseResult = vFor.forParseResult;
|
|
3410
4125
|
if (parseResult) {
|
|
4126
|
+
finalizeForParseResult(parseResult, context);
|
|
3411
4127
|
dynamicSlots.push(
|
|
3412
4128
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3413
4129
|
parseResult.source,
|
|
@@ -3670,17 +4386,6 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3670
4386
|
tag = isProp.value.content.slice(4);
|
|
3671
4387
|
}
|
|
3672
4388
|
}
|
|
3673
|
-
const isDir = !isExplicitDynamic && findDir(node, "is");
|
|
3674
|
-
if (isDir && isDir.exp) {
|
|
3675
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
3676
|
-
context.onWarn(
|
|
3677
|
-
createCompilerError(52, isDir.loc)
|
|
3678
|
-
);
|
|
3679
|
-
}
|
|
3680
|
-
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
3681
|
-
isDir.exp
|
|
3682
|
-
]);
|
|
3683
|
-
}
|
|
3684
4389
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3685
4390
|
if (builtIn) {
|
|
3686
4391
|
if (!ssr)
|
|
@@ -3752,7 +4457,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3752
4457
|
for (let i = 0; i < props.length; i++) {
|
|
3753
4458
|
const prop = props[i];
|
|
3754
4459
|
if (prop.type === 6) {
|
|
3755
|
-
const { loc, name, value } = prop;
|
|
4460
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3756
4461
|
let isStatic = true;
|
|
3757
4462
|
if (name === "ref") {
|
|
3758
4463
|
hasRef = true;
|
|
@@ -3773,11 +4478,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3773
4478
|
}
|
|
3774
4479
|
properties.push(
|
|
3775
4480
|
createObjectProperty(
|
|
3776
|
-
createSimpleExpression(
|
|
3777
|
-
name,
|
|
3778
|
-
true,
|
|
3779
|
-
getInnerRange(loc, 0, name.length)
|
|
3780
|
-
),
|
|
4481
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3781
4482
|
createSimpleExpression(
|
|
3782
4483
|
value ? value.content : "",
|
|
3783
4484
|
isStatic,
|
|
@@ -3786,7 +4487,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3786
4487
|
)
|
|
3787
4488
|
);
|
|
3788
4489
|
} else {
|
|
3789
|
-
const { name, arg, exp, loc } = prop;
|
|
4490
|
+
const { name, arg, exp, loc, modifiers } = prop;
|
|
3790
4491
|
const isVBind = name === "bind";
|
|
3791
4492
|
const isVOn = name === "on";
|
|
3792
4493
|
if (name === "slot") {
|
|
@@ -3879,6 +4580,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3879
4580
|
}
|
|
3880
4581
|
continue;
|
|
3881
4582
|
}
|
|
4583
|
+
if (isVBind && modifiers.includes("prop")) {
|
|
4584
|
+
patchFlag |= 32;
|
|
4585
|
+
}
|
|
3882
4586
|
const directiveTransform = context.directiveTransforms[name];
|
|
3883
4587
|
if (directiveTransform) {
|
|
3884
4588
|
const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
|
@@ -4256,8 +4960,13 @@ const transformOn = (dir, node, context, augmentor) => {
|
|
|
4256
4960
|
};
|
|
4257
4961
|
|
|
4258
4962
|
const transformBind = (dir, _node, context) => {
|
|
4259
|
-
const {
|
|
4963
|
+
const { modifiers, loc } = dir;
|
|
4260
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
|
+
}
|
|
4261
4970
|
if (arg.type !== 4) {
|
|
4262
4971
|
arg.children.unshift(`(`);
|
|
4263
4972
|
arg.children.push(`) || ""`);
|
|
@@ -4656,7 +5365,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
|
|
|
4656
5365
|
}
|
|
4657
5366
|
];
|
|
4658
5367
|
}
|
|
4659
|
-
function baseCompile(
|
|
5368
|
+
function baseCompile(source, options = {}) {
|
|
4660
5369
|
const onError = options.onError || defaultOnError;
|
|
4661
5370
|
const isModuleMode = options.mode === "module";
|
|
4662
5371
|
{
|
|
@@ -4673,7 +5382,7 @@ function baseCompile(template, options = {}) {
|
|
|
4673
5382
|
if (options.scopeId && !isModuleMode) {
|
|
4674
5383
|
onError(createCompilerError(50));
|
|
4675
5384
|
}
|
|
4676
|
-
const ast = isString(
|
|
5385
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4677
5386
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4678
5387
|
transform(
|
|
4679
5388
|
ast,
|
|
@@ -4702,4 +5411,4 @@ function baseCompile(template, options = {}) {
|
|
|
4702
5411
|
|
|
4703
5412
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
4704
5413
|
|
|
4705
|
-
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, 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 };
|