@vue/compiler-dom 3.3.9 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +10 -2362
- package/dist/compiler-dom.cjs.prod.js +9 -2362
- package/dist/compiler-dom.d.ts +5 -2
- package/dist/compiler-dom.esm-browser.js +1800 -1125
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +11 -25
- package/dist/compiler-dom.global.js +1801 -1126
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
function makeMap(str, expectsLowerCase) {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
for (let i = 0; i < list.length; i++) {
|
|
5
|
-
map[list[i]] = true;
|
|
6
|
-
}
|
|
7
|
-
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
|
|
2
|
+
const set = new Set(str.split(","));
|
|
3
|
+
return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
|
|
8
4
|
}
|
|
9
5
|
|
|
10
6
|
const EMPTY_OBJ = Object.freeze({}) ;
|
|
@@ -36,10 +32,6 @@ const camelizeRE = /-(\w)/g;
|
|
|
36
32
|
const camelize = cacheStringFunction((str) => {
|
|
37
33
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
38
34
|
});
|
|
39
|
-
const hyphenateRE = /\B([A-Z])/g;
|
|
40
|
-
const hyphenate = cacheStringFunction(
|
|
41
|
-
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
42
|
-
);
|
|
43
35
|
const capitalize = cacheStringFunction((str) => {
|
|
44
36
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
45
37
|
});
|
|
@@ -132,83 +124,6 @@ const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
|
132
124
|
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
133
125
|
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
134
126
|
|
|
135
|
-
function defaultOnError(error) {
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
function defaultOnWarn(msg) {
|
|
139
|
-
console.warn(`[Vue warn] ${msg.message}`);
|
|
140
|
-
}
|
|
141
|
-
function createCompilerError(code, loc, messages, additionalMessage) {
|
|
142
|
-
const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
|
|
143
|
-
const error = new SyntaxError(String(msg));
|
|
144
|
-
error.code = code;
|
|
145
|
-
error.loc = loc;
|
|
146
|
-
return error;
|
|
147
|
-
}
|
|
148
|
-
const errorMessages = {
|
|
149
|
-
// parse errors
|
|
150
|
-
[0]: "Illegal comment.",
|
|
151
|
-
[1]: "CDATA section is allowed only in XML context.",
|
|
152
|
-
[2]: "Duplicate attribute.",
|
|
153
|
-
[3]: "End tag cannot have attributes.",
|
|
154
|
-
[4]: "Illegal '/' in tags.",
|
|
155
|
-
[5]: "Unexpected EOF in tag.",
|
|
156
|
-
[6]: "Unexpected EOF in CDATA section.",
|
|
157
|
-
[7]: "Unexpected EOF in comment.",
|
|
158
|
-
[8]: "Unexpected EOF in script.",
|
|
159
|
-
[9]: "Unexpected EOF in tag.",
|
|
160
|
-
[10]: "Incorrectly closed comment.",
|
|
161
|
-
[11]: "Incorrectly opened comment.",
|
|
162
|
-
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
163
|
-
[13]: "Attribute value was expected.",
|
|
164
|
-
[14]: "End tag name was expected.",
|
|
165
|
-
[15]: "Whitespace was expected.",
|
|
166
|
-
[16]: "Unexpected '<!--' in comment.",
|
|
167
|
-
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
168
|
-
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
169
|
-
[19]: "Attribute name cannot start with '='.",
|
|
170
|
-
[21]: "'<?' is allowed only in XML context.",
|
|
171
|
-
[20]: `Unexpected null character.`,
|
|
172
|
-
[22]: "Illegal '/' in tags.",
|
|
173
|
-
// Vue-specific parse errors
|
|
174
|
-
[23]: "Invalid end tag.",
|
|
175
|
-
[24]: "Element is missing end tag.",
|
|
176
|
-
[25]: "Interpolation end sign was not found.",
|
|
177
|
-
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
178
|
-
[26]: "Legal directive name was expected.",
|
|
179
|
-
// transform errors
|
|
180
|
-
[28]: `v-if/v-else-if is missing expression.`,
|
|
181
|
-
[29]: `v-if/else branches must use unique keys.`,
|
|
182
|
-
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
183
|
-
[31]: `v-for is missing expression.`,
|
|
184
|
-
[32]: `v-for has invalid expression.`,
|
|
185
|
-
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
186
|
-
[34]: `v-bind is missing expression.`,
|
|
187
|
-
[35]: `v-on is missing expression.`,
|
|
188
|
-
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
189
|
-
[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.`,
|
|
190
|
-
[38]: `Duplicate slot names found. `,
|
|
191
|
-
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
192
|
-
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
193
|
-
[41]: `v-model is missing expression.`,
|
|
194
|
-
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
195
|
-
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
196
|
-
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
197
|
-
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
198
|
-
[45]: `Error parsing JavaScript expression: `,
|
|
199
|
-
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
200
|
-
// generic errors
|
|
201
|
-
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
202
|
-
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
203
|
-
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
204
|
-
[50]: `"scopeId" option is only supported in module mode.`,
|
|
205
|
-
// deprecations
|
|
206
|
-
[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.`,
|
|
207
|
-
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
208
|
-
// just to fulfill types
|
|
209
|
-
[53]: ``
|
|
210
|
-
};
|
|
211
|
-
|
|
212
127
|
const FRAGMENT = Symbol(`Fragment` );
|
|
213
128
|
const TELEPORT = Symbol(`Teleport` );
|
|
214
129
|
const SUSPENSE = Symbol(`Suspense` );
|
|
@@ -298,13 +213,14 @@ function registerRuntimeHelpers(helpers) {
|
|
|
298
213
|
}
|
|
299
214
|
|
|
300
215
|
const locStub = {
|
|
301
|
-
source: "",
|
|
302
216
|
start: { line: 1, column: 1, offset: 0 },
|
|
303
|
-
end: { line: 1, column: 1, offset: 0 }
|
|
217
|
+
end: { line: 1, column: 1, offset: 0 },
|
|
218
|
+
source: ""
|
|
304
219
|
};
|
|
305
|
-
function createRoot(children,
|
|
220
|
+
function createRoot(children, source = "") {
|
|
306
221
|
return {
|
|
307
222
|
type: 0,
|
|
223
|
+
source,
|
|
308
224
|
children,
|
|
309
225
|
helpers: /* @__PURE__ */ new Set(),
|
|
310
226
|
components: [],
|
|
@@ -314,7 +230,7 @@ function createRoot(children, loc = locStub) {
|
|
|
314
230
|
cached: 0,
|
|
315
231
|
temps: 0,
|
|
316
232
|
codegenNode: void 0,
|
|
317
|
-
loc
|
|
233
|
+
loc: locStub
|
|
318
234
|
};
|
|
319
235
|
}
|
|
320
236
|
function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
|
|
@@ -485,166 +401,1107 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
|
|
485
401
|
}
|
|
486
402
|
}
|
|
487
403
|
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
function
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
404
|
+
const defaultDelimitersOpen = new Uint8Array([123, 123]);
|
|
405
|
+
const defaultDelimitersClose = new Uint8Array([125, 125]);
|
|
406
|
+
function isTagStartChar(c) {
|
|
407
|
+
return c >= 97 && c <= 122 || c >= 65 && c <= 90;
|
|
408
|
+
}
|
|
409
|
+
function isWhitespace(c) {
|
|
410
|
+
return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
|
|
411
|
+
}
|
|
412
|
+
function isEndOfTagSection(c) {
|
|
413
|
+
return c === 47 || c === 62 || isWhitespace(c);
|
|
414
|
+
}
|
|
415
|
+
function toCharCodes(str) {
|
|
416
|
+
const ret = new Uint8Array(str.length);
|
|
417
|
+
for (let i = 0; i < str.length; i++) {
|
|
418
|
+
ret[i] = str.charCodeAt(i);
|
|
499
419
|
}
|
|
420
|
+
return ret;
|
|
500
421
|
}
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
422
|
+
const Sequences = {
|
|
423
|
+
Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
|
|
424
|
+
// CDATA[
|
|
425
|
+
CdataEnd: new Uint8Array([93, 93, 62]),
|
|
426
|
+
// ]]>
|
|
427
|
+
CommentEnd: new Uint8Array([45, 45, 62]),
|
|
428
|
+
// `-->`
|
|
429
|
+
ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
|
|
430
|
+
// `<\/script`
|
|
431
|
+
StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
|
|
432
|
+
// `</style`
|
|
433
|
+
TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
|
|
434
|
+
// `</title`
|
|
435
|
+
TextareaEnd: new Uint8Array([
|
|
436
|
+
60,
|
|
437
|
+
47,
|
|
438
|
+
116,
|
|
439
|
+
101,
|
|
440
|
+
120,
|
|
441
|
+
116,
|
|
442
|
+
97,
|
|
443
|
+
114,
|
|
444
|
+
101,
|
|
445
|
+
97
|
|
446
|
+
])
|
|
447
|
+
// `</textarea
|
|
448
|
+
};
|
|
449
|
+
class Tokenizer {
|
|
450
|
+
constructor(stack, cbs) {
|
|
451
|
+
this.stack = stack;
|
|
452
|
+
this.cbs = cbs;
|
|
453
|
+
/** The current state the tokenizer is in. */
|
|
454
|
+
this.state = 1;
|
|
455
|
+
/** The read buffer. */
|
|
456
|
+
this.buffer = "";
|
|
457
|
+
/** The beginning of the section that is currently being read. */
|
|
458
|
+
this.sectionStart = 0;
|
|
459
|
+
/** The index within the buffer that we are currently looking at. */
|
|
460
|
+
this.index = 0;
|
|
461
|
+
/** The start of the last entity. */
|
|
462
|
+
this.entityStart = 0;
|
|
463
|
+
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
464
|
+
this.baseState = 1;
|
|
465
|
+
/** For special parsing behavior inside of script and style tags. */
|
|
466
|
+
this.inRCDATA = false;
|
|
467
|
+
/** For disabling RCDATA tags handling */
|
|
468
|
+
this.inXML = false;
|
|
469
|
+
/** Reocrd newline positions for fast line / column calculation */
|
|
470
|
+
this.newlines = [];
|
|
471
|
+
this.mode = 0;
|
|
472
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
473
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
474
|
+
this.delimiterIndex = -1;
|
|
475
|
+
this.currentSequence = void 0;
|
|
476
|
+
this.sequenceIndex = 0;
|
|
477
|
+
}
|
|
478
|
+
get inSFCRoot() {
|
|
479
|
+
return this.mode === 2 && this.stack.length === 0;
|
|
480
|
+
}
|
|
481
|
+
reset() {
|
|
482
|
+
this.state = 1;
|
|
483
|
+
this.mode = 0;
|
|
484
|
+
this.buffer = "";
|
|
485
|
+
this.sectionStart = 0;
|
|
486
|
+
this.index = 0;
|
|
487
|
+
this.baseState = 1;
|
|
488
|
+
this.currentSequence = void 0;
|
|
489
|
+
this.newlines.length = 0;
|
|
490
|
+
this.delimiterOpen = defaultDelimitersOpen;
|
|
491
|
+
this.delimiterClose = defaultDelimitersClose;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Generate Position object with line / column information using recorded
|
|
495
|
+
* newline positions. We know the index is always going to be an already
|
|
496
|
+
* processed index, so all the newlines up to this index should have been
|
|
497
|
+
* recorded.
|
|
498
|
+
*/
|
|
499
|
+
getPos(index) {
|
|
500
|
+
let line = 1;
|
|
501
|
+
let column = index + 1;
|
|
502
|
+
for (let i = this.newlines.length - 1; i >= 0; i--) {
|
|
503
|
+
const newlineIndex = this.newlines[i];
|
|
504
|
+
if (index > newlineIndex) {
|
|
505
|
+
line = i + 2;
|
|
506
|
+
column = index - newlineIndex;
|
|
528
507
|
break;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return {
|
|
511
|
+
column,
|
|
512
|
+
line,
|
|
513
|
+
offset: index
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
peek() {
|
|
517
|
+
return this.buffer.charCodeAt(this.index + 1);
|
|
518
|
+
}
|
|
519
|
+
stateText(c) {
|
|
520
|
+
if (c === 60) {
|
|
521
|
+
if (this.index > this.sectionStart) {
|
|
522
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
523
|
+
}
|
|
524
|
+
this.state = 5;
|
|
525
|
+
this.sectionStart = this.index;
|
|
526
|
+
} else if (c === this.delimiterOpen[0]) {
|
|
527
|
+
this.state = 2;
|
|
528
|
+
this.delimiterIndex = 0;
|
|
529
|
+
this.stateInterpolationOpen(c);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
stateInterpolationOpen(c) {
|
|
533
|
+
if (c === this.delimiterOpen[this.delimiterIndex]) {
|
|
534
|
+
if (this.delimiterIndex === this.delimiterOpen.length - 1) {
|
|
535
|
+
const start = this.index + 1 - this.delimiterOpen.length;
|
|
536
|
+
if (start > this.sectionStart) {
|
|
537
|
+
this.cbs.ontext(this.sectionStart, start);
|
|
540
538
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
539
|
+
this.state = 3;
|
|
540
|
+
this.sectionStart = start;
|
|
541
|
+
} else {
|
|
542
|
+
this.delimiterIndex++;
|
|
543
|
+
}
|
|
544
|
+
} else if (this.inRCDATA) {
|
|
545
|
+
this.state = 32;
|
|
546
|
+
this.stateInRCDATA(c);
|
|
547
|
+
} else {
|
|
548
|
+
this.state = 1;
|
|
549
|
+
this.stateText(c);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
stateInterpolation(c) {
|
|
553
|
+
if (c === this.delimiterClose[0]) {
|
|
554
|
+
this.state = 4;
|
|
555
|
+
this.delimiterIndex = 0;
|
|
556
|
+
this.stateInterpolationClose(c);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
stateInterpolationClose(c) {
|
|
560
|
+
if (c === this.delimiterClose[this.delimiterIndex]) {
|
|
561
|
+
if (this.delimiterIndex === this.delimiterClose.length - 1) {
|
|
562
|
+
this.cbs.oninterpolation(this.sectionStart, this.index + 1);
|
|
563
|
+
if (this.inRCDATA) {
|
|
564
|
+
this.state = 32;
|
|
565
|
+
} else {
|
|
566
|
+
this.state = 1;
|
|
556
567
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
568
|
+
this.sectionStart = this.index + 1;
|
|
569
|
+
} else {
|
|
570
|
+
this.delimiterIndex++;
|
|
571
|
+
}
|
|
572
|
+
} else {
|
|
573
|
+
this.state = 3;
|
|
574
|
+
this.stateInterpolation(c);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
stateSpecialStartSequence(c) {
|
|
578
|
+
const isEnd = this.sequenceIndex === this.currentSequence.length;
|
|
579
|
+
const isMatch = isEnd ? (
|
|
580
|
+
// If we are at the end of the sequence, make sure the tag name has ended
|
|
581
|
+
isEndOfTagSection(c)
|
|
582
|
+
) : (
|
|
583
|
+
// Otherwise, do a case-insensitive comparison
|
|
584
|
+
(c | 32) === this.currentSequence[this.sequenceIndex]
|
|
585
|
+
);
|
|
586
|
+
if (!isMatch) {
|
|
587
|
+
this.inRCDATA = false;
|
|
588
|
+
} else if (!isEnd) {
|
|
589
|
+
this.sequenceIndex++;
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
this.sequenceIndex = 0;
|
|
593
|
+
this.state = 6;
|
|
594
|
+
this.stateInTagName(c);
|
|
595
|
+
}
|
|
596
|
+
/** Look for an end tag. For <title> and <textarea>, also decode entities. */
|
|
597
|
+
stateInRCDATA(c) {
|
|
598
|
+
if (this.sequenceIndex === this.currentSequence.length) {
|
|
599
|
+
if (c === 62 || isWhitespace(c)) {
|
|
600
|
+
const endOfText = this.index - this.currentSequence.length;
|
|
601
|
+
if (this.sectionStart < endOfText) {
|
|
602
|
+
const actualIndex = this.index;
|
|
603
|
+
this.index = endOfText;
|
|
604
|
+
this.cbs.ontext(this.sectionStart, endOfText);
|
|
605
|
+
this.index = actualIndex;
|
|
562
606
|
}
|
|
563
|
-
|
|
607
|
+
this.sectionStart = endOfText + 2;
|
|
608
|
+
this.stateInClosingTagName(c);
|
|
609
|
+
this.inRCDATA = false;
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
this.sequenceIndex = 0;
|
|
613
|
+
}
|
|
614
|
+
if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
|
|
615
|
+
this.sequenceIndex += 1;
|
|
616
|
+
} else if (this.sequenceIndex === 0) {
|
|
617
|
+
if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
|
|
618
|
+
if (c === this.delimiterOpen[0]) {
|
|
619
|
+
this.state = 2;
|
|
620
|
+
this.delimiterIndex = 0;
|
|
621
|
+
this.stateInterpolationOpen(c);
|
|
622
|
+
}
|
|
623
|
+
} else if (this.fastForwardTo(60)) {
|
|
624
|
+
this.sequenceIndex = 1;
|
|
625
|
+
}
|
|
626
|
+
} else {
|
|
627
|
+
this.sequenceIndex = Number(c === 60);
|
|
564
628
|
}
|
|
565
629
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
630
|
+
stateCDATASequence(c) {
|
|
631
|
+
if (c === Sequences.Cdata[this.sequenceIndex]) {
|
|
632
|
+
if (++this.sequenceIndex === Sequences.Cdata.length) {
|
|
633
|
+
this.state = 28;
|
|
634
|
+
this.currentSequence = Sequences.CdataEnd;
|
|
635
|
+
this.sequenceIndex = 0;
|
|
636
|
+
this.sectionStart = this.index + 1;
|
|
637
|
+
}
|
|
638
|
+
} else {
|
|
639
|
+
this.sequenceIndex = 0;
|
|
640
|
+
this.state = 23;
|
|
641
|
+
this.stateInDeclaration(c);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* When we wait for one specific character, we can speed things up
|
|
646
|
+
* by skipping through the buffer until we find it.
|
|
647
|
+
*
|
|
648
|
+
* @returns Whether the character was found.
|
|
649
|
+
*/
|
|
650
|
+
fastForwardTo(c) {
|
|
651
|
+
while (++this.index < this.buffer.length) {
|
|
652
|
+
const cc = this.buffer.charCodeAt(this.index);
|
|
653
|
+
if (cc === 10) {
|
|
654
|
+
this.newlines.push(this.index);
|
|
655
|
+
}
|
|
656
|
+
if (cc === c) {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
this.index = this.buffer.length - 1;
|
|
661
|
+
return false;
|
|
583
662
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
663
|
+
/**
|
|
664
|
+
* Comments and CDATA end with `-->` and `]]>`.
|
|
665
|
+
*
|
|
666
|
+
* Their common qualities are:
|
|
667
|
+
* - Their end sequences have a distinct character they start with.
|
|
668
|
+
* - That character is then repeated, so we have to check multiple repeats.
|
|
669
|
+
* - All characters but the start character of the sequence can be skipped.
|
|
670
|
+
*/
|
|
671
|
+
stateInCommentLike(c) {
|
|
672
|
+
if (c === this.currentSequence[this.sequenceIndex]) {
|
|
673
|
+
if (++this.sequenceIndex === this.currentSequence.length) {
|
|
674
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
675
|
+
this.cbs.oncdata(this.sectionStart, this.index - 2);
|
|
676
|
+
} else {
|
|
677
|
+
this.cbs.oncomment(this.sectionStart, this.index - 2);
|
|
678
|
+
}
|
|
679
|
+
this.sequenceIndex = 0;
|
|
680
|
+
this.sectionStart = this.index + 1;
|
|
681
|
+
this.state = 1;
|
|
682
|
+
}
|
|
683
|
+
} else if (this.sequenceIndex === 0) {
|
|
684
|
+
if (this.fastForwardTo(this.currentSequence[0])) {
|
|
685
|
+
this.sequenceIndex = 1;
|
|
686
|
+
}
|
|
687
|
+
} else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
|
|
688
|
+
this.sequenceIndex = 0;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
startSpecial(sequence, offset) {
|
|
692
|
+
this.enterRCDATA(sequence, offset);
|
|
693
|
+
this.state = 31;
|
|
694
|
+
}
|
|
695
|
+
enterRCDATA(sequence, offset) {
|
|
696
|
+
this.inRCDATA = true;
|
|
697
|
+
this.currentSequence = sequence;
|
|
698
|
+
this.sequenceIndex = offset;
|
|
699
|
+
}
|
|
700
|
+
stateBeforeTagName(c) {
|
|
701
|
+
if (c === 33) {
|
|
702
|
+
this.state = 22;
|
|
703
|
+
this.sectionStart = this.index + 1;
|
|
704
|
+
} else if (c === 63) {
|
|
705
|
+
this.state = 24;
|
|
706
|
+
this.sectionStart = this.index + 1;
|
|
707
|
+
} else if (isTagStartChar(c)) {
|
|
708
|
+
this.sectionStart = this.index;
|
|
709
|
+
if (this.mode === 0) {
|
|
710
|
+
this.state = 6;
|
|
711
|
+
} else if (this.inSFCRoot) {
|
|
712
|
+
this.state = 34;
|
|
713
|
+
} else if (!this.inXML) {
|
|
714
|
+
const lower = c | 32;
|
|
715
|
+
if (lower === 116) {
|
|
716
|
+
this.state = 30;
|
|
717
|
+
} else {
|
|
718
|
+
this.state = lower === 115 ? 29 : 6;
|
|
719
|
+
}
|
|
720
|
+
} else {
|
|
721
|
+
this.state = 6;
|
|
722
|
+
}
|
|
723
|
+
} else if (c === 47) {
|
|
724
|
+
this.state = 8;
|
|
725
|
+
} else {
|
|
726
|
+
this.state = 1;
|
|
727
|
+
this.stateText(c);
|
|
600
728
|
}
|
|
601
729
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
607
|
-
function assert(condition, msg) {
|
|
608
|
-
if (!condition) {
|
|
609
|
-
throw new Error(msg || `unexpected compiler condition`);
|
|
730
|
+
stateInTagName(c) {
|
|
731
|
+
if (isEndOfTagSection(c)) {
|
|
732
|
+
this.handleTagName(c);
|
|
733
|
+
}
|
|
610
734
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
735
|
+
stateInSFCRootTagName(c) {
|
|
736
|
+
if (isEndOfTagSection(c)) {
|
|
737
|
+
const tag = this.buffer.slice(this.sectionStart, this.index);
|
|
738
|
+
if (tag !== "template") {
|
|
739
|
+
this.enterRCDATA(toCharCodes(`</` + tag), 0);
|
|
740
|
+
}
|
|
741
|
+
this.handleTagName(c);
|
|
617
742
|
}
|
|
618
743
|
}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
744
|
+
handleTagName(c) {
|
|
745
|
+
this.cbs.onopentagname(this.sectionStart, this.index);
|
|
746
|
+
this.sectionStart = -1;
|
|
747
|
+
this.state = 11;
|
|
748
|
+
this.stateBeforeAttrName(c);
|
|
749
|
+
}
|
|
750
|
+
stateBeforeClosingTagName(c) {
|
|
751
|
+
if (isWhitespace(c)) ; else if (c === 62) {
|
|
752
|
+
{
|
|
753
|
+
this.cbs.onerr(14, this.index);
|
|
628
754
|
}
|
|
629
|
-
|
|
630
|
-
|
|
755
|
+
this.state = 1;
|
|
756
|
+
this.sectionStart = this.index + 1;
|
|
757
|
+
} else {
|
|
758
|
+
this.state = isTagStartChar(c) ? 9 : 27;
|
|
759
|
+
this.sectionStart = this.index;
|
|
631
760
|
}
|
|
632
761
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
762
|
+
stateInClosingTagName(c) {
|
|
763
|
+
if (c === 62 || isWhitespace(c)) {
|
|
764
|
+
this.cbs.onclosetag(this.sectionStart, this.index);
|
|
765
|
+
this.sectionStart = -1;
|
|
766
|
+
this.state = 10;
|
|
767
|
+
this.stateAfterClosingTagName(c);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
stateAfterClosingTagName(c) {
|
|
771
|
+
if (c === 62) {
|
|
772
|
+
this.state = 1;
|
|
773
|
+
this.sectionStart = this.index + 1;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
stateBeforeAttrName(c) {
|
|
777
|
+
if (c === 62) {
|
|
778
|
+
this.cbs.onopentagend(this.index);
|
|
779
|
+
if (this.inRCDATA) {
|
|
780
|
+
this.state = 32;
|
|
781
|
+
} else {
|
|
782
|
+
this.state = 1;
|
|
783
|
+
}
|
|
784
|
+
this.sectionStart = this.index + 1;
|
|
785
|
+
} else if (c === 47) {
|
|
786
|
+
this.state = 7;
|
|
787
|
+
if (this.peek() !== 62) {
|
|
788
|
+
this.cbs.onerr(22, this.index);
|
|
789
|
+
}
|
|
790
|
+
} else if (c === 60 && this.peek() === 47) {
|
|
791
|
+
this.cbs.onopentagend(this.index);
|
|
792
|
+
this.state = 5;
|
|
793
|
+
this.sectionStart = this.index;
|
|
794
|
+
} else if (!isWhitespace(c)) {
|
|
795
|
+
if (c === 61) {
|
|
796
|
+
this.cbs.onerr(
|
|
797
|
+
19,
|
|
798
|
+
this.index
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
this.handleAttrStart(c);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
handleAttrStart(c) {
|
|
805
|
+
if (c === 118 && this.peek() === 45) {
|
|
806
|
+
this.state = 13;
|
|
807
|
+
this.sectionStart = this.index;
|
|
808
|
+
} else if (c === 46 || c === 58 || c === 64 || c === 35) {
|
|
809
|
+
this.cbs.ondirname(this.index, this.index + 1);
|
|
810
|
+
this.state = 14;
|
|
811
|
+
this.sectionStart = this.index + 1;
|
|
812
|
+
} else {
|
|
813
|
+
this.state = 12;
|
|
814
|
+
this.sectionStart = this.index;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
stateInSelfClosingTag(c) {
|
|
818
|
+
if (c === 62) {
|
|
819
|
+
this.cbs.onselfclosingtag(this.index);
|
|
820
|
+
this.state = 1;
|
|
821
|
+
this.sectionStart = this.index + 1;
|
|
822
|
+
this.inRCDATA = false;
|
|
823
|
+
} else if (!isWhitespace(c)) {
|
|
824
|
+
this.state = 11;
|
|
825
|
+
this.stateBeforeAttrName(c);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
stateInAttrName(c) {
|
|
829
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
830
|
+
this.cbs.onattribname(this.sectionStart, this.index);
|
|
831
|
+
this.handleAttrNameEnd(c);
|
|
832
|
+
} else if (c === 34 || c === 39 || c === 60) {
|
|
833
|
+
this.cbs.onerr(
|
|
834
|
+
17,
|
|
835
|
+
this.index
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
stateInDirName(c) {
|
|
840
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
841
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
842
|
+
this.handleAttrNameEnd(c);
|
|
843
|
+
} else if (c === 58) {
|
|
844
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
845
|
+
this.state = 14;
|
|
846
|
+
this.sectionStart = this.index + 1;
|
|
847
|
+
} else if (c === 46) {
|
|
848
|
+
this.cbs.ondirname(this.sectionStart, this.index);
|
|
849
|
+
this.state = 16;
|
|
850
|
+
this.sectionStart = this.index + 1;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
stateInDirArg(c) {
|
|
854
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
855
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
856
|
+
this.handleAttrNameEnd(c);
|
|
857
|
+
} else if (c === 91) {
|
|
858
|
+
this.state = 15;
|
|
859
|
+
} else if (c === 46) {
|
|
860
|
+
this.cbs.ondirarg(this.sectionStart, this.index);
|
|
861
|
+
this.state = 16;
|
|
862
|
+
this.sectionStart = this.index + 1;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
stateInDynamicDirArg(c) {
|
|
866
|
+
if (c === 93) {
|
|
867
|
+
this.state = 14;
|
|
868
|
+
} else if (c === 61 || isEndOfTagSection(c)) {
|
|
869
|
+
this.cbs.ondirarg(this.sectionStart, this.index + 1);
|
|
870
|
+
this.handleAttrNameEnd(c);
|
|
871
|
+
{
|
|
872
|
+
this.cbs.onerr(
|
|
873
|
+
27,
|
|
874
|
+
this.index
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
stateInDirModifier(c) {
|
|
880
|
+
if (c === 61 || isEndOfTagSection(c)) {
|
|
881
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
882
|
+
this.handleAttrNameEnd(c);
|
|
883
|
+
} else if (c === 46) {
|
|
884
|
+
this.cbs.ondirmodifier(this.sectionStart, this.index);
|
|
885
|
+
this.sectionStart = this.index + 1;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
handleAttrNameEnd(c) {
|
|
889
|
+
this.sectionStart = this.index;
|
|
890
|
+
this.state = 17;
|
|
891
|
+
this.cbs.onattribnameend(this.index);
|
|
892
|
+
this.stateAfterAttrName(c);
|
|
893
|
+
}
|
|
894
|
+
stateAfterAttrName(c) {
|
|
895
|
+
if (c === 61) {
|
|
896
|
+
this.state = 18;
|
|
897
|
+
} else if (c === 47 || c === 62) {
|
|
898
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
899
|
+
this.sectionStart = -1;
|
|
900
|
+
this.state = 11;
|
|
901
|
+
this.stateBeforeAttrName(c);
|
|
902
|
+
} else if (!isWhitespace(c)) {
|
|
903
|
+
this.cbs.onattribend(0, this.sectionStart);
|
|
904
|
+
this.handleAttrStart(c);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
stateBeforeAttrValue(c) {
|
|
908
|
+
if (c === 34) {
|
|
909
|
+
this.state = 19;
|
|
910
|
+
this.sectionStart = this.index + 1;
|
|
911
|
+
} else if (c === 39) {
|
|
912
|
+
this.state = 20;
|
|
913
|
+
this.sectionStart = this.index + 1;
|
|
914
|
+
} else if (!isWhitespace(c)) {
|
|
915
|
+
this.sectionStart = this.index;
|
|
916
|
+
this.state = 21;
|
|
917
|
+
this.stateInAttrValueNoQuotes(c);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
handleInAttrValue(c, quote) {
|
|
921
|
+
if (c === quote || this.fastForwardTo(quote)) {
|
|
922
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
923
|
+
this.sectionStart = -1;
|
|
924
|
+
this.cbs.onattribend(
|
|
925
|
+
quote === 34 ? 3 : 2,
|
|
926
|
+
this.index + 1
|
|
927
|
+
);
|
|
928
|
+
this.state = 11;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
stateInAttrValueDoubleQuotes(c) {
|
|
932
|
+
this.handleInAttrValue(c, 34);
|
|
933
|
+
}
|
|
934
|
+
stateInAttrValueSingleQuotes(c) {
|
|
935
|
+
this.handleInAttrValue(c, 39);
|
|
936
|
+
}
|
|
937
|
+
stateInAttrValueNoQuotes(c) {
|
|
938
|
+
if (isWhitespace(c) || c === 62) {
|
|
939
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
940
|
+
this.sectionStart = -1;
|
|
941
|
+
this.cbs.onattribend(1, this.index);
|
|
942
|
+
this.state = 11;
|
|
943
|
+
this.stateBeforeAttrName(c);
|
|
944
|
+
} else if (c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
|
|
945
|
+
this.cbs.onerr(
|
|
946
|
+
18,
|
|
947
|
+
this.index
|
|
948
|
+
);
|
|
949
|
+
} else ;
|
|
950
|
+
}
|
|
951
|
+
stateBeforeDeclaration(c) {
|
|
952
|
+
if (c === 91) {
|
|
953
|
+
this.state = 26;
|
|
954
|
+
this.sequenceIndex = 0;
|
|
955
|
+
} else {
|
|
956
|
+
this.state = c === 45 ? 25 : 23;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
stateInDeclaration(c) {
|
|
960
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
961
|
+
this.state = 1;
|
|
962
|
+
this.sectionStart = this.index + 1;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
stateInProcessingInstruction(c) {
|
|
966
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
967
|
+
this.cbs.onprocessinginstruction(this.sectionStart, this.index);
|
|
968
|
+
this.state = 1;
|
|
969
|
+
this.sectionStart = this.index + 1;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
stateBeforeComment(c) {
|
|
973
|
+
if (c === 45) {
|
|
974
|
+
this.state = 28;
|
|
975
|
+
this.currentSequence = Sequences.CommentEnd;
|
|
976
|
+
this.sequenceIndex = 2;
|
|
977
|
+
this.sectionStart = this.index + 1;
|
|
978
|
+
} else {
|
|
979
|
+
this.state = 23;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
stateInSpecialComment(c) {
|
|
983
|
+
if (c === 62 || this.fastForwardTo(62)) {
|
|
984
|
+
this.cbs.oncomment(this.sectionStart, this.index);
|
|
985
|
+
this.state = 1;
|
|
986
|
+
this.sectionStart = this.index + 1;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
stateBeforeSpecialS(c) {
|
|
990
|
+
const lower = c | 32;
|
|
991
|
+
if (lower === Sequences.ScriptEnd[3]) {
|
|
992
|
+
this.startSpecial(Sequences.ScriptEnd, 4);
|
|
993
|
+
} else if (lower === Sequences.StyleEnd[3]) {
|
|
994
|
+
this.startSpecial(Sequences.StyleEnd, 4);
|
|
995
|
+
} else {
|
|
996
|
+
this.state = 6;
|
|
997
|
+
this.stateInTagName(c);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
stateBeforeSpecialT(c) {
|
|
1001
|
+
const lower = c | 32;
|
|
1002
|
+
if (lower === Sequences.TitleEnd[3]) {
|
|
1003
|
+
this.startSpecial(Sequences.TitleEnd, 4);
|
|
1004
|
+
} else if (lower === Sequences.TextareaEnd[3]) {
|
|
1005
|
+
this.startSpecial(Sequences.TextareaEnd, 4);
|
|
1006
|
+
} else {
|
|
1007
|
+
this.state = 6;
|
|
1008
|
+
this.stateInTagName(c);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
startEntity() {
|
|
1012
|
+
}
|
|
1013
|
+
stateInEntity() {
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
1017
|
+
*
|
|
1018
|
+
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
1019
|
+
*/
|
|
1020
|
+
parse(input) {
|
|
1021
|
+
this.buffer = input;
|
|
1022
|
+
while (this.index < this.buffer.length) {
|
|
1023
|
+
const c = this.buffer.charCodeAt(this.index);
|
|
1024
|
+
if (c === 10) {
|
|
1025
|
+
this.newlines.push(this.index);
|
|
1026
|
+
}
|
|
1027
|
+
switch (this.state) {
|
|
1028
|
+
case 1: {
|
|
1029
|
+
this.stateText(c);
|
|
1030
|
+
break;
|
|
1031
|
+
}
|
|
1032
|
+
case 2: {
|
|
1033
|
+
this.stateInterpolationOpen(c);
|
|
1034
|
+
break;
|
|
1035
|
+
}
|
|
1036
|
+
case 3: {
|
|
1037
|
+
this.stateInterpolation(c);
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
case 4: {
|
|
1041
|
+
this.stateInterpolationClose(c);
|
|
1042
|
+
break;
|
|
1043
|
+
}
|
|
1044
|
+
case 31: {
|
|
1045
|
+
this.stateSpecialStartSequence(c);
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
1048
|
+
case 32: {
|
|
1049
|
+
this.stateInRCDATA(c);
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
case 26: {
|
|
1053
|
+
this.stateCDATASequence(c);
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
case 19: {
|
|
1057
|
+
this.stateInAttrValueDoubleQuotes(c);
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
case 12: {
|
|
1061
|
+
this.stateInAttrName(c);
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
case 13: {
|
|
1065
|
+
this.stateInDirName(c);
|
|
1066
|
+
break;
|
|
1067
|
+
}
|
|
1068
|
+
case 14: {
|
|
1069
|
+
this.stateInDirArg(c);
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
case 15: {
|
|
1073
|
+
this.stateInDynamicDirArg(c);
|
|
1074
|
+
break;
|
|
1075
|
+
}
|
|
1076
|
+
case 16: {
|
|
1077
|
+
this.stateInDirModifier(c);
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
case 28: {
|
|
1081
|
+
this.stateInCommentLike(c);
|
|
1082
|
+
break;
|
|
1083
|
+
}
|
|
1084
|
+
case 27: {
|
|
1085
|
+
this.stateInSpecialComment(c);
|
|
1086
|
+
break;
|
|
1087
|
+
}
|
|
1088
|
+
case 11: {
|
|
1089
|
+
this.stateBeforeAttrName(c);
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
case 6: {
|
|
1093
|
+
this.stateInTagName(c);
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
case 34: {
|
|
1097
|
+
this.stateInSFCRootTagName(c);
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1100
|
+
case 9: {
|
|
1101
|
+
this.stateInClosingTagName(c);
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
case 5: {
|
|
1105
|
+
this.stateBeforeTagName(c);
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case 17: {
|
|
1109
|
+
this.stateAfterAttrName(c);
|
|
1110
|
+
break;
|
|
1111
|
+
}
|
|
1112
|
+
case 20: {
|
|
1113
|
+
this.stateInAttrValueSingleQuotes(c);
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
case 18: {
|
|
1117
|
+
this.stateBeforeAttrValue(c);
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
case 8: {
|
|
1121
|
+
this.stateBeforeClosingTagName(c);
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
case 10: {
|
|
1125
|
+
this.stateAfterClosingTagName(c);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
case 29: {
|
|
1129
|
+
this.stateBeforeSpecialS(c);
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
case 30: {
|
|
1133
|
+
this.stateBeforeSpecialT(c);
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
case 21: {
|
|
1137
|
+
this.stateInAttrValueNoQuotes(c);
|
|
1138
|
+
break;
|
|
1139
|
+
}
|
|
1140
|
+
case 7: {
|
|
1141
|
+
this.stateInSelfClosingTag(c);
|
|
1142
|
+
break;
|
|
1143
|
+
}
|
|
1144
|
+
case 23: {
|
|
1145
|
+
this.stateInDeclaration(c);
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
case 22: {
|
|
1149
|
+
this.stateBeforeDeclaration(c);
|
|
1150
|
+
break;
|
|
1151
|
+
}
|
|
1152
|
+
case 25: {
|
|
1153
|
+
this.stateBeforeComment(c);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
case 24: {
|
|
1157
|
+
this.stateInProcessingInstruction(c);
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
case 33: {
|
|
1161
|
+
this.stateInEntity();
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
this.index++;
|
|
1166
|
+
}
|
|
1167
|
+
this.cleanup();
|
|
1168
|
+
this.finish();
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Remove data that has already been consumed from the buffer.
|
|
1172
|
+
*/
|
|
1173
|
+
cleanup() {
|
|
1174
|
+
if (this.sectionStart !== this.index) {
|
|
1175
|
+
if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
|
|
1176
|
+
this.cbs.ontext(this.sectionStart, this.index);
|
|
1177
|
+
this.sectionStart = this.index;
|
|
1178
|
+
} else if (this.state === 19 || this.state === 20 || this.state === 21) {
|
|
1179
|
+
this.cbs.onattribdata(this.sectionStart, this.index);
|
|
1180
|
+
this.sectionStart = this.index;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
finish() {
|
|
1185
|
+
this.handleTrailingData();
|
|
1186
|
+
this.cbs.onend();
|
|
1187
|
+
}
|
|
1188
|
+
/** Handle any trailing data. */
|
|
1189
|
+
handleTrailingData() {
|
|
1190
|
+
const endIndex = this.buffer.length;
|
|
1191
|
+
if (this.sectionStart >= endIndex) {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
if (this.state === 28) {
|
|
1195
|
+
if (this.currentSequence === Sequences.CdataEnd) {
|
|
1196
|
+
this.cbs.oncdata(this.sectionStart, endIndex);
|
|
1197
|
+
} else {
|
|
1198
|
+
this.cbs.oncomment(this.sectionStart, endIndex);
|
|
1199
|
+
}
|
|
1200
|
+
} 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 {
|
|
1201
|
+
this.cbs.ontext(this.sectionStart, endIndex);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
emitCodePoint(cp, consumed) {
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
const deprecationData = {
|
|
1209
|
+
["COMPILER_IS_ON_ELEMENT"]: {
|
|
1210
|
+
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:".`,
|
|
1211
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
1212
|
+
},
|
|
1213
|
+
["COMPILER_V_BIND_SYNC"]: {
|
|
1214
|
+
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}\`.`,
|
|
1215
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
1216
|
+
},
|
|
1217
|
+
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
1218
|
+
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.`,
|
|
1219
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
1220
|
+
},
|
|
1221
|
+
["COMPILER_V_ON_NATIVE"]: {
|
|
1222
|
+
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
1223
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
1224
|
+
},
|
|
1225
|
+
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
1226
|
+
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.`,
|
|
1227
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
1228
|
+
},
|
|
1229
|
+
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
1230
|
+
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
1231
|
+
},
|
|
1232
|
+
["COMPILER_INLINE_TEMPLATE"]: {
|
|
1233
|
+
message: `"inline-template" has been removed in Vue 3.`,
|
|
1234
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
1235
|
+
},
|
|
1236
|
+
["COMPILER_FILTER"]: {
|
|
1237
|
+
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.`,
|
|
1238
|
+
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
function getCompatValue(key, { compatConfig }) {
|
|
1242
|
+
const value = compatConfig && compatConfig[key];
|
|
1243
|
+
if (key === "MODE") {
|
|
1244
|
+
return value || 3;
|
|
1245
|
+
} else {
|
|
1246
|
+
return value;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function isCompatEnabled(key, context) {
|
|
1250
|
+
const mode = getCompatValue("MODE", context);
|
|
1251
|
+
const value = getCompatValue(key, context);
|
|
1252
|
+
return mode === 3 ? value === true : value !== false;
|
|
1253
|
+
}
|
|
1254
|
+
function checkCompatEnabled(key, context, loc, ...args) {
|
|
1255
|
+
const enabled = isCompatEnabled(key, context);
|
|
1256
|
+
if (enabled) {
|
|
1257
|
+
warnDeprecation(key, context, loc, ...args);
|
|
1258
|
+
}
|
|
1259
|
+
return enabled;
|
|
1260
|
+
}
|
|
1261
|
+
function warnDeprecation(key, context, loc, ...args) {
|
|
1262
|
+
const val = getCompatValue(key, context);
|
|
1263
|
+
if (val === "suppress-warning") {
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
const { message, link } = deprecationData[key];
|
|
1267
|
+
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
1268
|
+
Details: ${link}` : ``}`;
|
|
1269
|
+
const err = new SyntaxError(msg);
|
|
1270
|
+
err.code = key;
|
|
1271
|
+
if (loc)
|
|
1272
|
+
err.loc = loc;
|
|
1273
|
+
context.onWarn(err);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
function defaultOnError(error) {
|
|
1277
|
+
throw error;
|
|
1278
|
+
}
|
|
1279
|
+
function defaultOnWarn(msg) {
|
|
1280
|
+
console.warn(`[Vue warn] ${msg.message}`);
|
|
1281
|
+
}
|
|
1282
|
+
function createCompilerError(code, loc, messages, additionalMessage) {
|
|
1283
|
+
const msg = (messages || errorMessages)[code] + (additionalMessage || ``) ;
|
|
1284
|
+
const error = new SyntaxError(String(msg));
|
|
1285
|
+
error.code = code;
|
|
1286
|
+
error.loc = loc;
|
|
1287
|
+
return error;
|
|
1288
|
+
}
|
|
1289
|
+
const errorMessages = {
|
|
1290
|
+
// parse errors
|
|
1291
|
+
[0]: "Illegal comment.",
|
|
1292
|
+
[1]: "CDATA section is allowed only in XML context.",
|
|
1293
|
+
[2]: "Duplicate attribute.",
|
|
1294
|
+
[3]: "End tag cannot have attributes.",
|
|
1295
|
+
[4]: "Illegal '/' in tags.",
|
|
1296
|
+
[5]: "Unexpected EOF in tag.",
|
|
1297
|
+
[6]: "Unexpected EOF in CDATA section.",
|
|
1298
|
+
[7]: "Unexpected EOF in comment.",
|
|
1299
|
+
[8]: "Unexpected EOF in script.",
|
|
1300
|
+
[9]: "Unexpected EOF in tag.",
|
|
1301
|
+
[10]: "Incorrectly closed comment.",
|
|
1302
|
+
[11]: "Incorrectly opened comment.",
|
|
1303
|
+
[12]: "Illegal tag name. Use '<' to print '<'.",
|
|
1304
|
+
[13]: "Attribute value was expected.",
|
|
1305
|
+
[14]: "End tag name was expected.",
|
|
1306
|
+
[15]: "Whitespace was expected.",
|
|
1307
|
+
[16]: "Unexpected '<!--' in comment.",
|
|
1308
|
+
[17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
|
|
1309
|
+
[18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
|
|
1310
|
+
[19]: "Attribute name cannot start with '='.",
|
|
1311
|
+
[21]: "'<?' is allowed only in XML context.",
|
|
1312
|
+
[20]: `Unexpected null character.`,
|
|
1313
|
+
[22]: "Illegal '/' in tags.",
|
|
1314
|
+
// Vue-specific parse errors
|
|
1315
|
+
[23]: "Invalid end tag.",
|
|
1316
|
+
[24]: "Element is missing end tag.",
|
|
1317
|
+
[25]: "Interpolation end sign was not found.",
|
|
1318
|
+
[27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
|
|
1319
|
+
[26]: "Legal directive name was expected.",
|
|
1320
|
+
// transform errors
|
|
1321
|
+
[28]: `v-if/v-else-if is missing expression.`,
|
|
1322
|
+
[29]: `v-if/else branches must use unique keys.`,
|
|
1323
|
+
[30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
|
|
1324
|
+
[31]: `v-for is missing expression.`,
|
|
1325
|
+
[32]: `v-for has invalid expression.`,
|
|
1326
|
+
[33]: `<template v-for> key should be placed on the <template> tag.`,
|
|
1327
|
+
[34]: `v-bind is missing expression.`,
|
|
1328
|
+
[35]: `v-on is missing expression.`,
|
|
1329
|
+
[36]: `Unexpected custom directive on <slot> outlet.`,
|
|
1330
|
+
[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.`,
|
|
1331
|
+
[38]: `Duplicate slot names found. `,
|
|
1332
|
+
[39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
|
|
1333
|
+
[40]: `v-slot can only be used on components or <template> tags.`,
|
|
1334
|
+
[41]: `v-model is missing expression.`,
|
|
1335
|
+
[42]: `v-model value must be a valid JavaScript member expression.`,
|
|
1336
|
+
[43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
|
|
1337
|
+
[44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
|
|
1338
|
+
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
1339
|
+
[45]: `Error parsing JavaScript expression: `,
|
|
1340
|
+
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
1341
|
+
// generic errors
|
|
1342
|
+
[47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
1343
|
+
[48]: `ES module mode is not supported in this build of compiler.`,
|
|
1344
|
+
[49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
1345
|
+
[50]: `"scopeId" option is only supported in module mode.`,
|
|
1346
|
+
// deprecations
|
|
1347
|
+
[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.`,
|
|
1348
|
+
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
1349
|
+
// just to fulfill types
|
|
1350
|
+
[53]: ``
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
1354
|
+
function isCoreComponent(tag) {
|
|
1355
|
+
switch (tag) {
|
|
1356
|
+
case "Teleport":
|
|
1357
|
+
case "teleport":
|
|
1358
|
+
return TELEPORT;
|
|
1359
|
+
case "Suspense":
|
|
1360
|
+
case "suspense":
|
|
1361
|
+
return SUSPENSE;
|
|
1362
|
+
case "KeepAlive":
|
|
1363
|
+
case "keep-alive":
|
|
1364
|
+
return KEEP_ALIVE;
|
|
1365
|
+
case "BaseTransition":
|
|
1366
|
+
case "base-transition":
|
|
1367
|
+
return BASE_TRANSITION;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
const nonIdentifierRE = /^\d|[^\$\w]/;
|
|
1371
|
+
const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
|
|
1372
|
+
const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
|
|
1373
|
+
const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
|
|
1374
|
+
const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
|
|
1375
|
+
const isMemberExpressionBrowser = (path) => {
|
|
1376
|
+
path = path.trim().replace(whitespaceRE, (s) => s.trim());
|
|
1377
|
+
let state = 0 /* inMemberExp */;
|
|
1378
|
+
let stateStack = [];
|
|
1379
|
+
let currentOpenBracketCount = 0;
|
|
1380
|
+
let currentOpenParensCount = 0;
|
|
1381
|
+
let currentStringType = null;
|
|
1382
|
+
for (let i = 0; i < path.length; i++) {
|
|
1383
|
+
const char = path.charAt(i);
|
|
1384
|
+
switch (state) {
|
|
1385
|
+
case 0 /* inMemberExp */:
|
|
1386
|
+
if (char === "[") {
|
|
1387
|
+
stateStack.push(state);
|
|
1388
|
+
state = 1 /* inBrackets */;
|
|
1389
|
+
currentOpenBracketCount++;
|
|
1390
|
+
} else if (char === "(") {
|
|
1391
|
+
stateStack.push(state);
|
|
1392
|
+
state = 2 /* inParens */;
|
|
1393
|
+
currentOpenParensCount++;
|
|
1394
|
+
} else if (!(i === 0 ? validFirstIdentCharRE : validIdentCharRE).test(char)) {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
break;
|
|
1398
|
+
case 1 /* inBrackets */:
|
|
1399
|
+
if (char === `'` || char === `"` || char === "`") {
|
|
1400
|
+
stateStack.push(state);
|
|
1401
|
+
state = 3 /* inString */;
|
|
1402
|
+
currentStringType = char;
|
|
1403
|
+
} else if (char === `[`) {
|
|
1404
|
+
currentOpenBracketCount++;
|
|
1405
|
+
} else if (char === `]`) {
|
|
1406
|
+
if (!--currentOpenBracketCount) {
|
|
1407
|
+
state = stateStack.pop();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
break;
|
|
1411
|
+
case 2 /* inParens */:
|
|
1412
|
+
if (char === `'` || char === `"` || char === "`") {
|
|
1413
|
+
stateStack.push(state);
|
|
1414
|
+
state = 3 /* inString */;
|
|
1415
|
+
currentStringType = char;
|
|
1416
|
+
} else if (char === `(`) {
|
|
1417
|
+
currentOpenParensCount++;
|
|
1418
|
+
} else if (char === `)`) {
|
|
1419
|
+
if (i === path.length - 1) {
|
|
1420
|
+
return false;
|
|
1421
|
+
}
|
|
1422
|
+
if (!--currentOpenParensCount) {
|
|
1423
|
+
state = stateStack.pop();
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
break;
|
|
1427
|
+
case 3 /* inString */:
|
|
1428
|
+
if (char === currentStringType) {
|
|
1429
|
+
state = stateStack.pop();
|
|
1430
|
+
currentStringType = null;
|
|
1431
|
+
}
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
1436
|
+
};
|
|
1437
|
+
const isMemberExpressionNode = NOOP ;
|
|
1438
|
+
const isMemberExpression = isMemberExpressionBrowser ;
|
|
1439
|
+
function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
|
|
1440
|
+
return advancePositionWithMutation(
|
|
1441
|
+
{
|
|
1442
|
+
offset: pos.offset,
|
|
1443
|
+
line: pos.line,
|
|
1444
|
+
column: pos.column
|
|
1445
|
+
},
|
|
1446
|
+
source,
|
|
1447
|
+
numberOfCharacters
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
function advancePositionWithMutation(pos, source, numberOfCharacters = source.length) {
|
|
1451
|
+
let linesCount = 0;
|
|
1452
|
+
let lastNewLinePos = -1;
|
|
1453
|
+
for (let i = 0; i < numberOfCharacters; i++) {
|
|
1454
|
+
if (source.charCodeAt(i) === 10) {
|
|
1455
|
+
linesCount++;
|
|
1456
|
+
lastNewLinePos = i;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
pos.offset += numberOfCharacters;
|
|
1460
|
+
pos.line += linesCount;
|
|
1461
|
+
pos.column = lastNewLinePos === -1 ? pos.column + numberOfCharacters : numberOfCharacters - lastNewLinePos;
|
|
1462
|
+
return pos;
|
|
1463
|
+
}
|
|
1464
|
+
function assert(condition, msg) {
|
|
1465
|
+
if (!condition) {
|
|
1466
|
+
throw new Error(msg || `unexpected compiler condition`);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function findDir(node, name, allowEmpty = false) {
|
|
1470
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1471
|
+
const p = node.props[i];
|
|
1472
|
+
if (p.type === 7 && (allowEmpty || p.exp) && (isString(name) ? p.name === name : name.test(p.name))) {
|
|
1473
|
+
return p;
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
|
|
1478
|
+
for (let i = 0; i < node.props.length; i++) {
|
|
1479
|
+
const p = node.props[i];
|
|
1480
|
+
if (p.type === 6) {
|
|
1481
|
+
if (dynamicOnly)
|
|
1482
|
+
continue;
|
|
1483
|
+
if (p.name === name && (p.value || allowEmpty)) {
|
|
1484
|
+
return p;
|
|
1485
|
+
}
|
|
1486
|
+
} else if (p.name === "bind" && (p.exp || allowEmpty) && isStaticArgOf(p.arg, name)) {
|
|
1487
|
+
return p;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function isStaticArgOf(arg, name) {
|
|
1492
|
+
return !!(arg && isStaticExp(arg) && arg.content === name);
|
|
1493
|
+
}
|
|
1494
|
+
function hasDynamicKeyVBind(node) {
|
|
1495
|
+
return node.props.some(
|
|
1496
|
+
(p) => p.type === 7 && p.name === "bind" && (!p.arg || // v-bind="obj"
|
|
1497
|
+
p.arg.type !== 4 || // v-bind:[_ctx.foo]
|
|
1498
|
+
!p.arg.isStatic)
|
|
1499
|
+
// v-bind:[foo]
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
function isText$1(node) {
|
|
1503
|
+
return node.type === 5 || node.type === 2;
|
|
1504
|
+
}
|
|
648
1505
|
function isVSlot(p) {
|
|
649
1506
|
return p.type === 7 && p.name === "slot";
|
|
650
1507
|
}
|
|
@@ -788,470 +1645,558 @@ function getMemoedVNodeCall(node) {
|
|
|
788
1645
|
}
|
|
789
1646
|
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
790
1647
|
|
|
791
|
-
const deprecationData = {
|
|
792
|
-
["COMPILER_IS_ON_ELEMENT"]: {
|
|
793
|
-
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:".`,
|
|
794
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
795
|
-
},
|
|
796
|
-
["COMPILER_V_BIND_SYNC"]: {
|
|
797
|
-
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}\`.`,
|
|
798
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
799
|
-
},
|
|
800
|
-
["COMPILER_V_BIND_PROP"]: {
|
|
801
|
-
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.`
|
|
802
|
-
},
|
|
803
|
-
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
804
|
-
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.`,
|
|
805
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
806
|
-
},
|
|
807
|
-
["COMPILER_V_ON_NATIVE"]: {
|
|
808
|
-
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
809
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
810
|
-
},
|
|
811
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
812
|
-
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.`,
|
|
813
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
814
|
-
},
|
|
815
|
-
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
816
|
-
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
817
|
-
},
|
|
818
|
-
["COMPILER_INLINE_TEMPLATE"]: {
|
|
819
|
-
message: `"inline-template" has been removed in Vue 3.`,
|
|
820
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
821
|
-
},
|
|
822
|
-
["COMPILER_FILTER"]: {
|
|
823
|
-
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.`,
|
|
824
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
function getCompatValue(key, context) {
|
|
828
|
-
const config = context.options ? context.options.compatConfig : context.compatConfig;
|
|
829
|
-
const value = config && config[key];
|
|
830
|
-
if (key === "MODE") {
|
|
831
|
-
return value || 3;
|
|
832
|
-
} else {
|
|
833
|
-
return value;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
function isCompatEnabled(key, context) {
|
|
837
|
-
const mode = getCompatValue("MODE", context);
|
|
838
|
-
const value = getCompatValue(key, context);
|
|
839
|
-
return mode === 3 ? value === true : value !== false;
|
|
840
|
-
}
|
|
841
|
-
function checkCompatEnabled(key, context, loc, ...args) {
|
|
842
|
-
const enabled = isCompatEnabled(key, context);
|
|
843
|
-
if (enabled) {
|
|
844
|
-
warnDeprecation(key, context, loc, ...args);
|
|
845
|
-
}
|
|
846
|
-
return enabled;
|
|
847
|
-
}
|
|
848
|
-
function warnDeprecation(key, context, loc, ...args) {
|
|
849
|
-
const val = getCompatValue(key, context);
|
|
850
|
-
if (val === "suppress-warning") {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
const { message, link } = deprecationData[key];
|
|
854
|
-
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
855
|
-
Details: ${link}` : ``}`;
|
|
856
|
-
const err = new SyntaxError(msg);
|
|
857
|
-
err.code = key;
|
|
858
|
-
if (loc)
|
|
859
|
-
err.loc = loc;
|
|
860
|
-
context.onWarn(err);
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
|
864
|
-
const decodeMap = {
|
|
865
|
-
gt: ">",
|
|
866
|
-
lt: "<",
|
|
867
|
-
amp: "&",
|
|
868
|
-
apos: "'",
|
|
869
|
-
quot: '"'
|
|
870
|
-
};
|
|
871
1648
|
const defaultParserOptions = {
|
|
1649
|
+
parseMode: "base",
|
|
1650
|
+
ns: 0,
|
|
872
1651
|
delimiters: [`{{`, `}}`],
|
|
873
1652
|
getNamespace: () => 0,
|
|
874
|
-
getTextMode: () => 0,
|
|
875
1653
|
isVoidTag: NO,
|
|
876
1654
|
isPreTag: NO,
|
|
877
1655
|
isCustomElement: NO,
|
|
878
|
-
decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
|
879
1656
|
onError: defaultOnError,
|
|
880
1657
|
onWarn: defaultOnWarn,
|
|
881
1658
|
comments: true
|
|
882
1659
|
};
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
let
|
|
916
|
-
if (
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1660
|
+
let currentOptions = defaultParserOptions;
|
|
1661
|
+
let currentRoot = null;
|
|
1662
|
+
let currentInput = "";
|
|
1663
|
+
let currentOpenTag = null;
|
|
1664
|
+
let currentProp = null;
|
|
1665
|
+
let currentAttrValue = "";
|
|
1666
|
+
let currentAttrStartIndex = -1;
|
|
1667
|
+
let currentAttrEndIndex = -1;
|
|
1668
|
+
let inPre = 0;
|
|
1669
|
+
let inVPre = false;
|
|
1670
|
+
let currentVPreBoundary = null;
|
|
1671
|
+
const stack = [];
|
|
1672
|
+
const tokenizer = new Tokenizer(stack, {
|
|
1673
|
+
onerr: emitError,
|
|
1674
|
+
ontext(start, end) {
|
|
1675
|
+
onText(getSlice(start, end), start, end);
|
|
1676
|
+
},
|
|
1677
|
+
ontextentity(char, start, end) {
|
|
1678
|
+
onText(char, start, end);
|
|
1679
|
+
},
|
|
1680
|
+
oninterpolation(start, end) {
|
|
1681
|
+
if (inVPre) {
|
|
1682
|
+
return onText(getSlice(start, end), start, end);
|
|
1683
|
+
}
|
|
1684
|
+
let innerStart = start + tokenizer.delimiterOpen.length;
|
|
1685
|
+
let innerEnd = end - tokenizer.delimiterClose.length;
|
|
1686
|
+
while (isWhitespace(currentInput.charCodeAt(innerStart))) {
|
|
1687
|
+
innerStart++;
|
|
1688
|
+
}
|
|
1689
|
+
while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
|
|
1690
|
+
innerEnd--;
|
|
1691
|
+
}
|
|
1692
|
+
let exp = getSlice(innerStart, innerEnd);
|
|
1693
|
+
if (exp.includes("&")) {
|
|
1694
|
+
{
|
|
1695
|
+
exp = currentOptions.decodeEntities(exp, false);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
addNode({
|
|
1699
|
+
type: 5,
|
|
1700
|
+
content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
|
|
1701
|
+
loc: getLoc(start, end)
|
|
1702
|
+
});
|
|
1703
|
+
},
|
|
1704
|
+
onopentagname(start, end) {
|
|
1705
|
+
const name = getSlice(start, end);
|
|
1706
|
+
currentOpenTag = {
|
|
1707
|
+
type: 1,
|
|
1708
|
+
tag: name,
|
|
1709
|
+
ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
|
|
1710
|
+
tagType: 0,
|
|
1711
|
+
// will be refined on tag close
|
|
1712
|
+
props: [],
|
|
1713
|
+
children: [],
|
|
1714
|
+
loc: getLoc(start - 1, end),
|
|
1715
|
+
codegenNode: void 0
|
|
1716
|
+
};
|
|
1717
|
+
if (tokenizer.inSFCRoot) {
|
|
1718
|
+
currentOpenTag.innerLoc = getLoc(
|
|
1719
|
+
end + fastForward(end) + 1,
|
|
1720
|
+
end
|
|
1721
|
+
);
|
|
1722
|
+
}
|
|
1723
|
+
},
|
|
1724
|
+
onopentagend(end) {
|
|
1725
|
+
endOpenTag(end);
|
|
1726
|
+
},
|
|
1727
|
+
onclosetag(start, end) {
|
|
1728
|
+
const name = getSlice(start, end);
|
|
1729
|
+
if (!currentOptions.isVoidTag(name)) {
|
|
1730
|
+
let found = false;
|
|
1731
|
+
for (let i = 0; i < stack.length; i++) {
|
|
1732
|
+
const e = stack[i];
|
|
1733
|
+
if (e.tag.toLowerCase() === name.toLowerCase()) {
|
|
1734
|
+
found = true;
|
|
1735
|
+
if (i > 0) {
|
|
1736
|
+
emitError(24, stack[0].loc.start.offset);
|
|
937
1737
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
} else if (s[2] === ">") {
|
|
942
|
-
emitError(context, 14, 2);
|
|
943
|
-
advanceBy(context, 3);
|
|
944
|
-
continue;
|
|
945
|
-
} else if (/[a-z]/i.test(s[2])) {
|
|
946
|
-
emitError(context, 23);
|
|
947
|
-
parseTag(context, 1 /* End */, parent);
|
|
948
|
-
continue;
|
|
949
|
-
} else {
|
|
950
|
-
emitError(
|
|
951
|
-
context,
|
|
952
|
-
12,
|
|
953
|
-
2
|
|
954
|
-
);
|
|
955
|
-
node = parseBogusComment(context);
|
|
1738
|
+
for (let j = 0; j <= i; j++) {
|
|
1739
|
+
const el = stack.shift();
|
|
1740
|
+
onCloseTag(el, end, j < i);
|
|
956
1741
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1742
|
+
break;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (!found) {
|
|
1746
|
+
emitError(23, backTrack(start, 60));
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
onselfclosingtag(end) {
|
|
1751
|
+
var _a;
|
|
1752
|
+
const name = currentOpenTag.tag;
|
|
1753
|
+
currentOpenTag.isSelfClosing = true;
|
|
1754
|
+
endOpenTag(end);
|
|
1755
|
+
if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
|
|
1756
|
+
onCloseTag(stack.shift(), end);
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
onattribname(start, end) {
|
|
1760
|
+
currentProp = {
|
|
1761
|
+
type: 6,
|
|
1762
|
+
name: getSlice(start, end),
|
|
1763
|
+
nameLoc: getLoc(start, end),
|
|
1764
|
+
value: void 0,
|
|
1765
|
+
loc: getLoc(start)
|
|
1766
|
+
};
|
|
1767
|
+
},
|
|
1768
|
+
ondirname(start, end) {
|
|
1769
|
+
const raw = getSlice(start, end);
|
|
1770
|
+
const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
|
|
1771
|
+
if (!inVPre && name === "") {
|
|
1772
|
+
emitError(26, start);
|
|
1773
|
+
}
|
|
1774
|
+
if (inVPre || name === "") {
|
|
1775
|
+
currentProp = {
|
|
1776
|
+
type: 6,
|
|
1777
|
+
name: raw,
|
|
1778
|
+
nameLoc: getLoc(start, end),
|
|
1779
|
+
value: void 0,
|
|
1780
|
+
loc: getLoc(start)
|
|
1781
|
+
};
|
|
1782
|
+
} else {
|
|
1783
|
+
currentProp = {
|
|
1784
|
+
type: 7,
|
|
1785
|
+
name,
|
|
1786
|
+
rawName: raw,
|
|
1787
|
+
exp: void 0,
|
|
1788
|
+
arg: void 0,
|
|
1789
|
+
modifiers: raw === "." ? ["prop"] : [],
|
|
1790
|
+
loc: getLoc(start)
|
|
1791
|
+
};
|
|
1792
|
+
if (name === "pre") {
|
|
1793
|
+
inVPre = true;
|
|
1794
|
+
currentVPreBoundary = currentOpenTag;
|
|
1795
|
+
const props = currentOpenTag.props;
|
|
1796
|
+
for (let i = 0; i < props.length; i++) {
|
|
1797
|
+
if (props[i].type === 7) {
|
|
1798
|
+
props[i] = dirToAttr(props[i]);
|
|
971
1799
|
}
|
|
972
|
-
} else if (s[1] === "?") {
|
|
973
|
-
emitError(
|
|
974
|
-
context,
|
|
975
|
-
21,
|
|
976
|
-
1
|
|
977
|
-
);
|
|
978
|
-
node = parseBogusComment(context);
|
|
979
|
-
} else {
|
|
980
|
-
emitError(context, 12, 1);
|
|
981
1800
|
}
|
|
982
1801
|
}
|
|
983
1802
|
}
|
|
984
|
-
|
|
985
|
-
|
|
1803
|
+
},
|
|
1804
|
+
ondirarg(start, end) {
|
|
1805
|
+
const arg = getSlice(start, end);
|
|
1806
|
+
if (inVPre) {
|
|
1807
|
+
currentProp.name += arg;
|
|
1808
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1809
|
+
} else {
|
|
1810
|
+
const isStatic = arg[0] !== `[`;
|
|
1811
|
+
currentProp.arg = createSimpleExpression(
|
|
1812
|
+
isStatic ? arg : arg.slice(1, -1),
|
|
1813
|
+
isStatic,
|
|
1814
|
+
getLoc(start, end),
|
|
1815
|
+
isStatic ? 3 : 0
|
|
1816
|
+
);
|
|
986
1817
|
}
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1818
|
+
},
|
|
1819
|
+
ondirmodifier(start, end) {
|
|
1820
|
+
const mod = getSlice(start, end);
|
|
1821
|
+
if (inVPre) {
|
|
1822
|
+
currentProp.name += "." + mod;
|
|
1823
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1824
|
+
} else if (currentProp.name === "slot") {
|
|
1825
|
+
const arg = currentProp.arg;
|
|
1826
|
+
if (arg) {
|
|
1827
|
+
arg.content += "." + mod;
|
|
1828
|
+
setLocEnd(arg.loc, end);
|
|
990
1829
|
}
|
|
991
1830
|
} else {
|
|
992
|
-
|
|
1831
|
+
currentProp.modifiers.push(mod);
|
|
993
1832
|
}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1833
|
+
},
|
|
1834
|
+
onattribdata(start, end) {
|
|
1835
|
+
currentAttrValue += getSlice(start, end);
|
|
1836
|
+
if (currentAttrStartIndex < 0)
|
|
1837
|
+
currentAttrStartIndex = start;
|
|
1838
|
+
currentAttrEndIndex = end;
|
|
1839
|
+
},
|
|
1840
|
+
onattribentity(char, start, end) {
|
|
1841
|
+
currentAttrValue += char;
|
|
1842
|
+
if (currentAttrStartIndex < 0)
|
|
1843
|
+
currentAttrStartIndex = start;
|
|
1844
|
+
currentAttrEndIndex = end;
|
|
1845
|
+
},
|
|
1846
|
+
onattribnameend(end) {
|
|
1847
|
+
const start = currentProp.loc.start.offset;
|
|
1848
|
+
const name = getSlice(start, end);
|
|
1849
|
+
if (currentProp.type === 7) {
|
|
1850
|
+
currentProp.rawName = name;
|
|
1851
|
+
}
|
|
1852
|
+
if (currentOpenTag.props.some(
|
|
1853
|
+
(p) => (p.type === 7 ? p.rawName : p.name) === name
|
|
1854
|
+
)) {
|
|
1855
|
+
emitError(2, start);
|
|
1856
|
+
}
|
|
1857
|
+
},
|
|
1858
|
+
onattribend(quote, end) {
|
|
1859
|
+
if (currentOpenTag && currentProp) {
|
|
1860
|
+
setLocEnd(currentProp.loc, end);
|
|
1861
|
+
if (quote !== 0) {
|
|
1862
|
+
if (currentAttrValue.includes("&")) {
|
|
1863
|
+
currentAttrValue = currentOptions.decodeEntities(
|
|
1864
|
+
currentAttrValue,
|
|
1865
|
+
true
|
|
1866
|
+
);
|
|
1867
|
+
}
|
|
1868
|
+
if (currentProp.type === 6) {
|
|
1869
|
+
if (currentProp.name === "class") {
|
|
1870
|
+
currentAttrValue = condense(currentAttrValue).trim();
|
|
1871
|
+
}
|
|
1872
|
+
if (quote === 1 && !currentAttrValue) {
|
|
1873
|
+
emitError(13, end);
|
|
1874
|
+
}
|
|
1875
|
+
currentProp.value = {
|
|
1876
|
+
type: 2,
|
|
1877
|
+
content: currentAttrValue,
|
|
1878
|
+
loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
|
1879
|
+
};
|
|
1880
|
+
if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
|
1881
|
+
tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
1013
1882
|
}
|
|
1014
1883
|
} else {
|
|
1015
|
-
|
|
1884
|
+
currentProp.exp = createSimpleExpression(
|
|
1885
|
+
currentAttrValue,
|
|
1886
|
+
false,
|
|
1887
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
1888
|
+
);
|
|
1889
|
+
if (currentProp.name === "for") {
|
|
1890
|
+
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
1891
|
+
}
|
|
1892
|
+
let syncIndex = -1;
|
|
1893
|
+
if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
|
|
1894
|
+
"COMPILER_V_BIND_SYNC",
|
|
1895
|
+
currentOptions,
|
|
1896
|
+
currentProp.loc,
|
|
1897
|
+
currentProp.rawName
|
|
1898
|
+
)) {
|
|
1899
|
+
currentProp.name = "model";
|
|
1900
|
+
currentProp.modifiers.splice(syncIndex, 1);
|
|
1901
|
+
}
|
|
1016
1902
|
}
|
|
1017
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
1018
|
-
removedWhitespace = true;
|
|
1019
|
-
nodes[i] = null;
|
|
1020
1903
|
}
|
|
1904
|
+
if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
|
1905
|
+
currentOpenTag.props.push(currentProp);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
currentAttrValue = "";
|
|
1909
|
+
currentAttrStartIndex = currentAttrEndIndex = -1;
|
|
1910
|
+
},
|
|
1911
|
+
oncomment(start, end) {
|
|
1912
|
+
if (currentOptions.comments) {
|
|
1913
|
+
addNode({
|
|
1914
|
+
type: 3,
|
|
1915
|
+
content: getSlice(start, end),
|
|
1916
|
+
loc: getLoc(start - 4, end + 3)
|
|
1917
|
+
});
|
|
1021
1918
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1919
|
+
},
|
|
1920
|
+
onend() {
|
|
1921
|
+
const end = currentInput.length;
|
|
1922
|
+
if (tokenizer.state !== 1) {
|
|
1923
|
+
switch (tokenizer.state) {
|
|
1924
|
+
case 5:
|
|
1925
|
+
case 8:
|
|
1926
|
+
emitError(5, end);
|
|
1927
|
+
break;
|
|
1928
|
+
case 3:
|
|
1929
|
+
case 4:
|
|
1930
|
+
emitError(
|
|
1931
|
+
25,
|
|
1932
|
+
tokenizer.sectionStart
|
|
1933
|
+
);
|
|
1934
|
+
break;
|
|
1935
|
+
case 28:
|
|
1936
|
+
if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
|
1937
|
+
emitError(6, end);
|
|
1938
|
+
} else {
|
|
1939
|
+
emitError(7, end);
|
|
1940
|
+
}
|
|
1941
|
+
break;
|
|
1942
|
+
case 6:
|
|
1943
|
+
case 7:
|
|
1944
|
+
case 9:
|
|
1945
|
+
case 11:
|
|
1946
|
+
case 12:
|
|
1947
|
+
case 13:
|
|
1948
|
+
case 14:
|
|
1949
|
+
case 15:
|
|
1950
|
+
case 16:
|
|
1951
|
+
case 17:
|
|
1952
|
+
case 18:
|
|
1953
|
+
case 19:
|
|
1954
|
+
case 20:
|
|
1955
|
+
case 21:
|
|
1956
|
+
emitError(9, end);
|
|
1957
|
+
break;
|
|
1026
1958
|
}
|
|
1027
1959
|
}
|
|
1960
|
+
for (let index = 0; index < stack.length; index++) {
|
|
1961
|
+
onCloseTag(stack[index], end - 1);
|
|
1962
|
+
emitError(24, stack[index].loc.start.offset);
|
|
1963
|
+
}
|
|
1964
|
+
},
|
|
1965
|
+
oncdata(start, end) {
|
|
1966
|
+
if (stack[0].ns !== 0) {
|
|
1967
|
+
onText(getSlice(start, end), start, end);
|
|
1968
|
+
} else {
|
|
1969
|
+
emitError(1, start - 9);
|
|
1970
|
+
}
|
|
1971
|
+
},
|
|
1972
|
+
onprocessinginstruction(start) {
|
|
1973
|
+
if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
1974
|
+
emitError(
|
|
1975
|
+
21,
|
|
1976
|
+
start - 1
|
|
1977
|
+
);
|
|
1978
|
+
}
|
|
1028
1979
|
}
|
|
1029
|
-
|
|
1980
|
+
});
|
|
1981
|
+
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
|
1982
|
+
const stripParensRE = /^\(|\)$/g;
|
|
1983
|
+
function parseForExpression(input) {
|
|
1984
|
+
const loc = input.loc;
|
|
1985
|
+
const exp = input.content;
|
|
1986
|
+
const inMatch = exp.match(forAliasRE);
|
|
1987
|
+
if (!inMatch)
|
|
1988
|
+
return;
|
|
1989
|
+
const [, LHS, RHS] = inMatch;
|
|
1990
|
+
const createAliasExpression = (content, offset) => {
|
|
1991
|
+
const start = loc.start.offset + offset;
|
|
1992
|
+
const end = start + content.length;
|
|
1993
|
+
return createSimpleExpression(content, false, getLoc(start, end));
|
|
1994
|
+
};
|
|
1995
|
+
const result = {
|
|
1996
|
+
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
1997
|
+
value: void 0,
|
|
1998
|
+
key: void 0,
|
|
1999
|
+
index: void 0,
|
|
2000
|
+
finalized: false
|
|
2001
|
+
};
|
|
2002
|
+
let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
|
2003
|
+
const trimmedOffset = LHS.indexOf(valueContent);
|
|
2004
|
+
const iteratorMatch = valueContent.match(forIteratorRE);
|
|
2005
|
+
if (iteratorMatch) {
|
|
2006
|
+
valueContent = valueContent.replace(forIteratorRE, "").trim();
|
|
2007
|
+
const keyContent = iteratorMatch[1].trim();
|
|
2008
|
+
let keyOffset;
|
|
2009
|
+
if (keyContent) {
|
|
2010
|
+
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
2011
|
+
result.key = createAliasExpression(keyContent, keyOffset);
|
|
2012
|
+
}
|
|
2013
|
+
if (iteratorMatch[2]) {
|
|
2014
|
+
const indexContent = iteratorMatch[2].trim();
|
|
2015
|
+
if (indexContent) {
|
|
2016
|
+
result.index = createAliasExpression(
|
|
2017
|
+
indexContent,
|
|
2018
|
+
exp.indexOf(
|
|
2019
|
+
indexContent,
|
|
2020
|
+
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
2021
|
+
)
|
|
2022
|
+
);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
if (valueContent) {
|
|
2027
|
+
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
2028
|
+
}
|
|
2029
|
+
return result;
|
|
1030
2030
|
}
|
|
1031
|
-
function
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
2031
|
+
function getSlice(start, end) {
|
|
2032
|
+
return currentInput.slice(start, end);
|
|
2033
|
+
}
|
|
2034
|
+
function endOpenTag(end) {
|
|
2035
|
+
addNode(currentOpenTag);
|
|
2036
|
+
const { tag, ns } = currentOpenTag;
|
|
2037
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2038
|
+
inPre++;
|
|
2039
|
+
}
|
|
2040
|
+
if (currentOptions.isVoidTag(tag)) {
|
|
2041
|
+
onCloseTag(currentOpenTag, end);
|
|
2042
|
+
} else {
|
|
2043
|
+
stack.unshift(currentOpenTag);
|
|
2044
|
+
if (ns === 1 || ns === 2) {
|
|
2045
|
+
tokenizer.inXML = true;
|
|
1039
2046
|
}
|
|
1040
2047
|
}
|
|
1041
|
-
|
|
2048
|
+
currentOpenTag = null;
|
|
1042
2049
|
}
|
|
1043
|
-
function
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
2050
|
+
function onText(content, start, end) {
|
|
2051
|
+
var _a;
|
|
2052
|
+
{
|
|
2053
|
+
const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
|
2054
|
+
if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
|
2055
|
+
content = currentOptions.decodeEntities(content, false);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
const parent = stack[0] || currentRoot;
|
|
2059
|
+
const lastNode = parent.children[parent.children.length - 1];
|
|
2060
|
+
if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
|
2061
|
+
lastNode.content += content;
|
|
2062
|
+
setLocEnd(lastNode.loc, end);
|
|
1048
2063
|
} else {
|
|
1049
|
-
|
|
2064
|
+
parent.children.push({
|
|
2065
|
+
type: 2,
|
|
2066
|
+
content,
|
|
2067
|
+
loc: getLoc(start, end)
|
|
2068
|
+
});
|
|
1050
2069
|
}
|
|
1051
|
-
return nodes;
|
|
1052
2070
|
}
|
|
1053
|
-
function
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
const match = /--(\!)?>/.exec(context.source);
|
|
1057
|
-
if (!match) {
|
|
1058
|
-
content = context.source.slice(4);
|
|
1059
|
-
advanceBy(context, context.source.length);
|
|
1060
|
-
emitError(context, 7);
|
|
2071
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
2072
|
+
if (isImplied) {
|
|
2073
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
1061
2074
|
} else {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
if (
|
|
1066
|
-
|
|
2075
|
+
setLocEnd(el.loc, end + fastForward(end) + 1);
|
|
2076
|
+
}
|
|
2077
|
+
if (tokenizer.inSFCRoot) {
|
|
2078
|
+
if (el.children.length) {
|
|
2079
|
+
el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
|
2080
|
+
} else {
|
|
2081
|
+
el.innerLoc.end = extend({}, el.innerLoc.start);
|
|
1067
2082
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
2083
|
+
el.innerLoc.source = getSlice(
|
|
2084
|
+
el.innerLoc.start.offset,
|
|
2085
|
+
el.innerLoc.end.offset
|
|
2086
|
+
);
|
|
2087
|
+
}
|
|
2088
|
+
const { tag, ns } = el;
|
|
2089
|
+
if (!inVPre) {
|
|
2090
|
+
if (tag === "slot") {
|
|
2091
|
+
el.tagType = 2;
|
|
2092
|
+
} else if (isFragmentTemplate(el)) {
|
|
2093
|
+
el.tagType = 3;
|
|
2094
|
+
} else if (isComponent(el)) {
|
|
2095
|
+
el.tagType = 1;
|
|
1077
2096
|
}
|
|
1078
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1079
2097
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
content = context.source.slice(contentStart);
|
|
1093
|
-
advanceBy(context, context.source.length);
|
|
1094
|
-
} else {
|
|
1095
|
-
content = context.source.slice(contentStart, closeIndex);
|
|
1096
|
-
advanceBy(context, closeIndex + 1);
|
|
2098
|
+
if (!tokenizer.inRCDATA) {
|
|
2099
|
+
el.children = condenseWhitespace(el.children, el.tag);
|
|
2100
|
+
}
|
|
2101
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2102
|
+
inPre--;
|
|
2103
|
+
}
|
|
2104
|
+
if (currentVPreBoundary === el) {
|
|
2105
|
+
inVPre = false;
|
|
2106
|
+
currentVPreBoundary = null;
|
|
2107
|
+
}
|
|
2108
|
+
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
2109
|
+
tokenizer.inXML = false;
|
|
1097
2110
|
}
|
|
1098
|
-
return {
|
|
1099
|
-
type: 3,
|
|
1100
|
-
content,
|
|
1101
|
-
loc: getSelection(context, start)
|
|
1102
|
-
};
|
|
1103
|
-
}
|
|
1104
|
-
function parseElement(context, ancestors) {
|
|
1105
|
-
const wasInPre = context.inPre;
|
|
1106
|
-
const wasInVPre = context.inVPre;
|
|
1107
|
-
const parent = last(ancestors);
|
|
1108
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
1109
|
-
const isPreBoundary = context.inPre && !wasInPre;
|
|
1110
|
-
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
1111
|
-
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
1112
|
-
if (isPreBoundary) {
|
|
1113
|
-
context.inPre = false;
|
|
1114
|
-
}
|
|
1115
|
-
if (isVPreBoundary) {
|
|
1116
|
-
context.inVPre = false;
|
|
1117
|
-
}
|
|
1118
|
-
return element;
|
|
1119
|
-
}
|
|
1120
|
-
ancestors.push(element);
|
|
1121
|
-
const mode = context.options.getTextMode(element, parent);
|
|
1122
|
-
const children = parseChildren(context, mode, ancestors);
|
|
1123
|
-
ancestors.pop();
|
|
1124
2111
|
{
|
|
1125
|
-
const
|
|
2112
|
+
const props = el.props;
|
|
2113
|
+
if (isCompatEnabled(
|
|
2114
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2115
|
+
currentOptions
|
|
2116
|
+
)) {
|
|
2117
|
+
let hasIf = false;
|
|
2118
|
+
let hasFor = false;
|
|
2119
|
+
for (let i = 0; i < props.length; i++) {
|
|
2120
|
+
const p = props[i];
|
|
2121
|
+
if (p.type === 7) {
|
|
2122
|
+
if (p.name === "if") {
|
|
2123
|
+
hasIf = true;
|
|
2124
|
+
} else if (p.name === "for") {
|
|
2125
|
+
hasFor = true;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
if (hasIf && hasFor) {
|
|
2129
|
+
warnDeprecation(
|
|
2130
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2131
|
+
currentOptions,
|
|
2132
|
+
el.loc
|
|
2133
|
+
);
|
|
2134
|
+
break;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
if (isCompatEnabled(
|
|
2139
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2140
|
+
currentOptions
|
|
2141
|
+
) && el.tag === "template" && !isFragmentTemplate(el)) {
|
|
2142
|
+
warnDeprecation(
|
|
2143
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2144
|
+
currentOptions,
|
|
2145
|
+
el.loc
|
|
2146
|
+
);
|
|
2147
|
+
const parent = stack[0] || currentRoot;
|
|
2148
|
+
const index = parent.children.indexOf(el);
|
|
2149
|
+
parent.children.splice(index, 1, ...el.children);
|
|
2150
|
+
}
|
|
2151
|
+
const inlineTemplateProp = props.find(
|
|
1126
2152
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
1127
2153
|
);
|
|
1128
2154
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1129
2155
|
"COMPILER_INLINE_TEMPLATE",
|
|
1130
|
-
|
|
2156
|
+
currentOptions,
|
|
1131
2157
|
inlineTemplateProp.loc
|
|
1132
|
-
)) {
|
|
1133
|
-
const loc = getSelection(context, element.loc.end);
|
|
2158
|
+
) && el.children.length) {
|
|
1134
2159
|
inlineTemplateProp.value = {
|
|
1135
2160
|
type: 2,
|
|
1136
|
-
content:
|
|
1137
|
-
|
|
2161
|
+
content: getSlice(
|
|
2162
|
+
el.children[0].loc.start.offset,
|
|
2163
|
+
el.children[el.children.length - 1].loc.end.offset
|
|
2164
|
+
),
|
|
2165
|
+
loc: inlineTemplateProp.loc
|
|
1138
2166
|
};
|
|
1139
2167
|
}
|
|
1140
2168
|
}
|
|
1141
|
-
element.children = children;
|
|
1142
|
-
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1143
|
-
parseTag(context, 1 /* End */, parent);
|
|
1144
|
-
} else {
|
|
1145
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1146
|
-
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1147
|
-
const first = children[0];
|
|
1148
|
-
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1149
|
-
emitError(context, 8);
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
element.loc = getSelection(context, element.loc.start);
|
|
1154
|
-
if (isPreBoundary) {
|
|
1155
|
-
context.inPre = false;
|
|
1156
|
-
}
|
|
1157
|
-
if (isVPreBoundary) {
|
|
1158
|
-
context.inVPre = false;
|
|
1159
|
-
}
|
|
1160
|
-
return element;
|
|
1161
2169
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
)
|
|
1165
|
-
|
|
1166
|
-
const start = getCursor(context);
|
|
1167
|
-
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
|
1168
|
-
const tag = match[1];
|
|
1169
|
-
const ns = context.options.getNamespace(tag, parent);
|
|
1170
|
-
advanceBy(context, match[0].length);
|
|
1171
|
-
advanceSpaces(context);
|
|
1172
|
-
const cursor = getCursor(context);
|
|
1173
|
-
const currentSource = context.source;
|
|
1174
|
-
if (context.options.isPreTag(tag)) {
|
|
1175
|
-
context.inPre = true;
|
|
1176
|
-
}
|
|
1177
|
-
let props = parseAttributes(context, type);
|
|
1178
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1179
|
-
context.inVPre = true;
|
|
1180
|
-
extend(context, cursor);
|
|
1181
|
-
context.source = currentSource;
|
|
1182
|
-
props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
|
|
1183
|
-
}
|
|
1184
|
-
let isSelfClosing = false;
|
|
1185
|
-
if (context.source.length === 0) {
|
|
1186
|
-
emitError(context, 9);
|
|
1187
|
-
} else {
|
|
1188
|
-
isSelfClosing = startsWith(context.source, "/>");
|
|
1189
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1190
|
-
emitError(context, 4);
|
|
1191
|
-
}
|
|
1192
|
-
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1193
|
-
}
|
|
1194
|
-
if (type === 1 /* End */) {
|
|
1195
|
-
return;
|
|
2170
|
+
function fastForward(start, c) {
|
|
2171
|
+
let offset = 0;
|
|
2172
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2173
|
+
offset++;
|
|
1196
2174
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
2175
|
+
return offset;
|
|
2176
|
+
}
|
|
2177
|
+
function backTrack(index, c) {
|
|
2178
|
+
let i = index;
|
|
2179
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2180
|
+
i--;
|
|
2181
|
+
return i;
|
|
2182
|
+
}
|
|
2183
|
+
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
2184
|
+
function isFragmentTemplate({ tag, props }) {
|
|
2185
|
+
if (tag === "template") {
|
|
1203
2186
|
for (let i = 0; i < props.length; i++) {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (p.name === "if") {
|
|
1207
|
-
hasIf = true;
|
|
1208
|
-
} else if (p.name === "for") {
|
|
1209
|
-
hasFor = true;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
if (hasIf && hasFor) {
|
|
1213
|
-
warnDeprecation(
|
|
1214
|
-
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1215
|
-
context,
|
|
1216
|
-
getSelection(context, start)
|
|
1217
|
-
);
|
|
1218
|
-
break;
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
let tagType = 0;
|
|
1223
|
-
if (!context.inVPre) {
|
|
1224
|
-
if (tag === "slot") {
|
|
1225
|
-
tagType = 2;
|
|
1226
|
-
} else if (tag === "template") {
|
|
1227
|
-
if (props.some(
|
|
1228
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1229
|
-
)) {
|
|
1230
|
-
tagType = 3;
|
|
2187
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2188
|
+
return true;
|
|
1231
2189
|
}
|
|
1232
|
-
} else if (isComponent(tag, props, context)) {
|
|
1233
|
-
tagType = 1;
|
|
1234
2190
|
}
|
|
1235
2191
|
}
|
|
1236
|
-
return
|
|
1237
|
-
type: 1,
|
|
1238
|
-
ns,
|
|
1239
|
-
tag,
|
|
1240
|
-
tagType,
|
|
1241
|
-
props,
|
|
1242
|
-
isSelfClosing,
|
|
1243
|
-
children: [],
|
|
1244
|
-
loc: getSelection(context, start),
|
|
1245
|
-
codegenNode: void 0
|
|
1246
|
-
// to be created during transform phase
|
|
1247
|
-
};
|
|
2192
|
+
return false;
|
|
1248
2193
|
}
|
|
1249
|
-
function isComponent(tag, props
|
|
1250
|
-
|
|
1251
|
-
if (
|
|
2194
|
+
function isComponent({ tag, props }) {
|
|
2195
|
+
var _a;
|
|
2196
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1252
2197
|
return false;
|
|
1253
2198
|
}
|
|
1254
|
-
if (tag === "component" ||
|
|
2199
|
+
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
|
1255
2200
|
return true;
|
|
1256
2201
|
}
|
|
1257
2202
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1262,374 +2207,179 @@ function isComponent(tag, props, context) {
|
|
|
1262
2207
|
return true;
|
|
1263
2208
|
} else if (checkCompatEnabled(
|
|
1264
2209
|
"COMPILER_IS_ON_ELEMENT",
|
|
1265
|
-
|
|
2210
|
+
currentOptions,
|
|
1266
2211
|
p.loc
|
|
1267
2212
|
)) {
|
|
1268
2213
|
return true;
|
|
1269
2214
|
}
|
|
1270
2215
|
}
|
|
1271
|
-
} else
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
context,
|
|
1279
|
-
p.loc
|
|
1280
|
-
)
|
|
1281
|
-
) {
|
|
1282
|
-
return true;
|
|
1283
|
-
}
|
|
2216
|
+
} else if (// :is on plain element - only treat as component in compat mode
|
|
2217
|
+
p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
|
|
2218
|
+
"COMPILER_IS_ON_ELEMENT",
|
|
2219
|
+
currentOptions,
|
|
2220
|
+
p.loc
|
|
2221
|
+
)) {
|
|
2222
|
+
return true;
|
|
1284
2223
|
}
|
|
1285
2224
|
}
|
|
2225
|
+
return false;
|
|
1286
2226
|
}
|
|
1287
|
-
function
|
|
1288
|
-
|
|
1289
|
-
const attributeNames = /* @__PURE__ */ new Set();
|
|
1290
|
-
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1291
|
-
if (startsWith(context.source, "/")) {
|
|
1292
|
-
emitError(context, 22);
|
|
1293
|
-
advanceBy(context, 1);
|
|
1294
|
-
advanceSpaces(context);
|
|
1295
|
-
continue;
|
|
1296
|
-
}
|
|
1297
|
-
if (type === 1 /* End */) {
|
|
1298
|
-
emitError(context, 3);
|
|
1299
|
-
}
|
|
1300
|
-
const attr = parseAttribute(context, attributeNames);
|
|
1301
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1302
|
-
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1303
|
-
}
|
|
1304
|
-
if (type === 0 /* Start */) {
|
|
1305
|
-
props.push(attr);
|
|
1306
|
-
}
|
|
1307
|
-
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1308
|
-
emitError(context, 15);
|
|
1309
|
-
}
|
|
1310
|
-
advanceSpaces(context);
|
|
1311
|
-
}
|
|
1312
|
-
return props;
|
|
2227
|
+
function isUpperCase(c) {
|
|
2228
|
+
return c > 64 && c < 91;
|
|
1313
2229
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
advanceBy(context, name.length);
|
|
1338
|
-
let value = void 0;
|
|
1339
|
-
if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
|
1340
|
-
advanceSpaces(context);
|
|
1341
|
-
advanceBy(context, 1);
|
|
1342
|
-
advanceSpaces(context);
|
|
1343
|
-
value = parseAttributeValue(context);
|
|
1344
|
-
if (!value) {
|
|
1345
|
-
emitError(context, 13);
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
const loc = getSelection(context, start);
|
|
1349
|
-
if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
|
1350
|
-
const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
|
|
1351
|
-
name
|
|
1352
|
-
);
|
|
1353
|
-
let isPropShorthand = startsWith(name, ".");
|
|
1354
|
-
let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
|
|
1355
|
-
let arg;
|
|
1356
|
-
if (match2[2]) {
|
|
1357
|
-
const isSlot = dirName === "slot";
|
|
1358
|
-
const startOffset = name.lastIndexOf(
|
|
1359
|
-
match2[2],
|
|
1360
|
-
name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
|
|
1361
|
-
);
|
|
1362
|
-
const loc2 = getSelection(
|
|
1363
|
-
context,
|
|
1364
|
-
getNewPosition(context, start, startOffset),
|
|
1365
|
-
getNewPosition(
|
|
1366
|
-
context,
|
|
1367
|
-
start,
|
|
1368
|
-
startOffset + match2[2].length + (isSlot && match2[3] || "").length
|
|
1369
|
-
)
|
|
1370
|
-
);
|
|
1371
|
-
let content = match2[2];
|
|
1372
|
-
let isStatic = true;
|
|
1373
|
-
if (content.startsWith("[")) {
|
|
1374
|
-
isStatic = false;
|
|
1375
|
-
if (!content.endsWith("]")) {
|
|
1376
|
-
emitError(
|
|
1377
|
-
context,
|
|
1378
|
-
27
|
|
1379
|
-
);
|
|
1380
|
-
content = content.slice(1);
|
|
1381
|
-
} else {
|
|
1382
|
-
content = content.slice(1, content.length - 1);
|
|
2230
|
+
const windowsNewlineRE = /\r\n/g;
|
|
2231
|
+
function condenseWhitespace(nodes, tag) {
|
|
2232
|
+
var _a, _b;
|
|
2233
|
+
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2234
|
+
let removedWhitespace = false;
|
|
2235
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2236
|
+
const node = nodes[i];
|
|
2237
|
+
if (node.type === 2) {
|
|
2238
|
+
if (!inPre) {
|
|
2239
|
+
if (isAllWhitespace(node.content)) {
|
|
2240
|
+
const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
|
2241
|
+
const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
|
2242
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2243
|
+
removedWhitespace = true;
|
|
2244
|
+
nodes[i] = null;
|
|
2245
|
+
} else {
|
|
2246
|
+
node.content = " ";
|
|
2247
|
+
}
|
|
2248
|
+
} else if (shouldCondense) {
|
|
2249
|
+
node.content = condense(node.content);
|
|
1383
2250
|
}
|
|
1384
|
-
} else
|
|
1385
|
-
content
|
|
1386
|
-
}
|
|
1387
|
-
arg = {
|
|
1388
|
-
type: 4,
|
|
1389
|
-
content,
|
|
1390
|
-
isStatic,
|
|
1391
|
-
constType: isStatic ? 3 : 0,
|
|
1392
|
-
loc: loc2
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
if (value && value.isQuoted) {
|
|
1396
|
-
const valueLoc = value.loc;
|
|
1397
|
-
valueLoc.start.offset++;
|
|
1398
|
-
valueLoc.start.column++;
|
|
1399
|
-
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1400
|
-
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1401
|
-
}
|
|
1402
|
-
const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
|
|
1403
|
-
if (isPropShorthand)
|
|
1404
|
-
modifiers.push("prop");
|
|
1405
|
-
if (dirName === "bind" && arg) {
|
|
1406
|
-
if (modifiers.includes("sync") && checkCompatEnabled(
|
|
1407
|
-
"COMPILER_V_BIND_SYNC",
|
|
1408
|
-
context,
|
|
1409
|
-
loc,
|
|
1410
|
-
arg.loc.source
|
|
1411
|
-
)) {
|
|
1412
|
-
dirName = "model";
|
|
1413
|
-
modifiers.splice(modifiers.indexOf("sync"), 1);
|
|
1414
|
-
}
|
|
1415
|
-
if (modifiers.includes("prop")) {
|
|
1416
|
-
checkCompatEnabled(
|
|
1417
|
-
"COMPILER_V_BIND_PROP",
|
|
1418
|
-
context,
|
|
1419
|
-
loc
|
|
1420
|
-
);
|
|
2251
|
+
} else {
|
|
2252
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1421
2253
|
}
|
|
1422
2254
|
}
|
|
1423
|
-
return {
|
|
1424
|
-
type: 7,
|
|
1425
|
-
name: dirName,
|
|
1426
|
-
exp: value && {
|
|
1427
|
-
type: 4,
|
|
1428
|
-
content: value.content,
|
|
1429
|
-
isStatic: false,
|
|
1430
|
-
// Treat as non-constant by default. This can be potentially set to
|
|
1431
|
-
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1432
|
-
constType: 0,
|
|
1433
|
-
loc: value.loc
|
|
1434
|
-
},
|
|
1435
|
-
arg,
|
|
1436
|
-
modifiers,
|
|
1437
|
-
loc
|
|
1438
|
-
};
|
|
1439
2255
|
}
|
|
1440
|
-
if (
|
|
1441
|
-
|
|
2256
|
+
if (inPre && tag && currentOptions.isPreTag(tag)) {
|
|
2257
|
+
const first = nodes[0];
|
|
2258
|
+
if (first && first.type === 2) {
|
|
2259
|
+
first.content = first.content.replace(/^\r?\n/, "");
|
|
2260
|
+
}
|
|
1442
2261
|
}
|
|
1443
|
-
return
|
|
1444
|
-
type: 6,
|
|
1445
|
-
name,
|
|
1446
|
-
value: value && {
|
|
1447
|
-
type: 2,
|
|
1448
|
-
content: value.content,
|
|
1449
|
-
loc: value.loc
|
|
1450
|
-
},
|
|
1451
|
-
loc
|
|
1452
|
-
};
|
|
2262
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1453
2263
|
}
|
|
1454
|
-
function
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const isQuoted = quote === `"` || quote === `'`;
|
|
1459
|
-
if (isQuoted) {
|
|
1460
|
-
advanceBy(context, 1);
|
|
1461
|
-
const endIndex = context.source.indexOf(quote);
|
|
1462
|
-
if (endIndex === -1) {
|
|
1463
|
-
content = parseTextData(
|
|
1464
|
-
context,
|
|
1465
|
-
context.source.length,
|
|
1466
|
-
4
|
|
1467
|
-
);
|
|
1468
|
-
} else {
|
|
1469
|
-
content = parseTextData(context, endIndex, 4);
|
|
1470
|
-
advanceBy(context, 1);
|
|
1471
|
-
}
|
|
1472
|
-
} else {
|
|
1473
|
-
const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
|
1474
|
-
if (!match) {
|
|
1475
|
-
return void 0;
|
|
1476
|
-
}
|
|
1477
|
-
const unexpectedChars = /["'<=`]/g;
|
|
1478
|
-
let m;
|
|
1479
|
-
while (m = unexpectedChars.exec(match[0])) {
|
|
1480
|
-
emitError(
|
|
1481
|
-
context,
|
|
1482
|
-
18,
|
|
1483
|
-
m.index
|
|
1484
|
-
);
|
|
2264
|
+
function isAllWhitespace(str) {
|
|
2265
|
+
for (let i = 0; i < str.length; i++) {
|
|
2266
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2267
|
+
return false;
|
|
1485
2268
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1489
|
-
}
|
|
1490
|
-
function parseInterpolation(context, mode) {
|
|
1491
|
-
const [open, close] = context.options.delimiters;
|
|
1492
|
-
const closeIndex = context.source.indexOf(close, open.length);
|
|
1493
|
-
if (closeIndex === -1) {
|
|
1494
|
-
emitError(context, 25);
|
|
1495
|
-
return void 0;
|
|
1496
|
-
}
|
|
1497
|
-
const start = getCursor(context);
|
|
1498
|
-
advanceBy(context, open.length);
|
|
1499
|
-
const innerStart = getCursor(context);
|
|
1500
|
-
const innerEnd = getCursor(context);
|
|
1501
|
-
const rawContentLength = closeIndex - open.length;
|
|
1502
|
-
const rawContent = context.source.slice(0, rawContentLength);
|
|
1503
|
-
const preTrimContent = parseTextData(context, rawContentLength, mode);
|
|
1504
|
-
const content = preTrimContent.trim();
|
|
1505
|
-
const startOffset = preTrimContent.indexOf(content);
|
|
1506
|
-
if (startOffset > 0) {
|
|
1507
|
-
advancePositionWithMutation(innerStart, rawContent, startOffset);
|
|
1508
|
-
}
|
|
1509
|
-
const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
|
1510
|
-
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1511
|
-
advanceBy(context, close.length);
|
|
1512
|
-
return {
|
|
1513
|
-
type: 5,
|
|
1514
|
-
content: {
|
|
1515
|
-
type: 4,
|
|
1516
|
-
isStatic: false,
|
|
1517
|
-
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1518
|
-
constType: 0,
|
|
1519
|
-
content,
|
|
1520
|
-
loc: getSelection(context, innerStart, innerEnd)
|
|
1521
|
-
},
|
|
1522
|
-
loc: getSelection(context, start)
|
|
1523
|
-
};
|
|
2269
|
+
}
|
|
2270
|
+
return true;
|
|
1524
2271
|
}
|
|
1525
|
-
function
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
if (index !== -1 && endIndex > index) {
|
|
1531
|
-
endIndex = index;
|
|
2272
|
+
function hasNewlineChar(str) {
|
|
2273
|
+
for (let i = 0; i < str.length; i++) {
|
|
2274
|
+
const c = str.charCodeAt(i);
|
|
2275
|
+
if (c === 10 || c === 13) {
|
|
2276
|
+
return true;
|
|
1532
2277
|
}
|
|
1533
2278
|
}
|
|
1534
|
-
|
|
1535
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1536
|
-
return {
|
|
1537
|
-
type: 2,
|
|
1538
|
-
content,
|
|
1539
|
-
loc: getSelection(context, start)
|
|
1540
|
-
};
|
|
2279
|
+
return false;
|
|
1541
2280
|
}
|
|
1542
|
-
function
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
2281
|
+
function condense(str) {
|
|
2282
|
+
let ret = "";
|
|
2283
|
+
let prevCharIsWhitespace = false;
|
|
2284
|
+
for (let i = 0; i < str.length; i++) {
|
|
2285
|
+
if (isWhitespace(str.charCodeAt(i))) {
|
|
2286
|
+
if (!prevCharIsWhitespace) {
|
|
2287
|
+
ret += " ";
|
|
2288
|
+
prevCharIsWhitespace = true;
|
|
2289
|
+
}
|
|
2290
|
+
} else {
|
|
2291
|
+
ret += str[i];
|
|
2292
|
+
prevCharIsWhitespace = false;
|
|
2293
|
+
}
|
|
1552
2294
|
}
|
|
2295
|
+
return ret;
|
|
1553
2296
|
}
|
|
1554
|
-
function
|
|
1555
|
-
|
|
1556
|
-
return { column, line, offset };
|
|
2297
|
+
function addNode(node) {
|
|
2298
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1557
2299
|
}
|
|
1558
|
-
function
|
|
1559
|
-
end = end || getCursor(context);
|
|
2300
|
+
function getLoc(start, end) {
|
|
1560
2301
|
return {
|
|
1561
|
-
start,
|
|
1562
|
-
|
|
1563
|
-
|
|
2302
|
+
start: tokenizer.getPos(start),
|
|
2303
|
+
// @ts-expect-error allow late attachment
|
|
2304
|
+
end: end == null ? end : tokenizer.getPos(end),
|
|
2305
|
+
// @ts-expect-error allow late attachment
|
|
2306
|
+
source: end == null ? end : getSlice(start, end)
|
|
1564
2307
|
};
|
|
1565
2308
|
}
|
|
1566
|
-
function
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
function startsWith(source, searchString) {
|
|
1570
|
-
return source.startsWith(searchString);
|
|
1571
|
-
}
|
|
1572
|
-
function advanceBy(context, numberOfCharacters) {
|
|
1573
|
-
const { source } = context;
|
|
1574
|
-
advancePositionWithMutation(context, source, numberOfCharacters);
|
|
1575
|
-
context.source = source.slice(numberOfCharacters);
|
|
1576
|
-
}
|
|
1577
|
-
function advanceSpaces(context) {
|
|
1578
|
-
const match = /^[\t\r\n\f ]+/.exec(context.source);
|
|
1579
|
-
if (match) {
|
|
1580
|
-
advanceBy(context, match[0].length);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
function getNewPosition(context, start, numberOfCharacters) {
|
|
1584
|
-
return advancePositionWithClone(
|
|
1585
|
-
start,
|
|
1586
|
-
context.originalSource.slice(start.offset, numberOfCharacters),
|
|
1587
|
-
numberOfCharacters
|
|
1588
|
-
);
|
|
2309
|
+
function setLocEnd(loc, end) {
|
|
2310
|
+
loc.end = tokenizer.getPos(end);
|
|
2311
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1589
2312
|
}
|
|
1590
|
-
function
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
2313
|
+
function dirToAttr(dir) {
|
|
2314
|
+
const attr = {
|
|
2315
|
+
type: 6,
|
|
2316
|
+
name: dir.rawName,
|
|
2317
|
+
nameLoc: getLoc(
|
|
2318
|
+
dir.loc.start.offset,
|
|
2319
|
+
dir.loc.start.offset + dir.rawName.length
|
|
2320
|
+
),
|
|
2321
|
+
value: void 0,
|
|
2322
|
+
loc: dir.loc
|
|
2323
|
+
};
|
|
2324
|
+
if (dir.exp) {
|
|
2325
|
+
const loc = dir.exp.loc;
|
|
2326
|
+
if (loc.end.offset < dir.loc.end.offset) {
|
|
2327
|
+
loc.start.offset--;
|
|
2328
|
+
loc.start.column--;
|
|
2329
|
+
loc.end.offset++;
|
|
2330
|
+
loc.end.column++;
|
|
2331
|
+
}
|
|
2332
|
+
attr.value = {
|
|
2333
|
+
type: 2,
|
|
2334
|
+
content: dir.exp.content,
|
|
2335
|
+
loc
|
|
2336
|
+
};
|
|
1594
2337
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
);
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1619
|
-
return true;
|
|
2338
|
+
return attr;
|
|
2339
|
+
}
|
|
2340
|
+
function emitError(code, index) {
|
|
2341
|
+
currentOptions.onError(createCompilerError(code, getLoc(index, index)));
|
|
2342
|
+
}
|
|
2343
|
+
function reset() {
|
|
2344
|
+
tokenizer.reset();
|
|
2345
|
+
currentOpenTag = null;
|
|
2346
|
+
currentProp = null;
|
|
2347
|
+
currentAttrValue = "";
|
|
2348
|
+
currentAttrStartIndex = -1;
|
|
2349
|
+
currentAttrEndIndex = -1;
|
|
2350
|
+
stack.length = 0;
|
|
2351
|
+
}
|
|
2352
|
+
function baseParse(input, options) {
|
|
2353
|
+
reset();
|
|
2354
|
+
currentInput = input;
|
|
2355
|
+
currentOptions = extend({}, defaultParserOptions);
|
|
2356
|
+
if (options) {
|
|
2357
|
+
let key;
|
|
2358
|
+
for (key in options) {
|
|
2359
|
+
if (options[key] != null) {
|
|
2360
|
+
currentOptions[key] = options[key];
|
|
1620
2361
|
}
|
|
1621
|
-
break;
|
|
1622
2362
|
}
|
|
1623
|
-
case 3:
|
|
1624
|
-
if (startsWith(s, "]]>")) {
|
|
1625
|
-
return true;
|
|
1626
|
-
}
|
|
1627
|
-
break;
|
|
1628
2363
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
2364
|
+
{
|
|
2365
|
+
if (!currentOptions.decodeEntities) {
|
|
2366
|
+
throw new Error(
|
|
2367
|
+
`[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
|
2368
|
+
);
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2372
|
+
const delimiters = options == null ? void 0 : options.delimiters;
|
|
2373
|
+
if (delimiters) {
|
|
2374
|
+
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2375
|
+
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
2376
|
+
}
|
|
2377
|
+
const root = currentRoot = createRoot([], input);
|
|
2378
|
+
tokenizer.parse(currentInput);
|
|
2379
|
+
root.loc = getLoc(0, input.length);
|
|
2380
|
+
root.children = condenseWhitespace(root.children);
|
|
2381
|
+
currentRoot = null;
|
|
2382
|
+
return root;
|
|
1633
2383
|
}
|
|
1634
2384
|
|
|
1635
2385
|
function hoistStatic(root, context) {
|
|
@@ -2041,6 +2791,7 @@ function transform(root, options) {
|
|
|
2041
2791
|
root.hoists = context.hoists;
|
|
2042
2792
|
root.temps = context.temps;
|
|
2043
2793
|
root.cached = context.cached;
|
|
2794
|
+
root.transformed = true;
|
|
2044
2795
|
{
|
|
2045
2796
|
root.filters = [...context.filters];
|
|
2046
2797
|
}
|
|
@@ -2197,7 +2948,7 @@ function createCodegenContext(ast, {
|
|
|
2197
2948
|
ssr,
|
|
2198
2949
|
isTS,
|
|
2199
2950
|
inSSR,
|
|
2200
|
-
source: ast.
|
|
2951
|
+
source: ast.source,
|
|
2201
2952
|
code: ``,
|
|
2202
2953
|
column: 1,
|
|
2203
2954
|
line: 1,
|
|
@@ -2208,7 +2959,7 @@ function createCodegenContext(ast, {
|
|
|
2208
2959
|
helper(key) {
|
|
2209
2960
|
return `_${helperNameMap[key]}`;
|
|
2210
2961
|
},
|
|
2211
|
-
push(code, node) {
|
|
2962
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2212
2963
|
context.code += code;
|
|
2213
2964
|
},
|
|
2214
2965
|
indent() {
|
|
@@ -2226,7 +2977,7 @@ function createCodegenContext(ast, {
|
|
|
2226
2977
|
}
|
|
2227
2978
|
};
|
|
2228
2979
|
function newline(n) {
|
|
2229
|
-
context.push("\n" + ` `.repeat(n));
|
|
2980
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2230
2981
|
}
|
|
2231
2982
|
return context;
|
|
2232
2983
|
}
|
|
@@ -2263,9 +3014,11 @@ function generate(ast, options = {}) {
|
|
|
2263
3014
|
push(`with (_ctx) {`);
|
|
2264
3015
|
indent();
|
|
2265
3016
|
if (hasHelpers) {
|
|
2266
|
-
push(
|
|
2267
|
-
|
|
2268
|
-
|
|
3017
|
+
push(
|
|
3018
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3019
|
+
`,
|
|
3020
|
+
-1 /* End */
|
|
3021
|
+
);
|
|
2269
3022
|
newline();
|
|
2270
3023
|
}
|
|
2271
3024
|
}
|
|
@@ -2294,7 +3047,7 @@ function generate(ast, options = {}) {
|
|
|
2294
3047
|
}
|
|
2295
3048
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2296
3049
|
push(`
|
|
2297
|
-
|
|
3050
|
+
`, 0 /* Start */);
|
|
2298
3051
|
newline();
|
|
2299
3052
|
}
|
|
2300
3053
|
if (!ssr) {
|
|
@@ -2315,7 +3068,6 @@ function generate(ast, options = {}) {
|
|
|
2315
3068
|
ast,
|
|
2316
3069
|
code: context.code,
|
|
2317
3070
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2318
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2319
3071
|
map: context.map ? context.map.toJSON() : void 0
|
|
2320
3072
|
};
|
|
2321
3073
|
}
|
|
@@ -2334,7 +3086,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2334
3086
|
if (helpers.length > 0) {
|
|
2335
3087
|
{
|
|
2336
3088
|
push(`const _Vue = ${VueBinding}
|
|
2337
|
-
|
|
3089
|
+
`, -1 /* End */);
|
|
2338
3090
|
if (ast.hoists.length) {
|
|
2339
3091
|
const staticHelpers = [
|
|
2340
3092
|
CREATE_VNODE,
|
|
@@ -2344,7 +3096,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2344
3096
|
CREATE_STATIC
|
|
2345
3097
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2346
3098
|
push(`const { ${staticHelpers} } = _Vue
|
|
2347
|
-
|
|
3099
|
+
`, -1 /* End */);
|
|
2348
3100
|
}
|
|
2349
3101
|
}
|
|
2350
3102
|
}
|
|
@@ -2405,7 +3157,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2405
3157
|
for (let i = 0; i < nodes.length; i++) {
|
|
2406
3158
|
const node = nodes[i];
|
|
2407
3159
|
if (isString(node)) {
|
|
2408
|
-
push(node);
|
|
3160
|
+
push(node, -3 /* Unknown */);
|
|
2409
3161
|
} else if (isArray(node)) {
|
|
2410
3162
|
genNodeListAsArray(node, context);
|
|
2411
3163
|
} else {
|
|
@@ -2423,7 +3175,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2423
3175
|
}
|
|
2424
3176
|
function genNode(node, context) {
|
|
2425
3177
|
if (isString(node)) {
|
|
2426
|
-
context.push(node);
|
|
3178
|
+
context.push(node, -3 /* Unknown */);
|
|
2427
3179
|
return;
|
|
2428
3180
|
}
|
|
2429
3181
|
if (isSymbol(node)) {
|
|
@@ -2503,11 +3255,15 @@ function genNode(node, context) {
|
|
|
2503
3255
|
}
|
|
2504
3256
|
}
|
|
2505
3257
|
function genText(node, context) {
|
|
2506
|
-
context.push(JSON.stringify(node.content), node);
|
|
3258
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2507
3259
|
}
|
|
2508
3260
|
function genExpression(node, context) {
|
|
2509
3261
|
const { content, isStatic } = node;
|
|
2510
|
-
context.push(
|
|
3262
|
+
context.push(
|
|
3263
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3264
|
+
-3 /* Unknown */,
|
|
3265
|
+
node
|
|
3266
|
+
);
|
|
2511
3267
|
}
|
|
2512
3268
|
function genInterpolation(node, context) {
|
|
2513
3269
|
const { push, helper, pure } = context;
|
|
@@ -2521,7 +3277,7 @@ function genCompoundExpression(node, context) {
|
|
|
2521
3277
|
for (let i = 0; i < node.children.length; i++) {
|
|
2522
3278
|
const child = node.children[i];
|
|
2523
3279
|
if (isString(child)) {
|
|
2524
|
-
context.push(child);
|
|
3280
|
+
context.push(child, -3 /* Unknown */);
|
|
2525
3281
|
} else {
|
|
2526
3282
|
genNode(child, context);
|
|
2527
3283
|
}
|
|
@@ -2535,9 +3291,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
2535
3291
|
push(`]`);
|
|
2536
3292
|
} else if (node.isStatic) {
|
|
2537
3293
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2538
|
-
push(text, node);
|
|
3294
|
+
push(text, -2 /* None */, node);
|
|
2539
3295
|
} else {
|
|
2540
|
-
push(`[${node.content}]`, node);
|
|
3296
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2541
3297
|
}
|
|
2542
3298
|
}
|
|
2543
3299
|
function genComment(node, context) {
|
|
@@ -2545,7 +3301,11 @@ function genComment(node, context) {
|
|
|
2545
3301
|
if (pure) {
|
|
2546
3302
|
push(PURE_ANNOTATION);
|
|
2547
3303
|
}
|
|
2548
|
-
push(
|
|
3304
|
+
push(
|
|
3305
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3306
|
+
-3 /* Unknown */,
|
|
3307
|
+
node
|
|
3308
|
+
);
|
|
2549
3309
|
}
|
|
2550
3310
|
function genVNodeCall(node, context) {
|
|
2551
3311
|
const { push, helper, pure } = context;
|
|
@@ -2570,7 +3330,7 @@ function genVNodeCall(node, context) {
|
|
|
2570
3330
|
push(PURE_ANNOTATION);
|
|
2571
3331
|
}
|
|
2572
3332
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2573
|
-
push(helper(callHelper) + `(`, node);
|
|
3333
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2574
3334
|
genNodeList(
|
|
2575
3335
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2576
3336
|
context
|
|
@@ -2599,7 +3359,7 @@ function genCallExpression(node, context) {
|
|
|
2599
3359
|
if (pure) {
|
|
2600
3360
|
push(PURE_ANNOTATION);
|
|
2601
3361
|
}
|
|
2602
|
-
push(callee + `(`, node);
|
|
3362
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2603
3363
|
genNodeList(node.arguments, context);
|
|
2604
3364
|
push(`)`);
|
|
2605
3365
|
}
|
|
@@ -2607,7 +3367,7 @@ function genObjectExpression(node, context) {
|
|
|
2607
3367
|
const { push, indent, deindent, newline } = context;
|
|
2608
3368
|
const { properties } = node;
|
|
2609
3369
|
if (!properties.length) {
|
|
2610
|
-
push(`{}`, node);
|
|
3370
|
+
push(`{}`, -2 /* None */, node);
|
|
2611
3371
|
return;
|
|
2612
3372
|
}
|
|
2613
3373
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -2635,7 +3395,7 @@ function genFunctionExpression(node, context) {
|
|
|
2635
3395
|
if (isSlot) {
|
|
2636
3396
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2637
3397
|
}
|
|
2638
|
-
push(`(`, node);
|
|
3398
|
+
push(`(`, -2 /* None */, node);
|
|
2639
3399
|
if (isArray(params)) {
|
|
2640
3400
|
genNodeList(params, context);
|
|
2641
3401
|
} else if (params) {
|
|
@@ -2989,7 +3749,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2989
3749
|
context.removeNode();
|
|
2990
3750
|
const branch = createIfBranch(node, dir);
|
|
2991
3751
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2992
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3752
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2993
3753
|
branch.children = [...comments, ...branch.children];
|
|
2994
3754
|
}
|
|
2995
3755
|
{
|
|
@@ -3271,18 +4031,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3271
4031
|
);
|
|
3272
4032
|
return;
|
|
3273
4033
|
}
|
|
3274
|
-
const parseResult =
|
|
3275
|
-
// can only be simple expression because vFor transform is applied
|
|
3276
|
-
// before expression transform.
|
|
3277
|
-
dir.exp,
|
|
3278
|
-
context
|
|
3279
|
-
);
|
|
4034
|
+
const parseResult = dir.forParseResult;
|
|
3280
4035
|
if (!parseResult) {
|
|
3281
4036
|
context.onError(
|
|
3282
4037
|
createCompilerError(32, dir.loc)
|
|
3283
4038
|
);
|
|
3284
4039
|
return;
|
|
3285
4040
|
}
|
|
4041
|
+
finalizeForParseResult(parseResult, context);
|
|
3286
4042
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3287
4043
|
const { source, value, key, index } = parseResult;
|
|
3288
4044
|
const forNode = {
|
|
@@ -3304,70 +4060,26 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3304
4060
|
onExit();
|
|
3305
4061
|
};
|
|
3306
4062
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
function parseForExpression(input, context) {
|
|
3310
|
-
const loc = input.loc;
|
|
3311
|
-
const exp = input.content;
|
|
3312
|
-
const inMatch = exp.match(forAliasRE);
|
|
3313
|
-
if (!inMatch)
|
|
4063
|
+
function finalizeForParseResult(result, context) {
|
|
4064
|
+
if (result.finalized)
|
|
3314
4065
|
return;
|
|
3315
|
-
const [, LHS, RHS] = inMatch;
|
|
3316
|
-
const result = {
|
|
3317
|
-
source: createAliasExpression(
|
|
3318
|
-
loc,
|
|
3319
|
-
RHS.trim(),
|
|
3320
|
-
exp.indexOf(RHS, LHS.length)
|
|
3321
|
-
),
|
|
3322
|
-
value: void 0,
|
|
3323
|
-
key: void 0,
|
|
3324
|
-
index: void 0
|
|
3325
|
-
};
|
|
3326
4066
|
{
|
|
3327
4067
|
validateBrowserExpression(result.source, context);
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
const keyContent = iteratorMatch[1].trim();
|
|
3335
|
-
let keyOffset;
|
|
3336
|
-
if (keyContent) {
|
|
3337
|
-
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
3338
|
-
result.key = createAliasExpression(loc, keyContent, keyOffset);
|
|
3339
|
-
{
|
|
3340
|
-
validateBrowserExpression(
|
|
3341
|
-
result.key,
|
|
3342
|
-
context,
|
|
3343
|
-
true
|
|
3344
|
-
);
|
|
3345
|
-
}
|
|
4068
|
+
if (result.key) {
|
|
4069
|
+
validateBrowserExpression(
|
|
4070
|
+
result.key,
|
|
4071
|
+
context,
|
|
4072
|
+
true
|
|
4073
|
+
);
|
|
3346
4074
|
}
|
|
3347
|
-
if (
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
exp.indexOf(
|
|
3354
|
-
indexContent,
|
|
3355
|
-
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
3356
|
-
)
|
|
3357
|
-
);
|
|
3358
|
-
{
|
|
3359
|
-
validateBrowserExpression(
|
|
3360
|
-
result.index,
|
|
3361
|
-
context,
|
|
3362
|
-
true
|
|
3363
|
-
);
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
4075
|
+
if (result.index) {
|
|
4076
|
+
validateBrowserExpression(
|
|
4077
|
+
result.index,
|
|
4078
|
+
context,
|
|
4079
|
+
true
|
|
4080
|
+
);
|
|
3366
4081
|
}
|
|
3367
|
-
|
|
3368
|
-
if (valueContent) {
|
|
3369
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3370
|
-
{
|
|
4082
|
+
if (result.value) {
|
|
3371
4083
|
validateBrowserExpression(
|
|
3372
4084
|
result.value,
|
|
3373
4085
|
context,
|
|
@@ -3375,14 +4087,7 @@ function parseForExpression(input, context) {
|
|
|
3375
4087
|
);
|
|
3376
4088
|
}
|
|
3377
4089
|
}
|
|
3378
|
-
|
|
3379
|
-
}
|
|
3380
|
-
function createAliasExpression(range, content, offset) {
|
|
3381
|
-
return createSimpleExpression(
|
|
3382
|
-
content,
|
|
3383
|
-
false,
|
|
3384
|
-
getInnerRange(range, offset, content.length)
|
|
3385
|
-
);
|
|
4090
|
+
result.finalized = true;
|
|
3386
4091
|
}
|
|
3387
4092
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3388
4093
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3412,11 +4117,9 @@ const trackSlotScopes = (node, context) => {
|
|
|
3412
4117
|
const trackVForSlotScopes = (node, context) => {
|
|
3413
4118
|
let vFor;
|
|
3414
4119
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3415
|
-
const result = vFor.
|
|
3416
|
-
vFor.exp,
|
|
3417
|
-
context
|
|
3418
|
-
);
|
|
4120
|
+
const result = vFor.forParseResult;
|
|
3419
4121
|
if (result) {
|
|
4122
|
+
finalizeForParseResult(result, context);
|
|
3420
4123
|
const { value, key, index } = result;
|
|
3421
4124
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3422
4125
|
value && addIdentifiers(value);
|
|
@@ -3490,12 +4193,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3490
4193
|
hasDynamicSlots = true;
|
|
3491
4194
|
}
|
|
3492
4195
|
const vFor = findDir(slotElement, "for");
|
|
3493
|
-
const slotFunction = buildSlotFn(
|
|
3494
|
-
slotProps,
|
|
3495
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3496
|
-
slotChildren,
|
|
3497
|
-
slotLoc
|
|
3498
|
-
);
|
|
4196
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3499
4197
|
let vIf;
|
|
3500
4198
|
let vElse;
|
|
3501
4199
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3544,8 +4242,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3544
4242
|
}
|
|
3545
4243
|
} else if (vFor) {
|
|
3546
4244
|
hasDynamicSlots = true;
|
|
3547
|
-
const parseResult = vFor.
|
|
4245
|
+
const parseResult = vFor.forParseResult;
|
|
3548
4246
|
if (parseResult) {
|
|
4247
|
+
finalizeForParseResult(parseResult, context);
|
|
3549
4248
|
dynamicSlots.push(
|
|
3550
4249
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3551
4250
|
parseResult.source,
|
|
@@ -3806,17 +4505,6 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3806
4505
|
tag = isProp.value.content.slice(4);
|
|
3807
4506
|
}
|
|
3808
4507
|
}
|
|
3809
|
-
const isDir = !isExplicitDynamic && findDir(node, "is");
|
|
3810
|
-
if (isDir && isDir.exp) {
|
|
3811
|
-
{
|
|
3812
|
-
context.onWarn(
|
|
3813
|
-
createCompilerError(52, isDir.loc)
|
|
3814
|
-
);
|
|
3815
|
-
}
|
|
3816
|
-
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
3817
|
-
isDir.exp
|
|
3818
|
-
]);
|
|
3819
|
-
}
|
|
3820
4508
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3821
4509
|
if (builtIn) {
|
|
3822
4510
|
if (!ssr)
|
|
@@ -3888,7 +4576,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3888
4576
|
for (let i = 0; i < props.length; i++) {
|
|
3889
4577
|
const prop = props[i];
|
|
3890
4578
|
if (prop.type === 6) {
|
|
3891
|
-
const { loc, name, value } = prop;
|
|
4579
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3892
4580
|
let isStatic = true;
|
|
3893
4581
|
if (name === "ref") {
|
|
3894
4582
|
hasRef = true;
|
|
@@ -3909,11 +4597,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3909
4597
|
}
|
|
3910
4598
|
properties.push(
|
|
3911
4599
|
createObjectProperty(
|
|
3912
|
-
createSimpleExpression(
|
|
3913
|
-
name,
|
|
3914
|
-
true,
|
|
3915
|
-
getInnerRange(loc, 0, name.length)
|
|
3916
|
-
),
|
|
4600
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3917
4601
|
createSimpleExpression(
|
|
3918
4602
|
value ? value.content : "",
|
|
3919
4603
|
isStatic,
|
|
@@ -4395,8 +5079,13 @@ const transformOn$1 = (dir, node, context, augmentor) => {
|
|
|
4395
5079
|
};
|
|
4396
5080
|
|
|
4397
5081
|
const transformBind = (dir, _node, context) => {
|
|
4398
|
-
const {
|
|
5082
|
+
const { modifiers, loc } = dir;
|
|
4399
5083
|
const arg = dir.arg;
|
|
5084
|
+
let { exp } = dir;
|
|
5085
|
+
if (!exp && arg.type === 4) {
|
|
5086
|
+
const propName = camelize(arg.content);
|
|
5087
|
+
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5088
|
+
}
|
|
4400
5089
|
if (arg.type !== 4) {
|
|
4401
5090
|
arg.children.unshift(`(`);
|
|
4402
5091
|
arg.children.push(`) || ""`);
|
|
@@ -4795,7 +5484,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
|
|
|
4795
5484
|
}
|
|
4796
5485
|
];
|
|
4797
5486
|
}
|
|
4798
|
-
function baseCompile(
|
|
5487
|
+
function baseCompile(source, options = {}) {
|
|
4799
5488
|
const onError = options.onError || defaultOnError;
|
|
4800
5489
|
const isModuleMode = options.mode === "module";
|
|
4801
5490
|
{
|
|
@@ -4812,7 +5501,7 @@ function baseCompile(template, options = {}) {
|
|
|
4812
5501
|
if (options.scopeId && !isModuleMode) {
|
|
4813
5502
|
onError(createCompilerError(50));
|
|
4814
5503
|
}
|
|
4815
|
-
const ast = isString(
|
|
5504
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4816
5505
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4817
5506
|
transform(
|
|
4818
5507
|
ast,
|
|
@@ -4878,25 +5567,22 @@ function decodeHtmlBrowser(raw, asAttr = false) {
|
|
|
4878
5567
|
}
|
|
4879
5568
|
}
|
|
4880
5569
|
|
|
4881
|
-
const isRawTextContainer = /* @__PURE__ */ makeMap(
|
|
4882
|
-
"style,iframe,script,noscript",
|
|
4883
|
-
true
|
|
4884
|
-
);
|
|
4885
5570
|
const parserOptions = {
|
|
5571
|
+
parseMode: "html",
|
|
4886
5572
|
isVoidTag,
|
|
4887
5573
|
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
4888
5574
|
isPreTag: (tag) => tag === "pre",
|
|
4889
5575
|
decodeEntities: decodeHtmlBrowser ,
|
|
4890
5576
|
isBuiltInComponent: (tag) => {
|
|
4891
|
-
if (
|
|
5577
|
+
if (tag === "Transition" || tag === "transition") {
|
|
4892
5578
|
return TRANSITION;
|
|
4893
|
-
} else if (
|
|
5579
|
+
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
|
4894
5580
|
return TRANSITION_GROUP;
|
|
4895
5581
|
}
|
|
4896
5582
|
},
|
|
4897
5583
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
4898
|
-
getNamespace(tag, parent) {
|
|
4899
|
-
let ns = parent ? parent.ns :
|
|
5584
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
5585
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
4900
5586
|
if (parent && ns === 2) {
|
|
4901
5587
|
if (parent.tag === "annotation-xml") {
|
|
4902
5588
|
if (tag === "svg") {
|
|
@@ -4924,18 +5610,6 @@ const parserOptions = {
|
|
|
4924
5610
|
}
|
|
4925
5611
|
}
|
|
4926
5612
|
return ns;
|
|
4927
|
-
},
|
|
4928
|
-
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
|
4929
|
-
getTextMode({ tag, ns }) {
|
|
4930
|
-
if (ns === 0) {
|
|
4931
|
-
if (tag === "textarea" || tag === "title") {
|
|
4932
|
-
return 1;
|
|
4933
|
-
}
|
|
4934
|
-
if (isRawTextContainer(tag)) {
|
|
4935
|
-
return 2;
|
|
4936
|
-
}
|
|
4937
|
-
}
|
|
4938
|
-
return 0;
|
|
4939
5613
|
}
|
|
4940
5614
|
};
|
|
4941
5615
|
|
|
@@ -5256,6 +5930,7 @@ const transformTransition = (node, context) => {
|
|
|
5256
5930
|
node.props.push({
|
|
5257
5931
|
type: 6,
|
|
5258
5932
|
name: "persisted",
|
|
5933
|
+
nameLoc: node.loc,
|
|
5259
5934
|
value: void 0,
|
|
5260
5935
|
loc: node.loc
|
|
5261
5936
|
});
|
|
@@ -5300,9 +5975,9 @@ const DOMDirectiveTransforms = {
|
|
|
5300
5975
|
// override compiler-core
|
|
5301
5976
|
show: transformShow
|
|
5302
5977
|
};
|
|
5303
|
-
function compile(
|
|
5978
|
+
function compile(src, options = {}) {
|
|
5304
5979
|
return baseCompile(
|
|
5305
|
-
|
|
5980
|
+
src,
|
|
5306
5981
|
extend({}, parserOptions, options, {
|
|
5307
5982
|
nodeTransforms: [
|
|
5308
5983
|
// ignore <script> and <tag>
|
|
@@ -5325,4 +6000,4 @@ function parse(template, options = {}) {
|
|
|
5325
6000
|
return baseParse(template, extend({}, parserOptions, options));
|
|
5326
6001
|
}
|
|
5327
6002
|
|
|
5328
|
-
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, DOMDirectiveTransforms, DOMNodeTransforms, 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, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType,
|
|
6003
|
+
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, DOMDirectiveTransforms, DOMErrorMessages, DOMNodeTransforms, 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, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, 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, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|