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