@vue/compiler-dom 3.4.0-alpha.1 → 3.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +11 -2364
- package/dist/compiler-dom.cjs.prod.js +8 -2362
- package/dist/compiler-dom.d.ts +2 -2
- package/dist/compiler-dom.esm-browser.js +1817 -1130
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +12 -26
- package/dist/compiler-dom.global.js +1817 -1131
- 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
|
});
|
|
@@ -57,7 +49,7 @@ var VueCompilerDOM = (function (exports) {
|
|
|
57
49
|
[4]: `STYLE`,
|
|
58
50
|
[8]: `PROPS`,
|
|
59
51
|
[16]: `FULL_PROPS`,
|
|
60
|
-
[32]: `
|
|
52
|
+
[32]: `NEED_HYDRATION`,
|
|
61
53
|
[64]: `STABLE_FRAGMENT`,
|
|
62
54
|
[128]: `KEYED_FRAGMENT`,
|
|
63
55
|
[256]: `UNKEYED_FRAGMENT`,
|
|
@@ -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
|
}
|
|
@@ -789,471 +1646,560 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
789
1646
|
return node;
|
|
790
1647
|
}
|
|
791
1648
|
}
|
|
1649
|
+
const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
|
|
792
1650
|
|
|
793
|
-
const deprecationData = {
|
|
794
|
-
["COMPILER_IS_ON_ELEMENT"]: {
|
|
795
|
-
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:".`,
|
|
796
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
|
|
797
|
-
},
|
|
798
|
-
["COMPILER_V_BIND_SYNC"]: {
|
|
799
|
-
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}\`.`,
|
|
800
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
|
|
801
|
-
},
|
|
802
|
-
["COMPILER_V_BIND_PROP"]: {
|
|
803
|
-
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.`
|
|
804
|
-
},
|
|
805
|
-
["COMPILER_V_BIND_OBJECT_ORDER"]: {
|
|
806
|
-
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.`,
|
|
807
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
|
|
808
|
-
},
|
|
809
|
-
["COMPILER_V_ON_NATIVE"]: {
|
|
810
|
-
message: `.native modifier for v-on has been removed as is no longer necessary.`,
|
|
811
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
|
|
812
|
-
},
|
|
813
|
-
["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
|
|
814
|
-
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.`,
|
|
815
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
|
|
816
|
-
},
|
|
817
|
-
["COMPILER_NATIVE_TEMPLATE"]: {
|
|
818
|
-
message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
|
|
819
|
-
},
|
|
820
|
-
["COMPILER_INLINE_TEMPLATE"]: {
|
|
821
|
-
message: `"inline-template" has been removed in Vue 3.`,
|
|
822
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
|
|
823
|
-
},
|
|
824
|
-
["COMPILER_FILTER"]: {
|
|
825
|
-
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.`,
|
|
826
|
-
link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
|
|
827
|
-
}
|
|
828
|
-
};
|
|
829
|
-
function getCompatValue(key, context) {
|
|
830
|
-
const config = context.options ? context.options.compatConfig : context.compatConfig;
|
|
831
|
-
const value = config && config[key];
|
|
832
|
-
if (key === "MODE") {
|
|
833
|
-
return value || 3;
|
|
834
|
-
} else {
|
|
835
|
-
return value;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
function isCompatEnabled(key, context) {
|
|
839
|
-
const mode = getCompatValue("MODE", context);
|
|
840
|
-
const value = getCompatValue(key, context);
|
|
841
|
-
return mode === 3 ? value === true : value !== false;
|
|
842
|
-
}
|
|
843
|
-
function checkCompatEnabled(key, context, loc, ...args) {
|
|
844
|
-
const enabled = isCompatEnabled(key, context);
|
|
845
|
-
if (enabled) {
|
|
846
|
-
warnDeprecation(key, context, loc, ...args);
|
|
847
|
-
}
|
|
848
|
-
return enabled;
|
|
849
|
-
}
|
|
850
|
-
function warnDeprecation(key, context, loc, ...args) {
|
|
851
|
-
const val = getCompatValue(key, context);
|
|
852
|
-
if (val === "suppress-warning") {
|
|
853
|
-
return;
|
|
854
|
-
}
|
|
855
|
-
const { message, link } = deprecationData[key];
|
|
856
|
-
const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
|
|
857
|
-
Details: ${link}` : ``}`;
|
|
858
|
-
const err = new SyntaxError(msg);
|
|
859
|
-
err.code = key;
|
|
860
|
-
if (loc)
|
|
861
|
-
err.loc = loc;
|
|
862
|
-
context.onWarn(err);
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
const decodeRE = /&(gt|lt|amp|apos|quot);/g;
|
|
866
|
-
const decodeMap = {
|
|
867
|
-
gt: ">",
|
|
868
|
-
lt: "<",
|
|
869
|
-
amp: "&",
|
|
870
|
-
apos: "'",
|
|
871
|
-
quot: '"'
|
|
872
|
-
};
|
|
873
1651
|
const defaultParserOptions = {
|
|
1652
|
+
parseMode: "base",
|
|
1653
|
+
ns: 0,
|
|
874
1654
|
delimiters: [`{{`, `}}`],
|
|
875
1655
|
getNamespace: () => 0,
|
|
876
|
-
getTextMode: () => 0,
|
|
877
1656
|
isVoidTag: NO,
|
|
878
1657
|
isPreTag: NO,
|
|
879
1658
|
isCustomElement: NO,
|
|
880
|
-
decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
|
|
881
1659
|
onError: defaultOnError,
|
|
882
1660
|
onWarn: defaultOnWarn,
|
|
883
1661
|
comments: true
|
|
884
1662
|
};
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
let
|
|
918
|
-
if (
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
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);
|
|
939
1740
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
} else if (s[2] === ">") {
|
|
944
|
-
emitError(context, 14, 2);
|
|
945
|
-
advanceBy(context, 3);
|
|
946
|
-
continue;
|
|
947
|
-
} else if (/[a-z]/i.test(s[2])) {
|
|
948
|
-
emitError(context, 23);
|
|
949
|
-
parseTag(context, 1 /* End */, parent);
|
|
950
|
-
continue;
|
|
951
|
-
} else {
|
|
952
|
-
emitError(
|
|
953
|
-
context,
|
|
954
|
-
12,
|
|
955
|
-
2
|
|
956
|
-
);
|
|
957
|
-
node = parseBogusComment(context);
|
|
1741
|
+
for (let j = 0; j <= i; j++) {
|
|
1742
|
+
const el = stack.shift();
|
|
1743
|
+
onCloseTag(el, end, j < i);
|
|
958
1744
|
}
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
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]);
|
|
973
1802
|
}
|
|
974
|
-
} else if (s[1] === "?") {
|
|
975
|
-
emitError(
|
|
976
|
-
context,
|
|
977
|
-
21,
|
|
978
|
-
1
|
|
979
|
-
);
|
|
980
|
-
node = parseBogusComment(context);
|
|
981
|
-
} else {
|
|
982
|
-
emitError(context, 12, 1);
|
|
983
1803
|
}
|
|
984
1804
|
}
|
|
985
1805
|
}
|
|
986
|
-
|
|
987
|
-
|
|
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
|
+
);
|
|
988
1820
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
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);
|
|
992
1832
|
}
|
|
993
1833
|
} else {
|
|
994
|
-
|
|
1834
|
+
currentProp.modifiers.push(mod);
|
|
995
1835
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
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);
|
|
1015
1885
|
}
|
|
1016
1886
|
} else {
|
|
1017
|
-
|
|
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
|
+
}
|
|
1018
1905
|
}
|
|
1019
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
1020
|
-
removedWhitespace = true;
|
|
1021
|
-
nodes[i] = null;
|
|
1022
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
|
+
});
|
|
1023
1921
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
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;
|
|
1028
1961
|
}
|
|
1029
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
|
+
}
|
|
1030
1982
|
}
|
|
1031
|
-
|
|
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;
|
|
1032
2033
|
}
|
|
1033
|
-
function
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
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;
|
|
1041
2049
|
}
|
|
1042
2050
|
}
|
|
1043
|
-
|
|
2051
|
+
currentOpenTag = null;
|
|
1044
2052
|
}
|
|
1045
|
-
function
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
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);
|
|
1050
2066
|
} else {
|
|
1051
|
-
|
|
2067
|
+
parent.children.push({
|
|
2068
|
+
type: 2,
|
|
2069
|
+
content,
|
|
2070
|
+
loc: getLoc(start, end)
|
|
2071
|
+
});
|
|
1052
2072
|
}
|
|
1053
|
-
return nodes;
|
|
1054
2073
|
}
|
|
1055
|
-
function
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const match = /--(\!)?>/.exec(context.source);
|
|
1059
|
-
if (!match) {
|
|
1060
|
-
content = context.source.slice(4);
|
|
1061
|
-
advanceBy(context, context.source.length);
|
|
1062
|
-
emitError(context, 7);
|
|
2074
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
2075
|
+
if (isImplied) {
|
|
2076
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
1063
2077
|
} else {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
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);
|
|
1069
2085
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
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;
|
|
1079
2099
|
}
|
|
1080
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1081
2100
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
content = context.source.slice(contentStart);
|
|
1095
|
-
advanceBy(context, context.source.length);
|
|
1096
|
-
} else {
|
|
1097
|
-
content = context.source.slice(contentStart, closeIndex);
|
|
1098
|
-
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;
|
|
1099
2113
|
}
|
|
1100
|
-
return {
|
|
1101
|
-
type: 3,
|
|
1102
|
-
content,
|
|
1103
|
-
loc: getSelection(context, start)
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
function parseElement(context, ancestors) {
|
|
1107
|
-
const wasInPre = context.inPre;
|
|
1108
|
-
const wasInVPre = context.inVPre;
|
|
1109
|
-
const parent = last(ancestors);
|
|
1110
|
-
const element = parseTag(context, 0 /* Start */, parent);
|
|
1111
|
-
const isPreBoundary = context.inPre && !wasInPre;
|
|
1112
|
-
const isVPreBoundary = context.inVPre && !wasInVPre;
|
|
1113
|
-
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
|
|
1114
|
-
if (isPreBoundary) {
|
|
1115
|
-
context.inPre = false;
|
|
1116
|
-
}
|
|
1117
|
-
if (isVPreBoundary) {
|
|
1118
|
-
context.inVPre = false;
|
|
1119
|
-
}
|
|
1120
|
-
return element;
|
|
1121
|
-
}
|
|
1122
|
-
ancestors.push(element);
|
|
1123
|
-
const mode = context.options.getTextMode(element, parent);
|
|
1124
|
-
const children = parseChildren(context, mode, ancestors);
|
|
1125
|
-
ancestors.pop();
|
|
1126
2114
|
{
|
|
1127
|
-
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(
|
|
1128
2155
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
1129
2156
|
);
|
|
1130
2157
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1131
2158
|
"COMPILER_INLINE_TEMPLATE",
|
|
1132
|
-
|
|
2159
|
+
currentOptions,
|
|
1133
2160
|
inlineTemplateProp.loc
|
|
1134
|
-
)) {
|
|
1135
|
-
const loc = getSelection(context, element.loc.end);
|
|
2161
|
+
) && el.children.length) {
|
|
1136
2162
|
inlineTemplateProp.value = {
|
|
1137
2163
|
type: 2,
|
|
1138
|
-
content:
|
|
1139
|
-
|
|
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
|
|
1140
2169
|
};
|
|
1141
2170
|
}
|
|
1142
2171
|
}
|
|
1143
|
-
element.children = children;
|
|
1144
|
-
if (startsWithEndTagOpen(context.source, element.tag)) {
|
|
1145
|
-
parseTag(context, 1 /* End */, parent);
|
|
1146
|
-
} else {
|
|
1147
|
-
emitError(context, 24, 0, element.loc.start);
|
|
1148
|
-
if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
|
|
1149
|
-
const first = children[0];
|
|
1150
|
-
if (first && startsWith(first.loc.source, "<!--")) {
|
|
1151
|
-
emitError(context, 8);
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
element.loc = getSelection(context, element.loc.start);
|
|
1156
|
-
if (isPreBoundary) {
|
|
1157
|
-
context.inPre = false;
|
|
1158
|
-
}
|
|
1159
|
-
if (isVPreBoundary) {
|
|
1160
|
-
context.inVPre = false;
|
|
1161
|
-
}
|
|
1162
|
-
return element;
|
|
1163
2172
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const start = getCursor(context);
|
|
1169
|
-
const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
|
|
1170
|
-
const tag = match[1];
|
|
1171
|
-
const ns = context.options.getNamespace(tag, parent);
|
|
1172
|
-
advanceBy(context, match[0].length);
|
|
1173
|
-
advanceSpaces(context);
|
|
1174
|
-
const cursor = getCursor(context);
|
|
1175
|
-
const currentSource = context.source;
|
|
1176
|
-
if (context.options.isPreTag(tag)) {
|
|
1177
|
-
context.inPre = true;
|
|
1178
|
-
}
|
|
1179
|
-
let props = parseAttributes(context, type);
|
|
1180
|
-
if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
|
|
1181
|
-
context.inVPre = true;
|
|
1182
|
-
extend(context, cursor);
|
|
1183
|
-
context.source = currentSource;
|
|
1184
|
-
props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
|
|
1185
|
-
}
|
|
1186
|
-
let isSelfClosing = false;
|
|
1187
|
-
if (context.source.length === 0) {
|
|
1188
|
-
emitError(context, 9);
|
|
1189
|
-
} else {
|
|
1190
|
-
isSelfClosing = startsWith(context.source, "/>");
|
|
1191
|
-
if (type === 1 /* End */ && isSelfClosing) {
|
|
1192
|
-
emitError(context, 4);
|
|
1193
|
-
}
|
|
1194
|
-
advanceBy(context, isSelfClosing ? 2 : 1);
|
|
1195
|
-
}
|
|
1196
|
-
if (type === 1 /* End */) {
|
|
1197
|
-
return;
|
|
2173
|
+
function fastForward(start, c) {
|
|
2174
|
+
let offset = 0;
|
|
2175
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2176
|
+
offset++;
|
|
1198
2177
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
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") {
|
|
1205
2189
|
for (let i = 0; i < props.length; i++) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
if (p.name === "if") {
|
|
1209
|
-
hasIf = true;
|
|
1210
|
-
} else if (p.name === "for") {
|
|
1211
|
-
hasFor = true;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
if (hasIf && hasFor) {
|
|
1215
|
-
warnDeprecation(
|
|
1216
|
-
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1217
|
-
context,
|
|
1218
|
-
getSelection(context, start)
|
|
1219
|
-
);
|
|
1220
|
-
break;
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
let tagType = 0;
|
|
1225
|
-
if (!context.inVPre) {
|
|
1226
|
-
if (tag === "slot") {
|
|
1227
|
-
tagType = 2;
|
|
1228
|
-
} else if (tag === "template") {
|
|
1229
|
-
if (props.some(
|
|
1230
|
-
(p) => p.type === 7 && isSpecialTemplateDirective(p.name)
|
|
1231
|
-
)) {
|
|
1232
|
-
tagType = 3;
|
|
2190
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2191
|
+
return true;
|
|
1233
2192
|
}
|
|
1234
|
-
} else if (isComponent(tag, props, context)) {
|
|
1235
|
-
tagType = 1;
|
|
1236
2193
|
}
|
|
1237
2194
|
}
|
|
1238
|
-
return
|
|
1239
|
-
type: 1,
|
|
1240
|
-
ns,
|
|
1241
|
-
tag,
|
|
1242
|
-
tagType,
|
|
1243
|
-
props,
|
|
1244
|
-
isSelfClosing,
|
|
1245
|
-
children: [],
|
|
1246
|
-
loc: getSelection(context, start),
|
|
1247
|
-
codegenNode: void 0
|
|
1248
|
-
// to be created during transform phase
|
|
1249
|
-
};
|
|
2195
|
+
return false;
|
|
1250
2196
|
}
|
|
1251
|
-
function isComponent(tag, props
|
|
1252
|
-
|
|
1253
|
-
if (
|
|
2197
|
+
function isComponent({ tag, props }) {
|
|
2198
|
+
var _a;
|
|
2199
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1254
2200
|
return false;
|
|
1255
2201
|
}
|
|
1256
|
-
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)) {
|
|
1257
2203
|
return true;
|
|
1258
2204
|
}
|
|
1259
2205
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1264,374 +2210,179 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1264
2210
|
return true;
|
|
1265
2211
|
} else if (checkCompatEnabled(
|
|
1266
2212
|
"COMPILER_IS_ON_ELEMENT",
|
|
1267
|
-
|
|
2213
|
+
currentOptions,
|
|
1268
2214
|
p.loc
|
|
1269
2215
|
)) {
|
|
1270
2216
|
return true;
|
|
1271
2217
|
}
|
|
1272
2218
|
}
|
|
1273
|
-
} else
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
context,
|
|
1281
|
-
p.loc
|
|
1282
|
-
)
|
|
1283
|
-
) {
|
|
1284
|
-
return true;
|
|
1285
|
-
}
|
|
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;
|
|
1286
2226
|
}
|
|
1287
2227
|
}
|
|
2228
|
+
return false;
|
|
1288
2229
|
}
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
const attributeNames = /* @__PURE__ */ new Set();
|
|
1292
|
-
while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
|
|
1293
|
-
if (startsWith(context.source, "/")) {
|
|
1294
|
-
emitError(context, 22);
|
|
1295
|
-
advanceBy(context, 1);
|
|
1296
|
-
advanceSpaces(context);
|
|
1297
|
-
continue;
|
|
1298
|
-
}
|
|
1299
|
-
if (type === 1 /* End */) {
|
|
1300
|
-
emitError(context, 3);
|
|
1301
|
-
}
|
|
1302
|
-
const attr = parseAttribute(context, attributeNames);
|
|
1303
|
-
if (attr.type === 6 && attr.value && attr.name === "class") {
|
|
1304
|
-
attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
|
|
1305
|
-
}
|
|
1306
|
-
if (type === 0 /* Start */) {
|
|
1307
|
-
props.push(attr);
|
|
1308
|
-
}
|
|
1309
|
-
if (/^[^\t\r\n\f />]/.test(context.source)) {
|
|
1310
|
-
emitError(context, 15);
|
|
1311
|
-
}
|
|
1312
|
-
advanceSpaces(context);
|
|
1313
|
-
}
|
|
1314
|
-
return props;
|
|
2230
|
+
function isUpperCase(c) {
|
|
2231
|
+
return c > 64 && c < 91;
|
|
1315
2232
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
);
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
advanceBy(context, name.length);
|
|
1340
|
-
let value = void 0;
|
|
1341
|
-
if (/^[\t\r\n\f ]*=/.test(context.source)) {
|
|
1342
|
-
advanceSpaces(context);
|
|
1343
|
-
advanceBy(context, 1);
|
|
1344
|
-
advanceSpaces(context);
|
|
1345
|
-
value = parseAttributeValue(context);
|
|
1346
|
-
if (!value) {
|
|
1347
|
-
emitError(context, 13);
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
const loc = getSelection(context, start);
|
|
1351
|
-
if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
|
|
1352
|
-
const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
|
|
1353
|
-
name
|
|
1354
|
-
);
|
|
1355
|
-
let isPropShorthand = startsWith(name, ".");
|
|
1356
|
-
let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
|
|
1357
|
-
let arg;
|
|
1358
|
-
if (match2[2]) {
|
|
1359
|
-
const isSlot = dirName === "slot";
|
|
1360
|
-
const startOffset = name.lastIndexOf(
|
|
1361
|
-
match2[2],
|
|
1362
|
-
name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
|
|
1363
|
-
);
|
|
1364
|
-
const loc2 = getSelection(
|
|
1365
|
-
context,
|
|
1366
|
-
getNewPosition(context, start, startOffset),
|
|
1367
|
-
getNewPosition(
|
|
1368
|
-
context,
|
|
1369
|
-
start,
|
|
1370
|
-
startOffset + match2[2].length + (isSlot && match2[3] || "").length
|
|
1371
|
-
)
|
|
1372
|
-
);
|
|
1373
|
-
let content = match2[2];
|
|
1374
|
-
let isStatic = true;
|
|
1375
|
-
if (content.startsWith("[")) {
|
|
1376
|
-
isStatic = false;
|
|
1377
|
-
if (!content.endsWith("]")) {
|
|
1378
|
-
emitError(
|
|
1379
|
-
context,
|
|
1380
|
-
27
|
|
1381
|
-
);
|
|
1382
|
-
content = content.slice(1);
|
|
1383
|
-
} else {
|
|
1384
|
-
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);
|
|
1385
2253
|
}
|
|
1386
|
-
} else
|
|
1387
|
-
content
|
|
1388
|
-
}
|
|
1389
|
-
arg = {
|
|
1390
|
-
type: 4,
|
|
1391
|
-
content,
|
|
1392
|
-
isStatic,
|
|
1393
|
-
constType: isStatic ? 3 : 0,
|
|
1394
|
-
loc: loc2
|
|
1395
|
-
};
|
|
1396
|
-
}
|
|
1397
|
-
if (value && value.isQuoted) {
|
|
1398
|
-
const valueLoc = value.loc;
|
|
1399
|
-
valueLoc.start.offset++;
|
|
1400
|
-
valueLoc.start.column++;
|
|
1401
|
-
valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
|
|
1402
|
-
valueLoc.source = valueLoc.source.slice(1, -1);
|
|
1403
|
-
}
|
|
1404
|
-
const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
|
|
1405
|
-
if (isPropShorthand)
|
|
1406
|
-
modifiers.push("prop");
|
|
1407
|
-
if (dirName === "bind" && arg) {
|
|
1408
|
-
if (modifiers.includes("sync") && checkCompatEnabled(
|
|
1409
|
-
"COMPILER_V_BIND_SYNC",
|
|
1410
|
-
context,
|
|
1411
|
-
loc,
|
|
1412
|
-
arg.loc.source
|
|
1413
|
-
)) {
|
|
1414
|
-
dirName = "model";
|
|
1415
|
-
modifiers.splice(modifiers.indexOf("sync"), 1);
|
|
1416
|
-
}
|
|
1417
|
-
if (modifiers.includes("prop")) {
|
|
1418
|
-
checkCompatEnabled(
|
|
1419
|
-
"COMPILER_V_BIND_PROP",
|
|
1420
|
-
context,
|
|
1421
|
-
loc
|
|
1422
|
-
);
|
|
2254
|
+
} else {
|
|
2255
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1423
2256
|
}
|
|
1424
2257
|
}
|
|
1425
|
-
return {
|
|
1426
|
-
type: 7,
|
|
1427
|
-
name: dirName,
|
|
1428
|
-
exp: value && {
|
|
1429
|
-
type: 4,
|
|
1430
|
-
content: value.content,
|
|
1431
|
-
isStatic: false,
|
|
1432
|
-
// Treat as non-constant by default. This can be potentially set to
|
|
1433
|
-
// other values by `transformExpression` to make it eligible for hoisting.
|
|
1434
|
-
constType: 0,
|
|
1435
|
-
loc: value.loc
|
|
1436
|
-
},
|
|
1437
|
-
arg,
|
|
1438
|
-
modifiers,
|
|
1439
|
-
loc
|
|
1440
|
-
};
|
|
1441
2258
|
}
|
|
1442
|
-
if (
|
|
1443
|
-
|
|
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
|
+
}
|
|
1444
2264
|
}
|
|
1445
|
-
return
|
|
1446
|
-
type: 6,
|
|
1447
|
-
name,
|
|
1448
|
-
value: value && {
|
|
1449
|
-
type: 2,
|
|
1450
|
-
content: value.content,
|
|
1451
|
-
loc: value.loc
|
|
1452
|
-
},
|
|
1453
|
-
loc
|
|
1454
|
-
};
|
|
2265
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1455
2266
|
}
|
|
1456
|
-
function
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
const isQuoted = quote === `"` || quote === `'`;
|
|
1461
|
-
if (isQuoted) {
|
|
1462
|
-
advanceBy(context, 1);
|
|
1463
|
-
const endIndex = context.source.indexOf(quote);
|
|
1464
|
-
if (endIndex === -1) {
|
|
1465
|
-
content = parseTextData(
|
|
1466
|
-
context,
|
|
1467
|
-
context.source.length,
|
|
1468
|
-
4
|
|
1469
|
-
);
|
|
1470
|
-
} else {
|
|
1471
|
-
content = parseTextData(context, endIndex, 4);
|
|
1472
|
-
advanceBy(context, 1);
|
|
1473
|
-
}
|
|
1474
|
-
} else {
|
|
1475
|
-
const match = /^[^\t\r\n\f >]+/.exec(context.source);
|
|
1476
|
-
if (!match) {
|
|
1477
|
-
return void 0;
|
|
1478
|
-
}
|
|
1479
|
-
const unexpectedChars = /["'<=`]/g;
|
|
1480
|
-
let m;
|
|
1481
|
-
while (m = unexpectedChars.exec(match[0])) {
|
|
1482
|
-
emitError(
|
|
1483
|
-
context,
|
|
1484
|
-
18,
|
|
1485
|
-
m.index
|
|
1486
|
-
);
|
|
2267
|
+
function isAllWhitespace(str) {
|
|
2268
|
+
for (let i = 0; i < str.length; i++) {
|
|
2269
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2270
|
+
return false;
|
|
1487
2271
|
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
return { content, isQuoted, loc: getSelection(context, start) };
|
|
1491
|
-
}
|
|
1492
|
-
function parseInterpolation(context, mode) {
|
|
1493
|
-
const [open, close] = context.options.delimiters;
|
|
1494
|
-
const closeIndex = context.source.indexOf(close, open.length);
|
|
1495
|
-
if (closeIndex === -1) {
|
|
1496
|
-
emitError(context, 25);
|
|
1497
|
-
return void 0;
|
|
1498
|
-
}
|
|
1499
|
-
const start = getCursor(context);
|
|
1500
|
-
advanceBy(context, open.length);
|
|
1501
|
-
const innerStart = getCursor(context);
|
|
1502
|
-
const innerEnd = getCursor(context);
|
|
1503
|
-
const rawContentLength = closeIndex - open.length;
|
|
1504
|
-
const rawContent = context.source.slice(0, rawContentLength);
|
|
1505
|
-
const preTrimContent = parseTextData(context, rawContentLength, mode);
|
|
1506
|
-
const content = preTrimContent.trim();
|
|
1507
|
-
const startOffset = preTrimContent.indexOf(content);
|
|
1508
|
-
if (startOffset > 0) {
|
|
1509
|
-
advancePositionWithMutation(innerStart, rawContent, startOffset);
|
|
1510
|
-
}
|
|
1511
|
-
const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
|
|
1512
|
-
advancePositionWithMutation(innerEnd, rawContent, endOffset);
|
|
1513
|
-
advanceBy(context, close.length);
|
|
1514
|
-
return {
|
|
1515
|
-
type: 5,
|
|
1516
|
-
content: {
|
|
1517
|
-
type: 4,
|
|
1518
|
-
isStatic: false,
|
|
1519
|
-
// Set `isConstant` to false by default and will decide in transformExpression
|
|
1520
|
-
constType: 0,
|
|
1521
|
-
content,
|
|
1522
|
-
loc: getSelection(context, innerStart, innerEnd)
|
|
1523
|
-
},
|
|
1524
|
-
loc: getSelection(context, start)
|
|
1525
|
-
};
|
|
2272
|
+
}
|
|
2273
|
+
return true;
|
|
1526
2274
|
}
|
|
1527
|
-
function
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (index !== -1 && endIndex > index) {
|
|
1533
|
-
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;
|
|
1534
2280
|
}
|
|
1535
2281
|
}
|
|
1536
|
-
|
|
1537
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1538
|
-
return {
|
|
1539
|
-
type: 2,
|
|
1540
|
-
content,
|
|
1541
|
-
loc: getSelection(context, start)
|
|
1542
|
-
};
|
|
2282
|
+
return false;
|
|
1543
2283
|
}
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
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
|
+
}
|
|
1554
2297
|
}
|
|
2298
|
+
return ret;
|
|
1555
2299
|
}
|
|
1556
|
-
function
|
|
1557
|
-
|
|
1558
|
-
return { column, line, offset };
|
|
2300
|
+
function addNode(node) {
|
|
2301
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1559
2302
|
}
|
|
1560
|
-
function
|
|
1561
|
-
end = end || getCursor(context);
|
|
2303
|
+
function getLoc(start, end) {
|
|
1562
2304
|
return {
|
|
1563
|
-
start,
|
|
1564
|
-
|
|
1565
|
-
|
|
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)
|
|
1566
2310
|
};
|
|
1567
2311
|
}
|
|
1568
|
-
function
|
|
1569
|
-
|
|
2312
|
+
function setLocEnd(loc, end) {
|
|
2313
|
+
loc.end = tokenizer.getPos(end);
|
|
2314
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1570
2315
|
}
|
|
1571
|
-
function
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
loc.column += offset;
|
|
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
|
+
};
|
|
1596
2340
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
);
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
if (parent && startsWithEndTagOpen(s, parent.tag)) {
|
|
1621
|
-
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];
|
|
1622
2364
|
}
|
|
1623
|
-
break;
|
|
1624
2365
|
}
|
|
1625
|
-
case 3:
|
|
1626
|
-
if (startsWith(s, "]]>")) {
|
|
1627
|
-
return true;
|
|
1628
|
-
}
|
|
1629
|
-
break;
|
|
1630
2366
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
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;
|
|
1635
2386
|
}
|
|
1636
2387
|
|
|
1637
2388
|
function hoistStatic(root, context) {
|
|
@@ -2043,6 +2794,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2043
2794
|
root.hoists = context.hoists;
|
|
2044
2795
|
root.temps = context.temps;
|
|
2045
2796
|
root.cached = context.cached;
|
|
2797
|
+
root.transformed = true;
|
|
2046
2798
|
{
|
|
2047
2799
|
root.filters = [...context.filters];
|
|
2048
2800
|
}
|
|
@@ -2199,7 +2951,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2199
2951
|
ssr,
|
|
2200
2952
|
isTS,
|
|
2201
2953
|
inSSR,
|
|
2202
|
-
source: ast.
|
|
2954
|
+
source: ast.source,
|
|
2203
2955
|
code: ``,
|
|
2204
2956
|
column: 1,
|
|
2205
2957
|
line: 1,
|
|
@@ -2210,7 +2962,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2210
2962
|
helper(key) {
|
|
2211
2963
|
return `_${helperNameMap[key]}`;
|
|
2212
2964
|
},
|
|
2213
|
-
push(code, node) {
|
|
2965
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2214
2966
|
context.code += code;
|
|
2215
2967
|
},
|
|
2216
2968
|
indent() {
|
|
@@ -2228,7 +2980,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2228
2980
|
}
|
|
2229
2981
|
};
|
|
2230
2982
|
function newline(n) {
|
|
2231
|
-
context.push("\n" + ` `.repeat(n));
|
|
2983
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2232
2984
|
}
|
|
2233
2985
|
return context;
|
|
2234
2986
|
}
|
|
@@ -2265,9 +3017,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2265
3017
|
push(`with (_ctx) {`);
|
|
2266
3018
|
indent();
|
|
2267
3019
|
if (hasHelpers) {
|
|
2268
|
-
push(
|
|
2269
|
-
|
|
2270
|
-
|
|
3020
|
+
push(
|
|
3021
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3022
|
+
`,
|
|
3023
|
+
-1 /* End */
|
|
3024
|
+
);
|
|
2271
3025
|
newline();
|
|
2272
3026
|
}
|
|
2273
3027
|
}
|
|
@@ -2296,7 +3050,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2296
3050
|
}
|
|
2297
3051
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2298
3052
|
push(`
|
|
2299
|
-
|
|
3053
|
+
`, 0 /* Start */);
|
|
2300
3054
|
newline();
|
|
2301
3055
|
}
|
|
2302
3056
|
if (!ssr) {
|
|
@@ -2317,7 +3071,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2317
3071
|
ast,
|
|
2318
3072
|
code: context.code,
|
|
2319
3073
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2320
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2321
3074
|
map: context.map ? context.map.toJSON() : void 0
|
|
2322
3075
|
};
|
|
2323
3076
|
}
|
|
@@ -2336,7 +3089,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2336
3089
|
if (helpers.length > 0) {
|
|
2337
3090
|
{
|
|
2338
3091
|
push(`const _Vue = ${VueBinding}
|
|
2339
|
-
|
|
3092
|
+
`, -1 /* End */);
|
|
2340
3093
|
if (ast.hoists.length) {
|
|
2341
3094
|
const staticHelpers = [
|
|
2342
3095
|
CREATE_VNODE,
|
|
@@ -2346,7 +3099,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2346
3099
|
CREATE_STATIC
|
|
2347
3100
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2348
3101
|
push(`const { ${staticHelpers} } = _Vue
|
|
2349
|
-
|
|
3102
|
+
`, -1 /* End */);
|
|
2350
3103
|
}
|
|
2351
3104
|
}
|
|
2352
3105
|
}
|
|
@@ -2407,7 +3160,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2407
3160
|
for (let i = 0; i < nodes.length; i++) {
|
|
2408
3161
|
const node = nodes[i];
|
|
2409
3162
|
if (isString(node)) {
|
|
2410
|
-
push(node);
|
|
3163
|
+
push(node, -3 /* Unknown */);
|
|
2411
3164
|
} else if (isArray(node)) {
|
|
2412
3165
|
genNodeListAsArray(node, context);
|
|
2413
3166
|
} else {
|
|
@@ -2425,7 +3178,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2425
3178
|
}
|
|
2426
3179
|
function genNode(node, context) {
|
|
2427
3180
|
if (isString(node)) {
|
|
2428
|
-
context.push(node);
|
|
3181
|
+
context.push(node, -3 /* Unknown */);
|
|
2429
3182
|
return;
|
|
2430
3183
|
}
|
|
2431
3184
|
if (isSymbol(node)) {
|
|
@@ -2505,11 +3258,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2505
3258
|
}
|
|
2506
3259
|
}
|
|
2507
3260
|
function genText(node, context) {
|
|
2508
|
-
context.push(JSON.stringify(node.content), node);
|
|
3261
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2509
3262
|
}
|
|
2510
3263
|
function genExpression(node, context) {
|
|
2511
3264
|
const { content, isStatic } = node;
|
|
2512
|
-
context.push(
|
|
3265
|
+
context.push(
|
|
3266
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3267
|
+
-3 /* Unknown */,
|
|
3268
|
+
node
|
|
3269
|
+
);
|
|
2513
3270
|
}
|
|
2514
3271
|
function genInterpolation(node, context) {
|
|
2515
3272
|
const { push, helper, pure } = context;
|
|
@@ -2523,7 +3280,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2523
3280
|
for (let i = 0; i < node.children.length; i++) {
|
|
2524
3281
|
const child = node.children[i];
|
|
2525
3282
|
if (isString(child)) {
|
|
2526
|
-
context.push(child);
|
|
3283
|
+
context.push(child, -3 /* Unknown */);
|
|
2527
3284
|
} else {
|
|
2528
3285
|
genNode(child, context);
|
|
2529
3286
|
}
|
|
@@ -2537,9 +3294,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2537
3294
|
push(`]`);
|
|
2538
3295
|
} else if (node.isStatic) {
|
|
2539
3296
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2540
|
-
push(text, node);
|
|
3297
|
+
push(text, -2 /* None */, node);
|
|
2541
3298
|
} else {
|
|
2542
|
-
push(`[${node.content}]`, node);
|
|
3299
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2543
3300
|
}
|
|
2544
3301
|
}
|
|
2545
3302
|
function genComment(node, context) {
|
|
@@ -2547,7 +3304,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2547
3304
|
if (pure) {
|
|
2548
3305
|
push(PURE_ANNOTATION);
|
|
2549
3306
|
}
|
|
2550
|
-
push(
|
|
3307
|
+
push(
|
|
3308
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3309
|
+
-3 /* Unknown */,
|
|
3310
|
+
node
|
|
3311
|
+
);
|
|
2551
3312
|
}
|
|
2552
3313
|
function genVNodeCall(node, context) {
|
|
2553
3314
|
const { push, helper, pure } = context;
|
|
@@ -2572,7 +3333,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2572
3333
|
push(PURE_ANNOTATION);
|
|
2573
3334
|
}
|
|
2574
3335
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2575
|
-
push(helper(callHelper) + `(`, node);
|
|
3336
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2576
3337
|
genNodeList(
|
|
2577
3338
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2578
3339
|
context
|
|
@@ -2601,7 +3362,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2601
3362
|
if (pure) {
|
|
2602
3363
|
push(PURE_ANNOTATION);
|
|
2603
3364
|
}
|
|
2604
|
-
push(callee + `(`, node);
|
|
3365
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2605
3366
|
genNodeList(node.arguments, context);
|
|
2606
3367
|
push(`)`);
|
|
2607
3368
|
}
|
|
@@ -2609,7 +3370,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2609
3370
|
const { push, indent, deindent, newline } = context;
|
|
2610
3371
|
const { properties } = node;
|
|
2611
3372
|
if (!properties.length) {
|
|
2612
|
-
push(`{}`, node);
|
|
3373
|
+
push(`{}`, -2 /* None */, node);
|
|
2613
3374
|
return;
|
|
2614
3375
|
}
|
|
2615
3376
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -2637,7 +3398,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2637
3398
|
if (isSlot) {
|
|
2638
3399
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2639
3400
|
}
|
|
2640
|
-
push(`(`, node);
|
|
3401
|
+
push(`(`, -2 /* None */, node);
|
|
2641
3402
|
if (isArray(params)) {
|
|
2642
3403
|
genNodeList(params, context);
|
|
2643
3404
|
} else if (params) {
|
|
@@ -2772,6 +3533,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2772
3533
|
if (stmt.declare || !stmt.id)
|
|
2773
3534
|
continue;
|
|
2774
3535
|
onIdent(stmt.id);
|
|
3536
|
+
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
3537
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
3538
|
+
if (variable && variable.type === "VariableDeclaration") {
|
|
3539
|
+
for (const decl of variable.declarations) {
|
|
3540
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
3541
|
+
onIdent(id);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
2775
3545
|
}
|
|
2776
3546
|
}
|
|
2777
3547
|
}
|
|
@@ -2982,7 +3752,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2982
3752
|
context.removeNode();
|
|
2983
3753
|
const branch = createIfBranch(node, dir);
|
|
2984
3754
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2985
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3755
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2986
3756
|
branch.children = [...comments, ...branch.children];
|
|
2987
3757
|
}
|
|
2988
3758
|
{
|
|
@@ -3264,18 +4034,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3264
4034
|
);
|
|
3265
4035
|
return;
|
|
3266
4036
|
}
|
|
3267
|
-
const parseResult =
|
|
3268
|
-
// can only be simple expression because vFor transform is applied
|
|
3269
|
-
// before expression transform.
|
|
3270
|
-
dir.exp,
|
|
3271
|
-
context
|
|
3272
|
-
);
|
|
4037
|
+
const parseResult = dir.forParseResult;
|
|
3273
4038
|
if (!parseResult) {
|
|
3274
4039
|
context.onError(
|
|
3275
4040
|
createCompilerError(32, dir.loc)
|
|
3276
4041
|
);
|
|
3277
4042
|
return;
|
|
3278
4043
|
}
|
|
4044
|
+
finalizeForParseResult(parseResult, context);
|
|
3279
4045
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3280
4046
|
const { source, value, key, index } = parseResult;
|
|
3281
4047
|
const forNode = {
|
|
@@ -3297,71 +4063,26 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3297
4063
|
onExit();
|
|
3298
4064
|
};
|
|
3299
4065
|
}
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
const stripParensRE = /^\(|\)$/g;
|
|
3303
|
-
function parseForExpression(input, context) {
|
|
3304
|
-
const loc = input.loc;
|
|
3305
|
-
const exp = input.content;
|
|
3306
|
-
const inMatch = exp.match(forAliasRE);
|
|
3307
|
-
if (!inMatch)
|
|
4066
|
+
function finalizeForParseResult(result, context) {
|
|
4067
|
+
if (result.finalized)
|
|
3308
4068
|
return;
|
|
3309
|
-
const [, LHS, RHS] = inMatch;
|
|
3310
|
-
const result = {
|
|
3311
|
-
source: createAliasExpression(
|
|
3312
|
-
loc,
|
|
3313
|
-
RHS.trim(),
|
|
3314
|
-
exp.indexOf(RHS, LHS.length)
|
|
3315
|
-
),
|
|
3316
|
-
value: void 0,
|
|
3317
|
-
key: void 0,
|
|
3318
|
-
index: void 0
|
|
3319
|
-
};
|
|
3320
4069
|
{
|
|
3321
4070
|
validateBrowserExpression(result.source, context);
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
const keyContent = iteratorMatch[1].trim();
|
|
3329
|
-
let keyOffset;
|
|
3330
|
-
if (keyContent) {
|
|
3331
|
-
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
3332
|
-
result.key = createAliasExpression(loc, keyContent, keyOffset);
|
|
3333
|
-
{
|
|
3334
|
-
validateBrowserExpression(
|
|
3335
|
-
result.key,
|
|
3336
|
-
context,
|
|
3337
|
-
true
|
|
3338
|
-
);
|
|
3339
|
-
}
|
|
4071
|
+
if (result.key) {
|
|
4072
|
+
validateBrowserExpression(
|
|
4073
|
+
result.key,
|
|
4074
|
+
context,
|
|
4075
|
+
true
|
|
4076
|
+
);
|
|
3340
4077
|
}
|
|
3341
|
-
if (
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
exp.indexOf(
|
|
3348
|
-
indexContent,
|
|
3349
|
-
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
3350
|
-
)
|
|
3351
|
-
);
|
|
3352
|
-
{
|
|
3353
|
-
validateBrowserExpression(
|
|
3354
|
-
result.index,
|
|
3355
|
-
context,
|
|
3356
|
-
true
|
|
3357
|
-
);
|
|
3358
|
-
}
|
|
3359
|
-
}
|
|
4078
|
+
if (result.index) {
|
|
4079
|
+
validateBrowserExpression(
|
|
4080
|
+
result.index,
|
|
4081
|
+
context,
|
|
4082
|
+
true
|
|
4083
|
+
);
|
|
3360
4084
|
}
|
|
3361
|
-
|
|
3362
|
-
if (valueContent) {
|
|
3363
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3364
|
-
{
|
|
4085
|
+
if (result.value) {
|
|
3365
4086
|
validateBrowserExpression(
|
|
3366
4087
|
result.value,
|
|
3367
4088
|
context,
|
|
@@ -3369,14 +4090,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3369
4090
|
);
|
|
3370
4091
|
}
|
|
3371
4092
|
}
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3374
|
-
function createAliasExpression(range, content, offset) {
|
|
3375
|
-
return createSimpleExpression(
|
|
3376
|
-
content,
|
|
3377
|
-
false,
|
|
3378
|
-
getInnerRange(range, offset, content.length)
|
|
3379
|
-
);
|
|
4093
|
+
result.finalized = true;
|
|
3380
4094
|
}
|
|
3381
4095
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3382
4096
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3406,11 +4120,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3406
4120
|
const trackVForSlotScopes = (node, context) => {
|
|
3407
4121
|
let vFor;
|
|
3408
4122
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3409
|
-
const result = vFor.
|
|
3410
|
-
vFor.exp,
|
|
3411
|
-
context
|
|
3412
|
-
);
|
|
4123
|
+
const result = vFor.forParseResult;
|
|
3413
4124
|
if (result) {
|
|
4125
|
+
finalizeForParseResult(result, context);
|
|
3414
4126
|
const { value, key, index } = result;
|
|
3415
4127
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3416
4128
|
value && addIdentifiers(value);
|
|
@@ -3484,12 +4196,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3484
4196
|
hasDynamicSlots = true;
|
|
3485
4197
|
}
|
|
3486
4198
|
const vFor = findDir(slotElement, "for");
|
|
3487
|
-
const slotFunction = buildSlotFn(
|
|
3488
|
-
slotProps,
|
|
3489
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3490
|
-
slotChildren,
|
|
3491
|
-
slotLoc
|
|
3492
|
-
);
|
|
4199
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3493
4200
|
let vIf;
|
|
3494
4201
|
let vElse;
|
|
3495
4202
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3538,8 +4245,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3538
4245
|
}
|
|
3539
4246
|
} else if (vFor) {
|
|
3540
4247
|
hasDynamicSlots = true;
|
|
3541
|
-
const parseResult = vFor.
|
|
4248
|
+
const parseResult = vFor.forParseResult;
|
|
3542
4249
|
if (parseResult) {
|
|
4250
|
+
finalizeForParseResult(parseResult, context);
|
|
3543
4251
|
dynamicSlots.push(
|
|
3544
4252
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3545
4253
|
parseResult.source,
|
|
@@ -3800,17 +4508,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3800
4508
|
tag = isProp.value.content.slice(4);
|
|
3801
4509
|
}
|
|
3802
4510
|
}
|
|
3803
|
-
const isDir = !isExplicitDynamic && findDir(node, "is");
|
|
3804
|
-
if (isDir && isDir.exp) {
|
|
3805
|
-
{
|
|
3806
|
-
context.onWarn(
|
|
3807
|
-
createCompilerError(52, isDir.loc)
|
|
3808
|
-
);
|
|
3809
|
-
}
|
|
3810
|
-
return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
|
|
3811
|
-
isDir.exp
|
|
3812
|
-
]);
|
|
3813
|
-
}
|
|
3814
4511
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3815
4512
|
if (builtIn) {
|
|
3816
4513
|
if (!ssr)
|
|
@@ -3882,7 +4579,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3882
4579
|
for (let i = 0; i < props.length; i++) {
|
|
3883
4580
|
const prop = props[i];
|
|
3884
4581
|
if (prop.type === 6) {
|
|
3885
|
-
const { loc, name, value } = prop;
|
|
4582
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3886
4583
|
let isStatic = true;
|
|
3887
4584
|
if (name === "ref") {
|
|
3888
4585
|
hasRef = true;
|
|
@@ -3903,11 +4600,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3903
4600
|
}
|
|
3904
4601
|
properties.push(
|
|
3905
4602
|
createObjectProperty(
|
|
3906
|
-
createSimpleExpression(
|
|
3907
|
-
name,
|
|
3908
|
-
true,
|
|
3909
|
-
getInnerRange(loc, 0, name.length)
|
|
3910
|
-
),
|
|
4603
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3911
4604
|
createSimpleExpression(
|
|
3912
4605
|
value ? value.content : "",
|
|
3913
4606
|
isStatic,
|
|
@@ -3916,7 +4609,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3916
4609
|
)
|
|
3917
4610
|
);
|
|
3918
4611
|
} else {
|
|
3919
|
-
const { name, arg, exp, loc } = prop;
|
|
4612
|
+
const { name, arg, exp, loc, modifiers } = prop;
|
|
3920
4613
|
const isVBind = name === "bind";
|
|
3921
4614
|
const isVOn = name === "on";
|
|
3922
4615
|
if (name === "slot") {
|
|
@@ -4009,6 +4702,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4009
4702
|
}
|
|
4010
4703
|
continue;
|
|
4011
4704
|
}
|
|
4705
|
+
if (isVBind && modifiers.includes("prop")) {
|
|
4706
|
+
patchFlag |= 32;
|
|
4707
|
+
}
|
|
4012
4708
|
const directiveTransform = context.directiveTransforms[name];
|
|
4013
4709
|
if (directiveTransform) {
|
|
4014
4710
|
const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
|
@@ -4386,8 +5082,13 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4386
5082
|
};
|
|
4387
5083
|
|
|
4388
5084
|
const transformBind = (dir, _node, context) => {
|
|
4389
|
-
const {
|
|
5085
|
+
const { modifiers, loc } = dir;
|
|
4390
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
|
+
}
|
|
4391
5092
|
if (arg.type !== 4) {
|
|
4392
5093
|
arg.children.unshift(`(`);
|
|
4393
5094
|
arg.children.push(`) || ""`);
|
|
@@ -4786,7 +5487,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4786
5487
|
}
|
|
4787
5488
|
];
|
|
4788
5489
|
}
|
|
4789
|
-
function baseCompile(
|
|
5490
|
+
function baseCompile(source, options = {}) {
|
|
4790
5491
|
const onError = options.onError || defaultOnError;
|
|
4791
5492
|
const isModuleMode = options.mode === "module";
|
|
4792
5493
|
{
|
|
@@ -4803,7 +5504,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4803
5504
|
if (options.scopeId && !isModuleMode) {
|
|
4804
5505
|
onError(createCompilerError(50));
|
|
4805
5506
|
}
|
|
4806
|
-
const ast = isString(
|
|
5507
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4807
5508
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4808
5509
|
transform(
|
|
4809
5510
|
ast,
|
|
@@ -4869,25 +5570,22 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4869
5570
|
}
|
|
4870
5571
|
}
|
|
4871
5572
|
|
|
4872
|
-
const isRawTextContainer = /* @__PURE__ */ makeMap(
|
|
4873
|
-
"style,iframe,script,noscript",
|
|
4874
|
-
true
|
|
4875
|
-
);
|
|
4876
5573
|
const parserOptions = {
|
|
5574
|
+
parseMode: "html",
|
|
4877
5575
|
isVoidTag,
|
|
4878
5576
|
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
4879
5577
|
isPreTag: (tag) => tag === "pre",
|
|
4880
5578
|
decodeEntities: decodeHtmlBrowser ,
|
|
4881
5579
|
isBuiltInComponent: (tag) => {
|
|
4882
|
-
if (
|
|
5580
|
+
if (tag === "Transition" || tag === "transition") {
|
|
4883
5581
|
return TRANSITION;
|
|
4884
|
-
} else if (
|
|
5582
|
+
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
|
4885
5583
|
return TRANSITION_GROUP;
|
|
4886
5584
|
}
|
|
4887
5585
|
},
|
|
4888
5586
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
4889
|
-
getNamespace(tag, parent) {
|
|
4890
|
-
let ns = parent ? parent.ns :
|
|
5587
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
5588
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
4891
5589
|
if (parent && ns === 2) {
|
|
4892
5590
|
if (parent.tag === "annotation-xml") {
|
|
4893
5591
|
if (tag === "svg") {
|
|
@@ -4915,18 +5613,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4915
5613
|
}
|
|
4916
5614
|
}
|
|
4917
5615
|
return ns;
|
|
4918
|
-
},
|
|
4919
|
-
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
|
4920
|
-
getTextMode({ tag, ns }) {
|
|
4921
|
-
if (ns === 0) {
|
|
4922
|
-
if (tag === "textarea" || tag === "title") {
|
|
4923
|
-
return 1;
|
|
4924
|
-
}
|
|
4925
|
-
if (isRawTextContainer(tag)) {
|
|
4926
|
-
return 2;
|
|
4927
|
-
}
|
|
4928
|
-
}
|
|
4929
|
-
return 0;
|
|
4930
5616
|
}
|
|
4931
5617
|
};
|
|
4932
5618
|
|
|
@@ -5041,8 +5727,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5041
5727
|
);
|
|
5042
5728
|
}
|
|
5043
5729
|
function checkDuplicatedValue() {
|
|
5044
|
-
const value =
|
|
5045
|
-
if (value) {
|
|
5730
|
+
const value = findDir(node, "bind");
|
|
5731
|
+
if (value && isStaticArgOf(value.arg, "value")) {
|
|
5046
5732
|
context.onError(
|
|
5047
5733
|
createDOMCompilerError(
|
|
5048
5734
|
60,
|
|
@@ -5247,6 +5933,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5247
5933
|
node.props.push({
|
|
5248
5934
|
type: 6,
|
|
5249
5935
|
name: "persisted",
|
|
5936
|
+
nameLoc: node.loc,
|
|
5250
5937
|
value: void 0,
|
|
5251
5938
|
loc: node.loc
|
|
5252
5939
|
});
|
|
@@ -5291,9 +5978,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5291
5978
|
// override compiler-core
|
|
5292
5979
|
show: transformShow
|
|
5293
5980
|
};
|
|
5294
|
-
function compile(
|
|
5981
|
+
function compile(src, options = {}) {
|
|
5295
5982
|
return baseCompile(
|
|
5296
|
-
|
|
5983
|
+
src,
|
|
5297
5984
|
extend({}, parserOptions, options, {
|
|
5298
5985
|
nodeTransforms: [
|
|
5299
5986
|
// ignore <script> and <tag>
|
|
@@ -5407,11 +6094,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5407
6094
|
exports.extractIdentifiers = extractIdentifiers;
|
|
5408
6095
|
exports.findDir = findDir;
|
|
5409
6096
|
exports.findProp = findProp;
|
|
6097
|
+
exports.forAliasRE = forAliasRE;
|
|
5410
6098
|
exports.generate = generate;
|
|
5411
6099
|
exports.generateCodeFrame = generateCodeFrame;
|
|
5412
6100
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
5413
6101
|
exports.getConstantType = getConstantType;
|
|
5414
|
-
exports.getInnerRange = getInnerRange;
|
|
5415
6102
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
5416
6103
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
5417
6104
|
exports.getVNodeHelper = getVNodeHelper;
|
|
@@ -5419,7 +6106,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5419
6106
|
exports.hasScopeRef = hasScopeRef;
|
|
5420
6107
|
exports.helperNameMap = helperNameMap;
|
|
5421
6108
|
exports.injectProp = injectProp;
|
|
5422
|
-
exports.isBuiltInType = isBuiltInType;
|
|
5423
6109
|
exports.isCoreComponent = isCoreComponent;
|
|
5424
6110
|
exports.isFunctionType = isFunctionType;
|
|
5425
6111
|
exports.isInDestructureAssignment = isInDestructureAssignment;
|