@vue/compiler-dom 3.4.0-alpha.1 → 3.4.0-alpha.3
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 +11 -2364
- package/dist/compiler-dom.cjs.prod.js +8 -2362
- package/dist/compiler-dom.d.ts +2 -2
- package/dist/compiler-dom.esm-browser.js +1819 -1130
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +12 -26
- package/dist/compiler-dom.global.js +1819 -1131
- 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
|
});
|
|
@@ -54,7 +46,7 @@ const PatchFlagNames = {
|
|
|
54
46
|
[4]: `STYLE`,
|
|
55
47
|
[8]: `PROPS`,
|
|
56
48
|
[16]: `FULL_PROPS`,
|
|
57
|
-
[32]: `
|
|
49
|
+
[32]: `NEED_HYDRATION`,
|
|
58
50
|
[64]: `STABLE_FRAGMENT`,
|
|
59
51
|
[128]: `KEYED_FRAGMENT`,
|
|
60
52
|
[256]: `UNKEYED_FRAGMENT`,
|
|
@@ -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
|
}
|
|
@@ -786,471 +1643,562 @@ function getMemoedVNodeCall(node) {
|
|
|
786
1643
|
return node;
|
|
787
1644
|
}
|
|
788
1645
|
}
|
|
1646
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
789
1647
|
|
|
790
|
-
const deprecationData = {
|
|
791
|
-
["COMPILER_IS_ON_ELEMENT"]: {
|
|
792
|
-
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:".`,
|
|
793
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
794
|
-
},
|
|
795
|
-
["COMPILER_V_BIND_SYNC"]: {
|
|
796
|
-
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}\`.`,
|
|
797
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
798
|
-
},
|
|
799
|
-
["COMPILER_V_BIND_PROP"]: {
|
|
800
|
-
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.`
|
|
801
|
-
},
|
|
802
|
-
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
803
|
-
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.`,
|
|
804
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
805
|
-
},
|
|
806
|
-
["COMPILER_V_ON_NATIVE"]: {
|
|
807
|
-
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
808
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
809
|
-
},
|
|
810
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
811
|
-
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.`,
|
|
812
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
813
|
-
},
|
|
814
|
-
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
815
|
-
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
816
|
-
},
|
|
817
|
-
["COMPILER_INLINE_TEMPLATE"]: {
|
|
818
|
-
message: `"inline-template" has been removed in Vue 3.`,
|
|
819
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
820
|
-
},
|
|
821
|
-
["COMPILER_FILTER"]: {
|
|
822
|
-
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.`,
|
|
823
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
function getCompatValue(key, context) {
|
|
827
|
-
const config = context.options ? context.options.compatConfig : context.compatConfig;
|
|
828
|
-
const value = config && config[key];
|
|
829
|
-
if (key === "MODE") {
|
|
830
|
-
return value || 3;
|
|
831
|
-
} else {
|
|
832
|
-
return value;
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
function isCompatEnabled(key, context) {
|
|
836
|
-
const mode = getCompatValue("MODE", context);
|
|
837
|
-
const value = getCompatValue(key, context);
|
|
838
|
-
return mode === 3 ? value === true : value !== false;
|
|
839
|
-
}
|
|
840
|
-
function checkCompatEnabled(key, context, loc, ...args) {
|
|
841
|
-
const enabled = isCompatEnabled(key, context);
|
|
842
|
-
if (enabled) {
|
|
843
|
-
warnDeprecation(key, context, loc, ...args);
|
|
844
|
-
}
|
|
845
|
-
return enabled;
|
|
846
|
-
}
|
|
847
|
-
function warnDeprecation(key, context, loc, ...args) {
|
|
848
|
-
const val = getCompatValue(key, context);
|
|
849
|
-
if (val === "suppress-warning") {
|
|
850
|
-
return;
|
|
851
|
-
}
|
|
852
|
-
const { message, link } = deprecationData[key];
|
|
853
|
-
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
854
|
-
Details: ${link}` : ``}`;
|
|
855
|
-
const err = new SyntaxError(msg);
|
|
856
|
-
err.code = key;
|
|
857
|
-
if (loc)
|
|
858
|
-
err.loc = loc;
|
|
859
|
-
context.onWarn(err);
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
|
863
|
-
const decodeMap = {
|
|
864
|
-
gt: ">",
|
|
865
|
-
lt: "<",
|
|
866
|
-
amp: "&",
|
|
867
|
-
apos: "'",
|
|
868
|
-
quot: '"'
|
|
869
|
-
};
|
|
870
1648
|
const defaultParserOptions = {
|
|
1649
|
+
parseMode: "base",
|
|
1650
|
+
ns: 0,
|
|
871
1651
|
delimiters: [`{{`, `}}`],
|
|
872
1652
|
getNamespace: () => 0,
|
|
873
|
-
getTextMode: () => 0,
|
|
874
1653
|
isVoidTag: NO,
|
|
875
1654
|
isPreTag: NO,
|
|
876
1655
|
isCustomElement: NO,
|
|
877
|
-
decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
|
878
1656
|
onError: defaultOnError,
|
|
879
1657
|
onWarn: defaultOnWarn,
|
|
880
1658
|
comments: true
|
|
881
1659
|
};
|
|
882
|
-
|
|
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
|
-
let
|
|
915
|
-
if (
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
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);
|
|
936
1737
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
} else if (s[2] === ">") {
|
|
941
|
-
emitError(context, 14, 2);
|
|
942
|
-
advanceBy(context, 3);
|
|
943
|
-
continue;
|
|
944
|
-
} else if (/[a-z]/i.test(s[2])) {
|
|
945
|
-
emitError(context, 23);
|
|
946
|
-
parseTag(context, 1 /* End */, parent);
|
|
947
|
-
continue;
|
|
948
|
-
} else {
|
|
949
|
-
emitError(
|
|
950
|
-
context,
|
|
951
|
-
12,
|
|
952
|
-
2
|
|
953
|
-
);
|
|
954
|
-
node = parseBogusComment(context);
|
|
1738
|
+
for (let j = 0; j <= i; j++) {
|
|
1739
|
+
const el = stack.shift();
|
|
1740
|
+
onCloseTag(el, end, j < i);
|
|
955
1741
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
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]);
|
|
970
1799
|
}
|
|
971
|
-
} else if (s[1] === "?") {
|
|
972
|
-
emitError(
|
|
973
|
-
context,
|
|
974
|
-
21,
|
|
975
|
-
1
|
|
976
|
-
);
|
|
977
|
-
node = parseBogusComment(context);
|
|
978
|
-
} else {
|
|
979
|
-
emitError(context, 12, 1);
|
|
980
1800
|
}
|
|
981
1801
|
}
|
|
982
1802
|
}
|
|
983
|
-
|
|
984
|
-
|
|
1803
|
+
},
|
|
1804
|
+
ondirarg(start, end) {
|
|
1805
|
+
if (start === end)
|
|
1806
|
+
return;
|
|
1807
|
+
const arg = getSlice(start, end);
|
|
1808
|
+
if (inVPre) {
|
|
1809
|
+
currentProp.name += arg;
|
|
1810
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1811
|
+
} else {
|
|
1812
|
+
const isStatic = arg[0] !== `[`;
|
|
1813
|
+
currentProp.arg = createSimpleExpression(
|
|
1814
|
+
isStatic ? arg : arg.slice(1, -1),
|
|
1815
|
+
isStatic,
|
|
1816
|
+
getLoc(start, end),
|
|
1817
|
+
isStatic ? 3 : 0
|
|
1818
|
+
);
|
|
985
1819
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1820
|
+
},
|
|
1821
|
+
ondirmodifier(start, end) {
|
|
1822
|
+
const mod = getSlice(start, end);
|
|
1823
|
+
if (inVPre) {
|
|
1824
|
+
currentProp.name += "." + mod;
|
|
1825
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1826
|
+
} else if (currentProp.name === "slot") {
|
|
1827
|
+
const arg = currentProp.arg;
|
|
1828
|
+
if (arg) {
|
|
1829
|
+
arg.content += "." + mod;
|
|
1830
|
+
setLocEnd(arg.loc, end);
|
|
989
1831
|
}
|
|
990
1832
|
} else {
|
|
991
|
-
|
|
1833
|
+
currentProp.modifiers.push(mod);
|
|
992
1834
|
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1835
|
+
},
|
|
1836
|
+
onattribdata(start, end) {
|
|
1837
|
+
currentAttrValue += getSlice(start, end);
|
|
1838
|
+
if (currentAttrStartIndex < 0)
|
|
1839
|
+
currentAttrStartIndex = start;
|
|
1840
|
+
currentAttrEndIndex = end;
|
|
1841
|
+
},
|
|
1842
|
+
onattribentity(char, start, end) {
|
|
1843
|
+
currentAttrValue += char;
|
|
1844
|
+
if (currentAttrStartIndex < 0)
|
|
1845
|
+
currentAttrStartIndex = start;
|
|
1846
|
+
currentAttrEndIndex = end;
|
|
1847
|
+
},
|
|
1848
|
+
onattribnameend(end) {
|
|
1849
|
+
const start = currentProp.loc.start.offset;
|
|
1850
|
+
const name = getSlice(start, end);
|
|
1851
|
+
if (currentProp.type === 7) {
|
|
1852
|
+
currentProp.rawName = name;
|
|
1853
|
+
}
|
|
1854
|
+
if (currentOpenTag.props.some(
|
|
1855
|
+
(p) => (p.type === 7 ? p.rawName : p.name) === name
|
|
1856
|
+
)) {
|
|
1857
|
+
emitError(2, start);
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
onattribend(quote, end) {
|
|
1861
|
+
if (currentOpenTag && currentProp) {
|
|
1862
|
+
setLocEnd(currentProp.loc, end);
|
|
1863
|
+
if (quote !== 0) {
|
|
1864
|
+
if (currentAttrValue.includes("&")) {
|
|
1865
|
+
currentAttrValue = currentOptions.decodeEntities(
|
|
1866
|
+
currentAttrValue,
|
|
1867
|
+
true
|
|
1868
|
+
);
|
|
1869
|
+
}
|
|
1870
|
+
if (currentProp.type === 6) {
|
|
1871
|
+
if (currentProp.name === "class") {
|
|
1872
|
+
currentAttrValue = condense(currentAttrValue).trim();
|
|
1873
|
+
}
|
|
1874
|
+
if (quote === 1 && !currentAttrValue) {
|
|
1875
|
+
emitError(13, end);
|
|
1876
|
+
}
|
|
1877
|
+
currentProp.value = {
|
|
1878
|
+
type: 2,
|
|
1879
|
+
content: currentAttrValue,
|
|
1880
|
+
loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
|
1881
|
+
};
|
|
1882
|
+
if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
|
1883
|
+
tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
1012
1884
|
}
|
|
1013
1885
|
} else {
|
|
1014
|
-
|
|
1886
|
+
currentProp.exp = createSimpleExpression(
|
|
1887
|
+
currentAttrValue,
|
|
1888
|
+
false,
|
|
1889
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
1890
|
+
);
|
|
1891
|
+
if (currentProp.name === "for") {
|
|
1892
|
+
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
1893
|
+
}
|
|
1894
|
+
let syncIndex = -1;
|
|
1895
|
+
if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
|
|
1896
|
+
"COMPILER_V_BIND_SYNC",
|
|
1897
|
+
currentOptions,
|
|
1898
|
+
currentProp.loc,
|
|
1899
|
+
currentProp.rawName
|
|
1900
|
+
)) {
|
|
1901
|
+
currentProp.name = "model";
|
|
1902
|
+
currentProp.modifiers.splice(syncIndex, 1);
|
|
1903
|
+
}
|
|
1015
1904
|
}
|
|
1016
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
1017
|
-
removedWhitespace = true;
|
|
1018
|
-
nodes[i] = null;
|
|
1019
1905
|
}
|
|
1906
|
+
if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
|
1907
|
+
currentOpenTag.props.push(currentProp);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
currentAttrValue = "";
|
|
1911
|
+
currentAttrStartIndex = currentAttrEndIndex = -1;
|
|
1912
|
+
},
|
|
1913
|
+
oncomment(start, end) {
|
|
1914
|
+
if (currentOptions.comments) {
|
|
1915
|
+
addNode({
|
|
1916
|
+
type: 3,
|
|
1917
|
+
content: getSlice(start, end),
|
|
1918
|
+
loc: getLoc(start - 4, end + 3)
|
|
1919
|
+
});
|
|
1020
1920
|
}
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1921
|
+
},
|
|
1922
|
+
onend() {
|
|
1923
|
+
const end = currentInput.length;
|
|
1924
|
+
if (tokenizer.state !== 1) {
|
|
1925
|
+
switch (tokenizer.state) {
|
|
1926
|
+
case 5:
|
|
1927
|
+
case 8:
|
|
1928
|
+
emitError(5, end);
|
|
1929
|
+
break;
|
|
1930
|
+
case 3:
|
|
1931
|
+
case 4:
|
|
1932
|
+
emitError(
|
|
1933
|
+
25,
|
|
1934
|
+
tokenizer.sectionStart
|
|
1935
|
+
);
|
|
1936
|
+
break;
|
|
1937
|
+
case 28:
|
|
1938
|
+
if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
|
1939
|
+
emitError(6, end);
|
|
1940
|
+
} else {
|
|
1941
|
+
emitError(7, end);
|
|
1942
|
+
}
|
|
1943
|
+
break;
|
|
1944
|
+
case 6:
|
|
1945
|
+
case 7:
|
|
1946
|
+
case 9:
|
|
1947
|
+
case 11:
|
|
1948
|
+
case 12:
|
|
1949
|
+
case 13:
|
|
1950
|
+
case 14:
|
|
1951
|
+
case 15:
|
|
1952
|
+
case 16:
|
|
1953
|
+
case 17:
|
|
1954
|
+
case 18:
|
|
1955
|
+
case 19:
|
|
1956
|
+
case 20:
|
|
1957
|
+
case 21:
|
|
1958
|
+
emitError(9, end);
|
|
1959
|
+
break;
|
|
1025
1960
|
}
|
|
1026
1961
|
}
|
|
1962
|
+
for (let index = 0; index < stack.length; index++) {
|
|
1963
|
+
onCloseTag(stack[index], end - 1);
|
|
1964
|
+
emitError(24, stack[index].loc.start.offset);
|
|
1965
|
+
}
|
|
1966
|
+
},
|
|
1967
|
+
oncdata(start, end) {
|
|
1968
|
+
if (stack[0].ns !== 0) {
|
|
1969
|
+
onText(getSlice(start, end), start, end);
|
|
1970
|
+
} else {
|
|
1971
|
+
emitError(1, start - 9);
|
|
1972
|
+
}
|
|
1973
|
+
},
|
|
1974
|
+
onprocessinginstruction(start) {
|
|
1975
|
+
if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
1976
|
+
emitError(
|
|
1977
|
+
21,
|
|
1978
|
+
start - 1
|
|
1979
|
+
);
|
|
1980
|
+
}
|
|
1027
1981
|
}
|
|
1028
|
-
|
|
1982
|
+
});
|
|
1983
|
+
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
|
1984
|
+
const stripParensRE = /^\(|\)$/g;
|
|
1985
|
+
function parseForExpression(input) {
|
|
1986
|
+
const loc = input.loc;
|
|
1987
|
+
const exp = input.content;
|
|
1988
|
+
const inMatch = exp.match(forAliasRE);
|
|
1989
|
+
if (!inMatch)
|
|
1990
|
+
return;
|
|
1991
|
+
const [, LHS, RHS] = inMatch;
|
|
1992
|
+
const createAliasExpression = (content, offset) => {
|
|
1993
|
+
const start = loc.start.offset + offset;
|
|
1994
|
+
const end = start + content.length;
|
|
1995
|
+
return createSimpleExpression(content, false, getLoc(start, end));
|
|
1996
|
+
};
|
|
1997
|
+
const result = {
|
|
1998
|
+
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
1999
|
+
value: void 0,
|
|
2000
|
+
key: void 0,
|
|
2001
|
+
index: void 0,
|
|
2002
|
+
finalized: false
|
|
2003
|
+
};
|
|
2004
|
+
let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
|
2005
|
+
const trimmedOffset = LHS.indexOf(valueContent);
|
|
2006
|
+
const iteratorMatch = valueContent.match(forIteratorRE);
|
|
2007
|
+
if (iteratorMatch) {
|
|
2008
|
+
valueContent = valueContent.replace(forIteratorRE, "").trim();
|
|
2009
|
+
const keyContent = iteratorMatch[1].trim();
|
|
2010
|
+
let keyOffset;
|
|
2011
|
+
if (keyContent) {
|
|
2012
|
+
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
2013
|
+
result.key = createAliasExpression(keyContent, keyOffset);
|
|
2014
|
+
}
|
|
2015
|
+
if (iteratorMatch[2]) {
|
|
2016
|
+
const indexContent = iteratorMatch[2].trim();
|
|
2017
|
+
if (indexContent) {
|
|
2018
|
+
result.index = createAliasExpression(
|
|
2019
|
+
indexContent,
|
|
2020
|
+
exp.indexOf(
|
|
2021
|
+
indexContent,
|
|
2022
|
+
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
2023
|
+
)
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
if (valueContent) {
|
|
2029
|
+
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
2030
|
+
}
|
|
2031
|
+
return result;
|
|
1029
2032
|
}
|
|
1030
|
-
function
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
2033
|
+
function getSlice(start, end) {
|
|
2034
|
+
return currentInput.slice(start, end);
|
|
2035
|
+
}
|
|
2036
|
+
function endOpenTag(end) {
|
|
2037
|
+
addNode(currentOpenTag);
|
|
2038
|
+
const { tag, ns } = currentOpenTag;
|
|
2039
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2040
|
+
inPre++;
|
|
2041
|
+
}
|
|
2042
|
+
if (currentOptions.isVoidTag(tag)) {
|
|
2043
|
+
onCloseTag(currentOpenTag, end);
|
|
2044
|
+
} else {
|
|
2045
|
+
stack.unshift(currentOpenTag);
|
|
2046
|
+
if (ns === 1 || ns === 2) {
|
|
2047
|
+
tokenizer.inXML = true;
|
|
1038
2048
|
}
|
|
1039
2049
|
}
|
|
1040
|
-
|
|
2050
|
+
currentOpenTag = null;
|
|
1041
2051
|
}
|
|
1042
|
-
function
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
2052
|
+
function onText(content, start, end) {
|
|
2053
|
+
var _a;
|
|
2054
|
+
{
|
|
2055
|
+
const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
|
2056
|
+
if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
|
2057
|
+
content = currentOptions.decodeEntities(content, false);
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
const parent = stack[0] || currentRoot;
|
|
2061
|
+
const lastNode = parent.children[parent.children.length - 1];
|
|
2062
|
+
if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
|
2063
|
+
lastNode.content += content;
|
|
2064
|
+
setLocEnd(lastNode.loc, end);
|
|
1047
2065
|
} else {
|
|
1048
|
-
|
|
2066
|
+
parent.children.push({
|
|
2067
|
+
type: 2,
|
|
2068
|
+
content,
|
|
2069
|
+
loc: getLoc(start, end)
|
|
2070
|
+
});
|
|
1049
2071
|
}
|
|
1050
|
-
return nodes;
|
|
1051
2072
|
}
|
|
1052
|
-
function
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
const match = /--(\!)?>/.exec(context.source);
|
|
1056
|
-
if (!match) {
|
|
1057
|
-
content = context.source.slice(4);
|
|
1058
|
-
advanceBy(context, context.source.length);
|
|
1059
|
-
emitError(context, 7);
|
|
2073
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
2074
|
+
if (isImplied) {
|
|
2075
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
1060
2076
|
} else {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
if (
|
|
1065
|
-
|
|
2077
|
+
setLocEnd(el.loc, end + fastForward(end) + 1);
|
|
2078
|
+
}
|
|
2079
|
+
if (tokenizer.inSFCRoot) {
|
|
2080
|
+
if (el.children.length) {
|
|
2081
|
+
el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
|
2082
|
+
} else {
|
|
2083
|
+
el.innerLoc.end = extend({}, el.innerLoc.start);
|
|
1066
2084
|
}
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
2085
|
+
el.innerLoc.source = getSlice(
|
|
2086
|
+
el.innerLoc.start.offset,
|
|
2087
|
+
el.innerLoc.end.offset
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2090
|
+
const { tag, ns } = el;
|
|
2091
|
+
if (!inVPre) {
|
|
2092
|
+
if (tag === "slot") {
|
|
2093
|
+
el.tagType = 2;
|
|
2094
|
+
} else if (isFragmentTemplate(el)) {
|
|
2095
|
+
el.tagType = 3;
|
|
2096
|
+
} else if (isComponent(el)) {
|
|
2097
|
+
el.tagType = 1;
|
|
1076
2098
|
}
|
|
1077
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1078
2099
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
content = context.source.slice(contentStart);
|
|
1092
|
-
advanceBy(context, context.source.length);
|
|
1093
|
-
} else {
|
|
1094
|
-
content = context.source.slice(contentStart, closeIndex);
|
|
1095
|
-
advanceBy(context, closeIndex + 1);
|
|
2100
|
+
if (!tokenizer.inRCDATA) {
|
|
2101
|
+
el.children = condenseWhitespace(el.children, el.tag);
|
|
2102
|
+
}
|
|
2103
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2104
|
+
inPre--;
|
|
2105
|
+
}
|
|
2106
|
+
if (currentVPreBoundary === el) {
|
|
2107
|
+
inVPre = false;
|
|
2108
|
+
currentVPreBoundary = null;
|
|
2109
|
+
}
|
|
2110
|
+
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
2111
|
+
tokenizer.inXML = false;
|
|
1096
2112
|
}
|
|
1097
|
-
return {
|
|
1098
|
-
type: 3,
|
|
1099
|
-
content,
|
|
1100
|
-
loc: getSelection(context, start)
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
function parseElement(context, ancestors) {
|
|
1104
|
-
const wasInPre = context.inPre;
|
|
1105
|
-
const wasInVPre = context.inVPre;
|
|
1106
|
-
const parent = last(ancestors);
|
|
1107
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
1108
|
-
const isPreBoundary = context.inPre && !wasInPre;
|
|
1109
|
-
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
1110
|
-
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
1111
|
-
if (isPreBoundary) {
|
|
1112
|
-
context.inPre = false;
|
|
1113
|
-
}
|
|
1114
|
-
if (isVPreBoundary) {
|
|
1115
|
-
context.inVPre = false;
|
|
1116
|
-
}
|
|
1117
|
-
return element;
|
|
1118
|
-
}
|
|
1119
|
-
ancestors.push(element);
|
|
1120
|
-
const mode = context.options.getTextMode(element, parent);
|
|
1121
|
-
const children = parseChildren(context, mode, ancestors);
|
|
1122
|
-
ancestors.pop();
|
|
1123
2113
|
{
|
|
1124
|
-
const
|
|
2114
|
+
const props = el.props;
|
|
2115
|
+
if (isCompatEnabled(
|
|
2116
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2117
|
+
currentOptions
|
|
2118
|
+
)) {
|
|
2119
|
+
let hasIf = false;
|
|
2120
|
+
let hasFor = false;
|
|
2121
|
+
for (let i = 0; i < props.length; i++) {
|
|
2122
|
+
const p = props[i];
|
|
2123
|
+
if (p.type === 7) {
|
|
2124
|
+
if (p.name === "if") {
|
|
2125
|
+
hasIf = true;
|
|
2126
|
+
} else if (p.name === "for") {
|
|
2127
|
+
hasFor = true;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
if (hasIf && hasFor) {
|
|
2131
|
+
warnDeprecation(
|
|
2132
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2133
|
+
currentOptions,
|
|
2134
|
+
el.loc
|
|
2135
|
+
);
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
if (isCompatEnabled(
|
|
2141
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2142
|
+
currentOptions
|
|
2143
|
+
) && el.tag === "template" && !isFragmentTemplate(el)) {
|
|
2144
|
+
warnDeprecation(
|
|
2145
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2146
|
+
currentOptions,
|
|
2147
|
+
el.loc
|
|
2148
|
+
);
|
|
2149
|
+
const parent = stack[0] || currentRoot;
|
|
2150
|
+
const index = parent.children.indexOf(el);
|
|
2151
|
+
parent.children.splice(index, 1, ...el.children);
|
|
2152
|
+
}
|
|
2153
|
+
const inlineTemplateProp = props.find(
|
|
1125
2154
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
1126
2155
|
);
|
|
1127
2156
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1128
2157
|
"COMPILER_INLINE_TEMPLATE",
|
|
1129
|
-
|
|
2158
|
+
currentOptions,
|
|
1130
2159
|
inlineTemplateProp.loc
|
|
1131
|
-
)) {
|
|
1132
|
-
const loc = getSelection(context, element.loc.end);
|
|
2160
|
+
) && el.children.length) {
|
|
1133
2161
|
inlineTemplateProp.value = {
|
|
1134
2162
|
type: 2,
|
|
1135
|
-
content:
|
|
1136
|
-
|
|
2163
|
+
content: getSlice(
|
|
2164
|
+
el.children[0].loc.start.offset,
|
|
2165
|
+
el.children[el.children.length - 1].loc.end.offset
|
|
2166
|
+
),
|
|
2167
|
+
loc: inlineTemplateProp.loc
|
|
1137
2168
|
};
|
|
1138
2169
|
}
|
|
1139
2170
|
}
|
|
1140
|
-
element.children = children;
|
|
1141
|
-
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1142
|
-
parseTag(context, 1 /* End */, parent);
|
|
1143
|
-
} else {
|
|
1144
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1145
|
-
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1146
|
-
const first = children[0];
|
|
1147
|
-
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1148
|
-
emitError(context, 8);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
element.loc = getSelection(context, element.loc.start);
|
|
1153
|
-
if (isPreBoundary) {
|
|
1154
|
-
context.inPre = false;
|
|
1155
|
-
}
|
|
1156
|
-
if (isVPreBoundary) {
|
|
1157
|
-
context.inVPre = false;
|
|
1158
|
-
}
|
|
1159
|
-
return element;
|
|
1160
2171
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
)
|
|
1164
|
-
|
|
1165
|
-
const start = getCursor(context);
|
|
1166
|
-
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
|
1167
|
-
const tag = match[1];
|
|
1168
|
-
const ns = context.options.getNamespace(tag, parent);
|
|
1169
|
-
advanceBy(context, match[0].length);
|
|
1170
|
-
advanceSpaces(context);
|
|
1171
|
-
const cursor = getCursor(context);
|
|
1172
|
-
const currentSource = context.source;
|
|
1173
|
-
if (context.options.isPreTag(tag)) {
|
|
1174
|
-
context.inPre = true;
|
|
1175
|
-
}
|
|
1176
|
-
let props = parseAttributes(context, type);
|
|
1177
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1178
|
-
context.inVPre = true;
|
|
1179
|
-
extend(context, cursor);
|
|
1180
|
-
context.source = currentSource;
|
|
1181
|
-
props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
|
|
1182
|
-
}
|
|
1183
|
-
let isSelfClosing = false;
|
|
1184
|
-
if (context.source.length === 0) {
|
|
1185
|
-
emitError(context, 9);
|
|
1186
|
-
} else {
|
|
1187
|
-
isSelfClosing = startsWith(context.source, "/>");
|
|
1188
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1189
|
-
emitError(context, 4);
|
|
1190
|
-
}
|
|
1191
|
-
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1192
|
-
}
|
|
1193
|
-
if (type === 1 /* End */) {
|
|
1194
|
-
return;
|
|
2172
|
+
function fastForward(start, c) {
|
|
2173
|
+
let offset = 0;
|
|
2174
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2175
|
+
offset++;
|
|
1195
2176
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
2177
|
+
return offset;
|
|
2178
|
+
}
|
|
2179
|
+
function backTrack(index, c) {
|
|
2180
|
+
let i = index;
|
|
2181
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2182
|
+
i--;
|
|
2183
|
+
return i;
|
|
2184
|
+
}
|
|
2185
|
+
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
2186
|
+
function isFragmentTemplate({ tag, props }) {
|
|
2187
|
+
if (tag === "template") {
|
|
1202
2188
|
for (let i = 0; i < props.length; i++) {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
if (p.name === "if") {
|
|
1206
|
-
hasIf = true;
|
|
1207
|
-
} else if (p.name === "for") {
|
|
1208
|
-
hasFor = true;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
if (hasIf && hasFor) {
|
|
1212
|
-
warnDeprecation(
|
|
1213
|
-
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1214
|
-
context,
|
|
1215
|
-
getSelection(context, start)
|
|
1216
|
-
);
|
|
1217
|
-
break;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
let tagType = 0;
|
|
1222
|
-
if (!context.inVPre) {
|
|
1223
|
-
if (tag === "slot") {
|
|
1224
|
-
tagType = 2;
|
|
1225
|
-
} else if (tag === "template") {
|
|
1226
|
-
if (props.some(
|
|
1227
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1228
|
-
)) {
|
|
1229
|
-
tagType = 3;
|
|
2189
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2190
|
+
return true;
|
|
1230
2191
|
}
|
|
1231
|
-
} else if (isComponent(tag, props, context)) {
|
|
1232
|
-
tagType = 1;
|
|
1233
2192
|
}
|
|
1234
2193
|
}
|
|
1235
|
-
return
|
|
1236
|
-
type: 1,
|
|
1237
|
-
ns,
|
|
1238
|
-
tag,
|
|
1239
|
-
tagType,
|
|
1240
|
-
props,
|
|
1241
|
-
isSelfClosing,
|
|
1242
|
-
children: [],
|
|
1243
|
-
loc: getSelection(context, start),
|
|
1244
|
-
codegenNode: void 0
|
|
1245
|
-
// to be created during transform phase
|
|
1246
|
-
};
|
|
2194
|
+
return false;
|
|
1247
2195
|
}
|
|
1248
|
-
function isComponent(tag, props
|
|
1249
|
-
|
|
1250
|
-
if (
|
|
2196
|
+
function isComponent({ tag, props }) {
|
|
2197
|
+
var _a;
|
|
2198
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1251
2199
|
return false;
|
|
1252
2200
|
}
|
|
1253
|
-
if (tag === "component" ||
|
|
2201
|
+
if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
|
|
1254
2202
|
return true;
|
|
1255
2203
|
}
|
|
1256
2204
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1261,374 +2209,179 @@ function isComponent(tag, props, context) {
|
|
|
1261
2209
|
return true;
|
|
1262
2210
|
} else if (checkCompatEnabled(
|
|
1263
2211
|
"COMPILER_IS_ON_ELEMENT",
|
|
1264
|
-
|
|
2212
|
+
currentOptions,
|
|
1265
2213
|
p.loc
|
|
1266
2214
|
)) {
|
|
1267
2215
|
return true;
|
|
1268
2216
|
}
|
|
1269
2217
|
}
|
|
1270
|
-
} else
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
context,
|
|
1278
|
-
p.loc
|
|
1279
|
-
)
|
|
1280
|
-
) {
|
|
1281
|
-
return true;
|
|
1282
|
-
}
|
|
2218
|
+
} else if (// :is on plain element - only treat as component in compat mode
|
|
2219
|
+
p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
|
|
2220
|
+
"COMPILER_IS_ON_ELEMENT",
|
|
2221
|
+
currentOptions,
|
|
2222
|
+
p.loc
|
|
2223
|
+
)) {
|
|
2224
|
+
return true;
|
|
1283
2225
|
}
|
|
1284
2226
|
}
|
|
2227
|
+
return false;
|
|
1285
2228
|
}
|
|
1286
|
-
function
|
|
1287
|
-
|
|
1288
|
-
const attributeNames = /* @__PURE__ */ new Set();
|
|
1289
|
-
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1290
|
-
if (startsWith(context.source, "/")) {
|
|
1291
|
-
emitError(context, 22);
|
|
1292
|
-
advanceBy(context, 1);
|
|
1293
|
-
advanceSpaces(context);
|
|
1294
|
-
continue;
|
|
1295
|
-
}
|
|
1296
|
-
if (type === 1 /* End */) {
|
|
1297
|
-
emitError(context, 3);
|
|
1298
|
-
}
|
|
1299
|
-
const attr = parseAttribute(context, attributeNames);
|
|
1300
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1301
|
-
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1302
|
-
}
|
|
1303
|
-
if (type === 0 /* Start */) {
|
|
1304
|
-
props.push(attr);
|
|
1305
|
-
}
|
|
1306
|
-
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1307
|
-
emitError(context, 15);
|
|
1308
|
-
}
|
|
1309
|
-
advanceSpaces(context);
|
|
1310
|
-
}
|
|
1311
|
-
return props;
|
|
2229
|
+
function isUpperCase(c) {
|
|
2230
|
+
return c > 64 && c < 91;
|
|
1312
2231
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
advanceBy(context, name.length);
|
|
1337
|
-
let value = void 0;
|
|
1338
|
-
if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
|
1339
|
-
advanceSpaces(context);
|
|
1340
|
-
advanceBy(context, 1);
|
|
1341
|
-
advanceSpaces(context);
|
|
1342
|
-
value = parseAttributeValue(context);
|
|
1343
|
-
if (!value) {
|
|
1344
|
-
emitError(context, 13);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
const loc = getSelection(context, start);
|
|
1348
|
-
if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
|
1349
|
-
const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
|
|
1350
|
-
name
|
|
1351
|
-
);
|
|
1352
|
-
let isPropShorthand = startsWith(name, ".");
|
|
1353
|
-
let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
|
|
1354
|
-
let arg;
|
|
1355
|
-
if (match2[2]) {
|
|
1356
|
-
const isSlot = dirName === "slot";
|
|
1357
|
-
const startOffset = name.lastIndexOf(
|
|
1358
|
-
match2[2],
|
|
1359
|
-
name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
|
|
1360
|
-
);
|
|
1361
|
-
const loc2 = getSelection(
|
|
1362
|
-
context,
|
|
1363
|
-
getNewPosition(context, start, startOffset),
|
|
1364
|
-
getNewPosition(
|
|
1365
|
-
context,
|
|
1366
|
-
start,
|
|
1367
|
-
startOffset + match2[2].length + (isSlot && match2[3] || "").length
|
|
1368
|
-
)
|
|
1369
|
-
);
|
|
1370
|
-
let content = match2[2];
|
|
1371
|
-
let isStatic = true;
|
|
1372
|
-
if (content.startsWith("[")) {
|
|
1373
|
-
isStatic = false;
|
|
1374
|
-
if (!content.endsWith("]")) {
|
|
1375
|
-
emitError(
|
|
1376
|
-
context,
|
|
1377
|
-
27
|
|
1378
|
-
);
|
|
1379
|
-
content = content.slice(1);
|
|
1380
|
-
} else {
|
|
1381
|
-
content = content.slice(1, content.length - 1);
|
|
2232
|
+
const windowsNewlineRE = /\r\n/g;
|
|
2233
|
+
function condenseWhitespace(nodes, tag) {
|
|
2234
|
+
var _a, _b;
|
|
2235
|
+
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2236
|
+
let removedWhitespace = false;
|
|
2237
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2238
|
+
const node = nodes[i];
|
|
2239
|
+
if (node.type === 2) {
|
|
2240
|
+
if (!inPre) {
|
|
2241
|
+
if (isAllWhitespace(node.content)) {
|
|
2242
|
+
const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
|
2243
|
+
const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
|
2244
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2245
|
+
removedWhitespace = true;
|
|
2246
|
+
nodes[i] = null;
|
|
2247
|
+
} else {
|
|
2248
|
+
node.content = " ";
|
|
2249
|
+
}
|
|
2250
|
+
} else if (shouldCondense) {
|
|
2251
|
+
node.content = condense(node.content);
|
|
1382
2252
|
}
|
|
1383
|
-
} else
|
|
1384
|
-
content
|
|
1385
|
-
}
|
|
1386
|
-
arg = {
|
|
1387
|
-
type: 4,
|
|
1388
|
-
content,
|
|
1389
|
-
isStatic,
|
|
1390
|
-
constType: isStatic ? 3 : 0,
|
|
1391
|
-
loc: loc2
|
|
1392
|
-
};
|
|
1393
|
-
}
|
|
1394
|
-
if (value && value.isQuoted) {
|
|
1395
|
-
const valueLoc = value.loc;
|
|
1396
|
-
valueLoc.start.offset++;
|
|
1397
|
-
valueLoc.start.column++;
|
|
1398
|
-
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1399
|
-
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1400
|
-
}
|
|
1401
|
-
const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
|
|
1402
|
-
if (isPropShorthand)
|
|
1403
|
-
modifiers.push("prop");
|
|
1404
|
-
if (dirName === "bind" && arg) {
|
|
1405
|
-
if (modifiers.includes("sync") && checkCompatEnabled(
|
|
1406
|
-
"COMPILER_V_BIND_SYNC",
|
|
1407
|
-
context,
|
|
1408
|
-
loc,
|
|
1409
|
-
arg.loc.source
|
|
1410
|
-
)) {
|
|
1411
|
-
dirName = "model";
|
|
1412
|
-
modifiers.splice(modifiers.indexOf("sync"), 1);
|
|
1413
|
-
}
|
|
1414
|
-
if (modifiers.includes("prop")) {
|
|
1415
|
-
checkCompatEnabled(
|
|
1416
|
-
"COMPILER_V_BIND_PROP",
|
|
1417
|
-
context,
|
|
1418
|
-
loc
|
|
1419
|
-
);
|
|
2253
|
+
} else {
|
|
2254
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1420
2255
|
}
|
|
1421
2256
|
}
|
|
1422
|
-
return {
|
|
1423
|
-
type: 7,
|
|
1424
|
-
name: dirName,
|
|
1425
|
-
exp: value && {
|
|
1426
|
-
type: 4,
|
|
1427
|
-
content: value.content,
|
|
1428
|
-
isStatic: false,
|
|
1429
|
-
// Treat as non-constant by default. This can be potentially set to
|
|
1430
|
-
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1431
|
-
constType: 0,
|
|
1432
|
-
loc: value.loc
|
|
1433
|
-
},
|
|
1434
|
-
arg,
|
|
1435
|
-
modifiers,
|
|
1436
|
-
loc
|
|
1437
|
-
};
|
|
1438
2257
|
}
|
|
1439
|
-
if (
|
|
1440
|
-
|
|
2258
|
+
if (inPre && tag && currentOptions.isPreTag(tag)) {
|
|
2259
|
+
const first = nodes[0];
|
|
2260
|
+
if (first && first.type === 2) {
|
|
2261
|
+
first.content = first.content.replace(/^\r?\n/, "");
|
|
2262
|
+
}
|
|
1441
2263
|
}
|
|
1442
|
-
return
|
|
1443
|
-
type: 6,
|
|
1444
|
-
name,
|
|
1445
|
-
value: value && {
|
|
1446
|
-
type: 2,
|
|
1447
|
-
content: value.content,
|
|
1448
|
-
loc: value.loc
|
|
1449
|
-
},
|
|
1450
|
-
loc
|
|
1451
|
-
};
|
|
2264
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1452
2265
|
}
|
|
1453
|
-
function
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
const isQuoted = quote === `"` || quote === `'`;
|
|
1458
|
-
if (isQuoted) {
|
|
1459
|
-
advanceBy(context, 1);
|
|
1460
|
-
const endIndex = context.source.indexOf(quote);
|
|
1461
|
-
if (endIndex === -1) {
|
|
1462
|
-
content = parseTextData(
|
|
1463
|
-
context,
|
|
1464
|
-
context.source.length,
|
|
1465
|
-
4
|
|
1466
|
-
);
|
|
1467
|
-
} else {
|
|
1468
|
-
content = parseTextData(context, endIndex, 4);
|
|
1469
|
-
advanceBy(context, 1);
|
|
1470
|
-
}
|
|
1471
|
-
} else {
|
|
1472
|
-
const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
|
1473
|
-
if (!match) {
|
|
1474
|
-
return void 0;
|
|
1475
|
-
}
|
|
1476
|
-
const unexpectedChars = /["'<=`]/g;
|
|
1477
|
-
let m;
|
|
1478
|
-
while (m = unexpectedChars.exec(match[0])) {
|
|
1479
|
-
emitError(
|
|
1480
|
-
context,
|
|
1481
|
-
18,
|
|
1482
|
-
m.index
|
|
1483
|
-
);
|
|
2266
|
+
function isAllWhitespace(str) {
|
|
2267
|
+
for (let i = 0; i < str.length; i++) {
|
|
2268
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2269
|
+
return false;
|
|
1484
2270
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1488
|
-
}
|
|
1489
|
-
function parseInterpolation(context, mode) {
|
|
1490
|
-
const [open, close] = context.options.delimiters;
|
|
1491
|
-
const closeIndex = context.source.indexOf(close, open.length);
|
|
1492
|
-
if (closeIndex === -1) {
|
|
1493
|
-
emitError(context, 25);
|
|
1494
|
-
return void 0;
|
|
1495
|
-
}
|
|
1496
|
-
const start = getCursor(context);
|
|
1497
|
-
advanceBy(context, open.length);
|
|
1498
|
-
const innerStart = getCursor(context);
|
|
1499
|
-
const innerEnd = getCursor(context);
|
|
1500
|
-
const rawContentLength = closeIndex - open.length;
|
|
1501
|
-
const rawContent = context.source.slice(0, rawContentLength);
|
|
1502
|
-
const preTrimContent = parseTextData(context, rawContentLength, mode);
|
|
1503
|
-
const content = preTrimContent.trim();
|
|
1504
|
-
const startOffset = preTrimContent.indexOf(content);
|
|
1505
|
-
if (startOffset > 0) {
|
|
1506
|
-
advancePositionWithMutation(innerStart, rawContent, startOffset);
|
|
1507
|
-
}
|
|
1508
|
-
const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
|
1509
|
-
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1510
|
-
advanceBy(context, close.length);
|
|
1511
|
-
return {
|
|
1512
|
-
type: 5,
|
|
1513
|
-
content: {
|
|
1514
|
-
type: 4,
|
|
1515
|
-
isStatic: false,
|
|
1516
|
-
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1517
|
-
constType: 0,
|
|
1518
|
-
content,
|
|
1519
|
-
loc: getSelection(context, innerStart, innerEnd)
|
|
1520
|
-
},
|
|
1521
|
-
loc: getSelection(context, start)
|
|
1522
|
-
};
|
|
2271
|
+
}
|
|
2272
|
+
return true;
|
|
1523
2273
|
}
|
|
1524
|
-
function
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
if (index !== -1 && endIndex > index) {
|
|
1530
|
-
endIndex = index;
|
|
2274
|
+
function hasNewlineChar(str) {
|
|
2275
|
+
for (let i = 0; i < str.length; i++) {
|
|
2276
|
+
const c = str.charCodeAt(i);
|
|
2277
|
+
if (c === 10 || c === 13) {
|
|
2278
|
+
return true;
|
|
1531
2279
|
}
|
|
1532
2280
|
}
|
|
1533
|
-
|
|
1534
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1535
|
-
return {
|
|
1536
|
-
type: 2,
|
|
1537
|
-
content,
|
|
1538
|
-
loc: getSelection(context, start)
|
|
1539
|
-
};
|
|
2281
|
+
return false;
|
|
1540
2282
|
}
|
|
1541
|
-
function
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
2283
|
+
function condense(str) {
|
|
2284
|
+
let ret = "";
|
|
2285
|
+
let prevCharIsWhitespace = false;
|
|
2286
|
+
for (let i = 0; i < str.length; i++) {
|
|
2287
|
+
if (isWhitespace(str.charCodeAt(i))) {
|
|
2288
|
+
if (!prevCharIsWhitespace) {
|
|
2289
|
+
ret += " ";
|
|
2290
|
+
prevCharIsWhitespace = true;
|
|
2291
|
+
}
|
|
2292
|
+
} else {
|
|
2293
|
+
ret += str[i];
|
|
2294
|
+
prevCharIsWhitespace = false;
|
|
2295
|
+
}
|
|
1551
2296
|
}
|
|
2297
|
+
return ret;
|
|
1552
2298
|
}
|
|
1553
|
-
function
|
|
1554
|
-
|
|
1555
|
-
return { column, line, offset };
|
|
2299
|
+
function addNode(node) {
|
|
2300
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1556
2301
|
}
|
|
1557
|
-
function
|
|
1558
|
-
end = end || getCursor(context);
|
|
2302
|
+
function getLoc(start, end) {
|
|
1559
2303
|
return {
|
|
1560
|
-
start,
|
|
1561
|
-
|
|
1562
|
-
|
|
2304
|
+
start: tokenizer.getPos(start),
|
|
2305
|
+
// @ts-expect-error allow late attachment
|
|
2306
|
+
end: end == null ? end : tokenizer.getPos(end),
|
|
2307
|
+
// @ts-expect-error allow late attachment
|
|
2308
|
+
source: end == null ? end : getSlice(start, end)
|
|
1563
2309
|
};
|
|
1564
2310
|
}
|
|
1565
|
-
function
|
|
1566
|
-
|
|
2311
|
+
function setLocEnd(loc, end) {
|
|
2312
|
+
loc.end = tokenizer.getPos(end);
|
|
2313
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1567
2314
|
}
|
|
1568
|
-
function
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
loc.column += offset;
|
|
2315
|
+
function dirToAttr(dir) {
|
|
2316
|
+
const attr = {
|
|
2317
|
+
type: 6,
|
|
2318
|
+
name: dir.rawName,
|
|
2319
|
+
nameLoc: getLoc(
|
|
2320
|
+
dir.loc.start.offset,
|
|
2321
|
+
dir.loc.start.offset + dir.rawName.length
|
|
2322
|
+
),
|
|
2323
|
+
value: void 0,
|
|
2324
|
+
loc: dir.loc
|
|
2325
|
+
};
|
|
2326
|
+
if (dir.exp) {
|
|
2327
|
+
const loc = dir.exp.loc;
|
|
2328
|
+
if (loc.end.offset < dir.loc.end.offset) {
|
|
2329
|
+
loc.start.offset--;
|
|
2330
|
+
loc.start.column--;
|
|
2331
|
+
loc.end.offset++;
|
|
2332
|
+
loc.end.column++;
|
|
2333
|
+
}
|
|
2334
|
+
attr.value = {
|
|
2335
|
+
type: 2,
|
|
2336
|
+
content: dir.exp.content,
|
|
2337
|
+
loc
|
|
2338
|
+
};
|
|
1593
2339
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
);
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1618
|
-
return true;
|
|
2340
|
+
return attr;
|
|
2341
|
+
}
|
|
2342
|
+
function emitError(code, index) {
|
|
2343
|
+
currentOptions.onError(createCompilerError(code, getLoc(index, index)));
|
|
2344
|
+
}
|
|
2345
|
+
function reset() {
|
|
2346
|
+
tokenizer.reset();
|
|
2347
|
+
currentOpenTag = null;
|
|
2348
|
+
currentProp = null;
|
|
2349
|
+
currentAttrValue = "";
|
|
2350
|
+
currentAttrStartIndex = -1;
|
|
2351
|
+
currentAttrEndIndex = -1;
|
|
2352
|
+
stack.length = 0;
|
|
2353
|
+
}
|
|
2354
|
+
function baseParse(input, options) {
|
|
2355
|
+
reset();
|
|
2356
|
+
currentInput = input;
|
|
2357
|
+
currentOptions = extend({}, defaultParserOptions);
|
|
2358
|
+
if (options) {
|
|
2359
|
+
let key;
|
|
2360
|
+
for (key in options) {
|
|
2361
|
+
if (options[key] != null) {
|
|
2362
|
+
currentOptions[key] = options[key];
|
|
1619
2363
|
}
|
|
1620
|
-
break;
|
|
1621
2364
|
}
|
|
1622
|
-
case 3:
|
|
1623
|
-
if (startsWith(s, "]]>")) {
|
|
1624
|
-
return true;
|
|
1625
|
-
}
|
|
1626
|
-
break;
|
|
1627
2365
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
2366
|
+
{
|
|
2367
|
+
if (!currentOptions.decodeEntities) {
|
|
2368
|
+
throw new Error(
|
|
2369
|
+
`[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
|
2370
|
+
);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2374
|
+
const delimiters = options == null ? void 0 : options.delimiters;
|
|
2375
|
+
if (delimiters) {
|
|
2376
|
+
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2377
|
+
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
2378
|
+
}
|
|
2379
|
+
const root = currentRoot = createRoot([], input);
|
|
2380
|
+
tokenizer.parse(currentInput);
|
|
2381
|
+
root.loc = getLoc(0, input.length);
|
|
2382
|
+
root.children = condenseWhitespace(root.children);
|
|
2383
|
+
currentRoot = null;
|
|
2384
|
+
return root;
|
|
1632
2385
|
}
|
|
1633
2386
|
|
|
1634
2387
|
function hoistStatic(root, context) {
|
|
@@ -2040,6 +2793,7 @@ function transform(root, options) {
|
|
|
2040
2793
|
root.hoists = context.hoists;
|
|
2041
2794
|
root.temps = context.temps;
|
|
2042
2795
|
root.cached = context.cached;
|
|
2796
|
+
root.transformed = true;
|
|
2043
2797
|
{
|
|
2044
2798
|
root.filters = [...context.filters];
|
|
2045
2799
|
}
|
|
@@ -2196,7 +2950,7 @@ function createCodegenContext(ast, {
|
|
|
2196
2950
|
ssr,
|
|
2197
2951
|
isTS,
|
|
2198
2952
|
inSSR,
|
|
2199
|
-
source: ast.
|
|
2953
|
+
source: ast.source,
|
|
2200
2954
|
code: ``,
|
|
2201
2955
|
column: 1,
|
|
2202
2956
|
line: 1,
|
|
@@ -2207,7 +2961,7 @@ function createCodegenContext(ast, {
|
|
|
2207
2961
|
helper(key) {
|
|
2208
2962
|
return `_${helperNameMap[key]}`;
|
|
2209
2963
|
},
|
|
2210
|
-
push(code, node) {
|
|
2964
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2211
2965
|
context.code += code;
|
|
2212
2966
|
},
|
|
2213
2967
|
indent() {
|
|
@@ -2225,7 +2979,7 @@ function createCodegenContext(ast, {
|
|
|
2225
2979
|
}
|
|
2226
2980
|
};
|
|
2227
2981
|
function newline(n) {
|
|
2228
|
-
context.push("\n" + ` `.repeat(n));
|
|
2982
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2229
2983
|
}
|
|
2230
2984
|
return context;
|
|
2231
2985
|
}
|
|
@@ -2262,9 +3016,11 @@ function generate(ast, options = {}) {
|
|
|
2262
3016
|
push(`with (_ctx) {`);
|
|
2263
3017
|
indent();
|
|
2264
3018
|
if (hasHelpers) {
|
|
2265
|
-
push(
|
|
2266
|
-
|
|
2267
|
-
|
|
3019
|
+
push(
|
|
3020
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3021
|
+
`,
|
|
3022
|
+
-1 /* End */
|
|
3023
|
+
);
|
|
2268
3024
|
newline();
|
|
2269
3025
|
}
|
|
2270
3026
|
}
|
|
@@ -2293,7 +3049,7 @@ function generate(ast, options = {}) {
|
|
|
2293
3049
|
}
|
|
2294
3050
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2295
3051
|
push(`
|
|
2296
|
-
|
|
3052
|
+
`, 0 /* Start */);
|
|
2297
3053
|
newline();
|
|
2298
3054
|
}
|
|
2299
3055
|
if (!ssr) {
|
|
@@ -2314,7 +3070,6 @@ function generate(ast, options = {}) {
|
|
|
2314
3070
|
ast,
|
|
2315
3071
|
code: context.code,
|
|
2316
3072
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2317
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2318
3073
|
map: context.map ? context.map.toJSON() : void 0
|
|
2319
3074
|
};
|
|
2320
3075
|
}
|
|
@@ -2333,7 +3088,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2333
3088
|
if (helpers.length > 0) {
|
|
2334
3089
|
{
|
|
2335
3090
|
push(`const _Vue = ${VueBinding}
|
|
2336
|
-
|
|
3091
|
+
`, -1 /* End */);
|
|
2337
3092
|
if (ast.hoists.length) {
|
|
2338
3093
|
const staticHelpers = [
|
|
2339
3094
|
CREATE_VNODE,
|
|
@@ -2343,7 +3098,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
2343
3098
|
CREATE_STATIC
|
|
2344
3099
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2345
3100
|
push(`const { ${staticHelpers} } = _Vue
|
|
2346
|
-
|
|
3101
|
+
`, -1 /* End */);
|
|
2347
3102
|
}
|
|
2348
3103
|
}
|
|
2349
3104
|
}
|
|
@@ -2404,7 +3159,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2404
3159
|
for (let i = 0; i < nodes.length; i++) {
|
|
2405
3160
|
const node = nodes[i];
|
|
2406
3161
|
if (isString(node)) {
|
|
2407
|
-
push(node);
|
|
3162
|
+
push(node, -3 /* Unknown */);
|
|
2408
3163
|
} else if (isArray(node)) {
|
|
2409
3164
|
genNodeListAsArray(node, context);
|
|
2410
3165
|
} else {
|
|
@@ -2422,7 +3177,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
2422
3177
|
}
|
|
2423
3178
|
function genNode(node, context) {
|
|
2424
3179
|
if (isString(node)) {
|
|
2425
|
-
context.push(node);
|
|
3180
|
+
context.push(node, -3 /* Unknown */);
|
|
2426
3181
|
return;
|
|
2427
3182
|
}
|
|
2428
3183
|
if (isSymbol(node)) {
|
|
@@ -2502,11 +3257,15 @@ function genNode(node, context) {
|
|
|
2502
3257
|
}
|
|
2503
3258
|
}
|
|
2504
3259
|
function genText(node, context) {
|
|
2505
|
-
context.push(JSON.stringify(node.content), node);
|
|
3260
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2506
3261
|
}
|
|
2507
3262
|
function genExpression(node, context) {
|
|
2508
3263
|
const { content, isStatic } = node;
|
|
2509
|
-
context.push(
|
|
3264
|
+
context.push(
|
|
3265
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3266
|
+
-3 /* Unknown */,
|
|
3267
|
+
node
|
|
3268
|
+
);
|
|
2510
3269
|
}
|
|
2511
3270
|
function genInterpolation(node, context) {
|
|
2512
3271
|
const { push, helper, pure } = context;
|
|
@@ -2520,7 +3279,7 @@ function genCompoundExpression(node, context) {
|
|
|
2520
3279
|
for (let i = 0; i < node.children.length; i++) {
|
|
2521
3280
|
const child = node.children[i];
|
|
2522
3281
|
if (isString(child)) {
|
|
2523
|
-
context.push(child);
|
|
3282
|
+
context.push(child, -3 /* Unknown */);
|
|
2524
3283
|
} else {
|
|
2525
3284
|
genNode(child, context);
|
|
2526
3285
|
}
|
|
@@ -2534,9 +3293,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
2534
3293
|
push(`]`);
|
|
2535
3294
|
} else if (node.isStatic) {
|
|
2536
3295
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2537
|
-
push(text, node);
|
|
3296
|
+
push(text, -2 /* None */, node);
|
|
2538
3297
|
} else {
|
|
2539
|
-
push(`[${node.content}]`, node);
|
|
3298
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2540
3299
|
}
|
|
2541
3300
|
}
|
|
2542
3301
|
function genComment(node, context) {
|
|
@@ -2544,7 +3303,11 @@ function genComment(node, context) {
|
|
|
2544
3303
|
if (pure) {
|
|
2545
3304
|
push(PURE_ANNOTATION);
|
|
2546
3305
|
}
|
|
2547
|
-
push(
|
|
3306
|
+
push(
|
|
3307
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3308
|
+
-3 /* Unknown */,
|
|
3309
|
+
node
|
|
3310
|
+
);
|
|
2548
3311
|
}
|
|
2549
3312
|
function genVNodeCall(node, context) {
|
|
2550
3313
|
const { push, helper, pure } = context;
|
|
@@ -2569,7 +3332,7 @@ function genVNodeCall(node, context) {
|
|
|
2569
3332
|
push(PURE_ANNOTATION);
|
|
2570
3333
|
}
|
|
2571
3334
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2572
|
-
push(helper(callHelper) + `(`, node);
|
|
3335
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2573
3336
|
genNodeList(
|
|
2574
3337
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2575
3338
|
context
|
|
@@ -2598,7 +3361,7 @@ function genCallExpression(node, context) {
|
|
|
2598
3361
|
if (pure) {
|
|
2599
3362
|
push(PURE_ANNOTATION);
|
|
2600
3363
|
}
|
|
2601
|
-
push(callee + `(`, node);
|
|
3364
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2602
3365
|
genNodeList(node.arguments, context);
|
|
2603
3366
|
push(`)`);
|
|
2604
3367
|
}
|
|
@@ -2606,7 +3369,7 @@ function genObjectExpression(node, context) {
|
|
|
2606
3369
|
const { push, indent, deindent, newline } = context;
|
|
2607
3370
|
const { properties } = node;
|
|
2608
3371
|
if (!properties.length) {
|
|
2609
|
-
push(`{}`, node);
|
|
3372
|
+
push(`{}`, -2 /* None */, node);
|
|
2610
3373
|
return;
|
|
2611
3374
|
}
|
|
2612
3375
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -2634,7 +3397,7 @@ function genFunctionExpression(node, context) {
|
|
|
2634
3397
|
if (isSlot) {
|
|
2635
3398
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2636
3399
|
}
|
|
2637
|
-
push(`(`, node);
|
|
3400
|
+
push(`(`, -2 /* None */, node);
|
|
2638
3401
|
if (isArray(params)) {
|
|
2639
3402
|
genNodeList(params, context);
|
|
2640
3403
|
} else if (params) {
|
|
@@ -2769,6 +3532,15 @@ function walkBlockDeclarations(block, onIdent) {
|
|
|
2769
3532
|
if (stmt.declare || !stmt.id)
|
|
2770
3533
|
continue;
|
|
2771
3534
|
onIdent(stmt.id);
|
|
3535
|
+
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
3536
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
3537
|
+
if (variable && variable.type === "VariableDeclaration") {
|
|
3538
|
+
for (const decl of variable.declarations) {
|
|
3539
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
3540
|
+
onIdent(id);
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
2772
3544
|
}
|
|
2773
3545
|
}
|
|
2774
3546
|
}
|
|
@@ -2979,7 +3751,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2979
3751
|
context.removeNode();
|
|
2980
3752
|
const branch = createIfBranch(node, dir);
|
|
2981
3753
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2982
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3754
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2983
3755
|
branch.children = [...comments, ...branch.children];
|
|
2984
3756
|
}
|
|
2985
3757
|
{
|
|
@@ -3261,18 +4033,14 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3261
4033
|
);
|
|
3262
4034
|
return;
|
|
3263
4035
|
}
|
|
3264
|
-
const parseResult =
|
|
3265
|
-
// can only be simple expression because vFor transform is applied
|
|
3266
|
-
// before expression transform.
|
|
3267
|
-
dir.exp,
|
|
3268
|
-
context
|
|
3269
|
-
);
|
|
4036
|
+
const parseResult = dir.forParseResult;
|
|
3270
4037
|
if (!parseResult) {
|
|
3271
4038
|
context.onError(
|
|
3272
4039
|
createCompilerError(32, dir.loc)
|
|
3273
4040
|
);
|
|
3274
4041
|
return;
|
|
3275
4042
|
}
|
|
4043
|
+
finalizeForParseResult(parseResult, context);
|
|
3276
4044
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3277
4045
|
const { source, value, key, index } = parseResult;
|
|
3278
4046
|
const forNode = {
|
|
@@ -3294,71 +4062,26 @@ function processFor(node, dir, context, processCodegen) {
|
|
|
3294
4062
|
onExit();
|
|
3295
4063
|
};
|
|
3296
4064
|
}
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
const stripParensRE = /^\(|\)$/g;
|
|
3300
|
-
function parseForExpression(input, context) {
|
|
3301
|
-
const loc = input.loc;
|
|
3302
|
-
const exp = input.content;
|
|
3303
|
-
const inMatch = exp.match(forAliasRE);
|
|
3304
|
-
if (!inMatch)
|
|
4065
|
+
function finalizeForParseResult(result, context) {
|
|
4066
|
+
if (result.finalized)
|
|
3305
4067
|
return;
|
|
3306
|
-
const [, LHS, RHS] = inMatch;
|
|
3307
|
-
const result = {
|
|
3308
|
-
source: createAliasExpression(
|
|
3309
|
-
loc,
|
|
3310
|
-
RHS.trim(),
|
|
3311
|
-
exp.indexOf(RHS, LHS.length)
|
|
3312
|
-
),
|
|
3313
|
-
value: void 0,
|
|
3314
|
-
key: void 0,
|
|
3315
|
-
index: void 0
|
|
3316
|
-
};
|
|
3317
4068
|
{
|
|
3318
4069
|
validateBrowserExpression(result.source, context);
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
const keyContent = iteratorMatch[1].trim();
|
|
3326
|
-
let keyOffset;
|
|
3327
|
-
if (keyContent) {
|
|
3328
|
-
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
3329
|
-
result.key = createAliasExpression(loc, keyContent, keyOffset);
|
|
3330
|
-
{
|
|
3331
|
-
validateBrowserExpression(
|
|
3332
|
-
result.key,
|
|
3333
|
-
context,
|
|
3334
|
-
true
|
|
3335
|
-
);
|
|
3336
|
-
}
|
|
4070
|
+
if (result.key) {
|
|
4071
|
+
validateBrowserExpression(
|
|
4072
|
+
result.key,
|
|
4073
|
+
context,
|
|
4074
|
+
true
|
|
4075
|
+
);
|
|
3337
4076
|
}
|
|
3338
|
-
if (
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
exp.indexOf(
|
|
3345
|
-
indexContent,
|
|
3346
|
-
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
3347
|
-
)
|
|
3348
|
-
);
|
|
3349
|
-
{
|
|
3350
|
-
validateBrowserExpression(
|
|
3351
|
-
result.index,
|
|
3352
|
-
context,
|
|
3353
|
-
true
|
|
3354
|
-
);
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
4077
|
+
if (result.index) {
|
|
4078
|
+
validateBrowserExpression(
|
|
4079
|
+
result.index,
|
|
4080
|
+
context,
|
|
4081
|
+
true
|
|
4082
|
+
);
|
|
3357
4083
|
}
|
|
3358
|
-
|
|
3359
|
-
if (valueContent) {
|
|
3360
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3361
|
-
{
|
|
4084
|
+
if (result.value) {
|
|
3362
4085
|
validateBrowserExpression(
|
|
3363
4086
|
result.value,
|
|
3364
4087
|
context,
|
|
@@ -3366,14 +4089,7 @@ function parseForExpression(input, context) {
|
|
|
3366
4089
|
);
|
|
3367
4090
|
}
|
|
3368
4091
|
}
|
|
3369
|
-
|
|
3370
|
-
}
|
|
3371
|
-
function createAliasExpression(range, content, offset) {
|
|
3372
|
-
return createSimpleExpression(
|
|
3373
|
-
content,
|
|
3374
|
-
false,
|
|
3375
|
-
getInnerRange(range, offset, content.length)
|
|
3376
|
-
);
|
|
4092
|
+
result.finalized = true;
|
|
3377
4093
|
}
|
|
3378
4094
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3379
4095
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3403,11 +4119,9 @@ const trackSlotScopes = (node, context) => {
|
|
|
3403
4119
|
const trackVForSlotScopes = (node, context) => {
|
|
3404
4120
|
let vFor;
|
|
3405
4121
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3406
|
-
const result = vFor.
|
|
3407
|
-
vFor.exp,
|
|
3408
|
-
context
|
|
3409
|
-
);
|
|
4122
|
+
const result = vFor.forParseResult;
|
|
3410
4123
|
if (result) {
|
|
4124
|
+
finalizeForParseResult(result, context);
|
|
3411
4125
|
const { value, key, index } = result;
|
|
3412
4126
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3413
4127
|
value && addIdentifiers(value);
|
|
@@ -3481,12 +4195,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3481
4195
|
hasDynamicSlots = true;
|
|
3482
4196
|
}
|
|
3483
4197
|
const vFor = findDir(slotElement, "for");
|
|
3484
|
-
const slotFunction = buildSlotFn(
|
|
3485
|
-
slotProps,
|
|
3486
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3487
|
-
slotChildren,
|
|
3488
|
-
slotLoc
|
|
3489
|
-
);
|
|
4198
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3490
4199
|
let vIf;
|
|
3491
4200
|
let vElse;
|
|
3492
4201
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3535,8 +4244,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3535
4244
|
}
|
|
3536
4245
|
} else if (vFor) {
|
|
3537
4246
|
hasDynamicSlots = true;
|
|
3538
|
-
const parseResult = vFor.
|
|
4247
|
+
const parseResult = vFor.forParseResult;
|
|
3539
4248
|
if (parseResult) {
|
|
4249
|
+
finalizeForParseResult(parseResult, context);
|
|
3540
4250
|
dynamicSlots.push(
|
|
3541
4251
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3542
4252
|
parseResult.source,
|
|
@@ -3797,17 +4507,6 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3797
4507
|
tag = isProp.value.content.slice(4);
|
|
3798
4508
|
}
|
|
3799
4509
|
}
|
|
3800
|
-
const isDir = !isExplicitDynamic && findDir(node, "is");
|
|
3801
|
-
if (isDir && isDir.exp) {
|
|
3802
|
-
{
|
|
3803
|
-
context.onWarn(
|
|
3804
|
-
createCompilerError(52, isDir.loc)
|
|
3805
|
-
);
|
|
3806
|
-
}
|
|
3807
|
-
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
3808
|
-
isDir.exp
|
|
3809
|
-
]);
|
|
3810
|
-
}
|
|
3811
4510
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3812
4511
|
if (builtIn) {
|
|
3813
4512
|
if (!ssr)
|
|
@@ -3879,7 +4578,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3879
4578
|
for (let i = 0; i < props.length; i++) {
|
|
3880
4579
|
const prop = props[i];
|
|
3881
4580
|
if (prop.type === 6) {
|
|
3882
|
-
const { loc, name, value } = prop;
|
|
4581
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3883
4582
|
let isStatic = true;
|
|
3884
4583
|
if (name === "ref") {
|
|
3885
4584
|
hasRef = true;
|
|
@@ -3900,11 +4599,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3900
4599
|
}
|
|
3901
4600
|
properties.push(
|
|
3902
4601
|
createObjectProperty(
|
|
3903
|
-
createSimpleExpression(
|
|
3904
|
-
name,
|
|
3905
|
-
true,
|
|
3906
|
-
getInnerRange(loc, 0, name.length)
|
|
3907
|
-
),
|
|
4602
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3908
4603
|
createSimpleExpression(
|
|
3909
4604
|
value ? value.content : "",
|
|
3910
4605
|
isStatic,
|
|
@@ -3913,7 +4608,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
3913
4608
|
)
|
|
3914
4609
|
);
|
|
3915
4610
|
} else {
|
|
3916
|
-
const { name, arg, exp, loc } = prop;
|
|
4611
|
+
const { name, arg, exp, loc, modifiers } = prop;
|
|
3917
4612
|
const isVBind = name === "bind";
|
|
3918
4613
|
const isVOn = name === "on";
|
|
3919
4614
|
if (name === "slot") {
|
|
@@ -4006,6 +4701,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
4006
4701
|
}
|
|
4007
4702
|
continue;
|
|
4008
4703
|
}
|
|
4704
|
+
if (isVBind && modifiers.includes("prop")) {
|
|
4705
|
+
patchFlag |= 32;
|
|
4706
|
+
}
|
|
4009
4707
|
const directiveTransform = context.directiveTransforms[name];
|
|
4010
4708
|
if (directiveTransform) {
|
|
4011
4709
|
const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
|
@@ -4383,8 +5081,13 @@ const transformOn$1 = (dir, node, context, augmentor) => {
|
|
|
4383
5081
|
};
|
|
4384
5082
|
|
|
4385
5083
|
const transformBind = (dir, _node, context) => {
|
|
4386
|
-
const {
|
|
5084
|
+
const { modifiers, loc } = dir;
|
|
4387
5085
|
const arg = dir.arg;
|
|
5086
|
+
let { exp } = dir;
|
|
5087
|
+
if (!exp && arg.type === 4) {
|
|
5088
|
+
const propName = camelize(arg.content);
|
|
5089
|
+
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5090
|
+
}
|
|
4388
5091
|
if (arg.type !== 4) {
|
|
4389
5092
|
arg.children.unshift(`(`);
|
|
4390
5093
|
arg.children.push(`) || ""`);
|
|
@@ -4783,7 +5486,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
|
|
|
4783
5486
|
}
|
|
4784
5487
|
];
|
|
4785
5488
|
}
|
|
4786
|
-
function baseCompile(
|
|
5489
|
+
function baseCompile(source, options = {}) {
|
|
4787
5490
|
const onError = options.onError || defaultOnError;
|
|
4788
5491
|
const isModuleMode = options.mode === "module";
|
|
4789
5492
|
{
|
|
@@ -4800,7 +5503,7 @@ function baseCompile(template, options = {}) {
|
|
|
4800
5503
|
if (options.scopeId && !isModuleMode) {
|
|
4801
5504
|
onError(createCompilerError(50));
|
|
4802
5505
|
}
|
|
4803
|
-
const ast = isString(
|
|
5506
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4804
5507
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4805
5508
|
transform(
|
|
4806
5509
|
ast,
|
|
@@ -4866,25 +5569,22 @@ function decodeHtmlBrowser(raw, asAttr = false) {
|
|
|
4866
5569
|
}
|
|
4867
5570
|
}
|
|
4868
5571
|
|
|
4869
|
-
const isRawTextContainer = /* @__PURE__ */ makeMap(
|
|
4870
|
-
"style,iframe,script,noscript",
|
|
4871
|
-
true
|
|
4872
|
-
);
|
|
4873
5572
|
const parserOptions = {
|
|
5573
|
+
parseMode: "html",
|
|
4874
5574
|
isVoidTag,
|
|
4875
5575
|
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
4876
5576
|
isPreTag: (tag) => tag === "pre",
|
|
4877
5577
|
decodeEntities: decodeHtmlBrowser ,
|
|
4878
5578
|
isBuiltInComponent: (tag) => {
|
|
4879
|
-
if (
|
|
5579
|
+
if (tag === "Transition" || tag === "transition") {
|
|
4880
5580
|
return TRANSITION;
|
|
4881
|
-
} else if (
|
|
5581
|
+
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
|
4882
5582
|
return TRANSITION_GROUP;
|
|
4883
5583
|
}
|
|
4884
5584
|
},
|
|
4885
5585
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
4886
|
-
getNamespace(tag, parent) {
|
|
4887
|
-
let ns = parent ? parent.ns :
|
|
5586
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
5587
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
4888
5588
|
if (parent && ns === 2) {
|
|
4889
5589
|
if (parent.tag === "annotation-xml") {
|
|
4890
5590
|
if (tag === "svg") {
|
|
@@ -4912,18 +5612,6 @@ const parserOptions = {
|
|
|
4912
5612
|
}
|
|
4913
5613
|
}
|
|
4914
5614
|
return ns;
|
|
4915
|
-
},
|
|
4916
|
-
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
|
4917
|
-
getTextMode({ tag, ns }) {
|
|
4918
|
-
if (ns === 0) {
|
|
4919
|
-
if (tag === "textarea" || tag === "title") {
|
|
4920
|
-
return 1;
|
|
4921
|
-
}
|
|
4922
|
-
if (isRawTextContainer(tag)) {
|
|
4923
|
-
return 2;
|
|
4924
|
-
}
|
|
4925
|
-
}
|
|
4926
|
-
return 0;
|
|
4927
5615
|
}
|
|
4928
5616
|
};
|
|
4929
5617
|
|
|
@@ -5038,8 +5726,8 @@ const transformModel = (dir, node, context) => {
|
|
|
5038
5726
|
);
|
|
5039
5727
|
}
|
|
5040
5728
|
function checkDuplicatedValue() {
|
|
5041
|
-
const value =
|
|
5042
|
-
if (value) {
|
|
5729
|
+
const value = findDir(node, "bind");
|
|
5730
|
+
if (value && isStaticArgOf(value.arg, "value")) {
|
|
5043
5731
|
context.onError(
|
|
5044
5732
|
createDOMCompilerError(
|
|
5045
5733
|
60,
|
|
@@ -5244,6 +5932,7 @@ const transformTransition = (node, context) => {
|
|
|
5244
5932
|
node.props.push({
|
|
5245
5933
|
type: 6,
|
|
5246
5934
|
name: "persisted",
|
|
5935
|
+
nameLoc: node.loc,
|
|
5247
5936
|
value: void 0,
|
|
5248
5937
|
loc: node.loc
|
|
5249
5938
|
});
|
|
@@ -5288,9 +5977,9 @@ const DOMDirectiveTransforms = {
|
|
|
5288
5977
|
// override compiler-core
|
|
5289
5978
|
show: transformShow
|
|
5290
5979
|
};
|
|
5291
|
-
function compile(
|
|
5980
|
+
function compile(src, options = {}) {
|
|
5292
5981
|
return baseCompile(
|
|
5293
|
-
|
|
5982
|
+
src,
|
|
5294
5983
|
extend({}, parserOptions, options, {
|
|
5295
5984
|
nodeTransforms: [
|
|
5296
5985
|
// ignore <script> and <tag>
|
|
@@ -5313,4 +6002,4 @@ function parse(template, options = {}) {
|
|
|
5313
6002
|
return baseParse(template, extend({}, parserOptions, options));
|
|
5314
6003
|
}
|
|
5315
6004
|
|
|
5316
|
-
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, generate, generateCodeFrame, getBaseTransformPreset, getConstantType,
|
|
6005
|
+
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 };
|