@vue/compiler-dom 3.4.0-alpha.1 → 3.4.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler-dom.cjs.js +11 -2364
- package/dist/compiler-dom.cjs.prod.js +8 -2362
- package/dist/compiler-dom.d.ts +2 -2
- package/dist/compiler-dom.esm-browser.js +1819 -1130
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +12 -26
- package/dist/compiler-dom.global.js +1819 -1131
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
|
@@ -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,562 @@ 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
|
+
if (start === end)
|
|
1809
|
+
return;
|
|
1810
|
+
const arg = getSlice(start, end);
|
|
1811
|
+
if (inVPre) {
|
|
1812
|
+
currentProp.name += arg;
|
|
1813
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1814
|
+
} else {
|
|
1815
|
+
const isStatic = arg[0] !== `[`;
|
|
1816
|
+
currentProp.arg = createSimpleExpression(
|
|
1817
|
+
isStatic ? arg : arg.slice(1, -1),
|
|
1818
|
+
isStatic,
|
|
1819
|
+
getLoc(start, end),
|
|
1820
|
+
isStatic ? 3 : 0
|
|
1821
|
+
);
|
|
988
1822
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1823
|
+
},
|
|
1824
|
+
ondirmodifier(start, end) {
|
|
1825
|
+
const mod = getSlice(start, end);
|
|
1826
|
+
if (inVPre) {
|
|
1827
|
+
currentProp.name += "." + mod;
|
|
1828
|
+
setLocEnd(currentProp.nameLoc, end);
|
|
1829
|
+
} else if (currentProp.name === "slot") {
|
|
1830
|
+
const arg = currentProp.arg;
|
|
1831
|
+
if (arg) {
|
|
1832
|
+
arg.content += "." + mod;
|
|
1833
|
+
setLocEnd(arg.loc, end);
|
|
992
1834
|
}
|
|
993
1835
|
} else {
|
|
994
|
-
|
|
1836
|
+
currentProp.modifiers.push(mod);
|
|
995
1837
|
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1838
|
+
},
|
|
1839
|
+
onattribdata(start, end) {
|
|
1840
|
+
currentAttrValue += getSlice(start, end);
|
|
1841
|
+
if (currentAttrStartIndex < 0)
|
|
1842
|
+
currentAttrStartIndex = start;
|
|
1843
|
+
currentAttrEndIndex = end;
|
|
1844
|
+
},
|
|
1845
|
+
onattribentity(char, start, end) {
|
|
1846
|
+
currentAttrValue += char;
|
|
1847
|
+
if (currentAttrStartIndex < 0)
|
|
1848
|
+
currentAttrStartIndex = start;
|
|
1849
|
+
currentAttrEndIndex = end;
|
|
1850
|
+
},
|
|
1851
|
+
onattribnameend(end) {
|
|
1852
|
+
const start = currentProp.loc.start.offset;
|
|
1853
|
+
const name = getSlice(start, end);
|
|
1854
|
+
if (currentProp.type === 7) {
|
|
1855
|
+
currentProp.rawName = name;
|
|
1856
|
+
}
|
|
1857
|
+
if (currentOpenTag.props.some(
|
|
1858
|
+
(p) => (p.type === 7 ? p.rawName : p.name) === name
|
|
1859
|
+
)) {
|
|
1860
|
+
emitError(2, start);
|
|
1861
|
+
}
|
|
1862
|
+
},
|
|
1863
|
+
onattribend(quote, end) {
|
|
1864
|
+
if (currentOpenTag && currentProp) {
|
|
1865
|
+
setLocEnd(currentProp.loc, end);
|
|
1866
|
+
if (quote !== 0) {
|
|
1867
|
+
if (currentAttrValue.includes("&")) {
|
|
1868
|
+
currentAttrValue = currentOptions.decodeEntities(
|
|
1869
|
+
currentAttrValue,
|
|
1870
|
+
true
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
if (currentProp.type === 6) {
|
|
1874
|
+
if (currentProp.name === "class") {
|
|
1875
|
+
currentAttrValue = condense(currentAttrValue).trim();
|
|
1876
|
+
}
|
|
1877
|
+
if (quote === 1 && !currentAttrValue) {
|
|
1878
|
+
emitError(13, end);
|
|
1879
|
+
}
|
|
1880
|
+
currentProp.value = {
|
|
1881
|
+
type: 2,
|
|
1882
|
+
content: currentAttrValue,
|
|
1883
|
+
loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
|
|
1884
|
+
};
|
|
1885
|
+
if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
|
|
1886
|
+
tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
1015
1887
|
}
|
|
1016
1888
|
} else {
|
|
1017
|
-
|
|
1889
|
+
currentProp.exp = createSimpleExpression(
|
|
1890
|
+
currentAttrValue,
|
|
1891
|
+
false,
|
|
1892
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
1893
|
+
);
|
|
1894
|
+
if (currentProp.name === "for") {
|
|
1895
|
+
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
1896
|
+
}
|
|
1897
|
+
let syncIndex = -1;
|
|
1898
|
+
if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
|
|
1899
|
+
"COMPILER_V_BIND_SYNC",
|
|
1900
|
+
currentOptions,
|
|
1901
|
+
currentProp.loc,
|
|
1902
|
+
currentProp.rawName
|
|
1903
|
+
)) {
|
|
1904
|
+
currentProp.name = "model";
|
|
1905
|
+
currentProp.modifiers.splice(syncIndex, 1);
|
|
1906
|
+
}
|
|
1018
1907
|
}
|
|
1019
|
-
} else if (node.type === 3 && !context.options.comments) {
|
|
1020
|
-
removedWhitespace = true;
|
|
1021
|
-
nodes[i] = null;
|
|
1022
1908
|
}
|
|
1909
|
+
if (currentProp.type !== 7 || currentProp.name !== "pre") {
|
|
1910
|
+
currentOpenTag.props.push(currentProp);
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
currentAttrValue = "";
|
|
1914
|
+
currentAttrStartIndex = currentAttrEndIndex = -1;
|
|
1915
|
+
},
|
|
1916
|
+
oncomment(start, end) {
|
|
1917
|
+
if (currentOptions.comments) {
|
|
1918
|
+
addNode({
|
|
1919
|
+
type: 3,
|
|
1920
|
+
content: getSlice(start, end),
|
|
1921
|
+
loc: getLoc(start - 4, end + 3)
|
|
1922
|
+
});
|
|
1023
1923
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1924
|
+
},
|
|
1925
|
+
onend() {
|
|
1926
|
+
const end = currentInput.length;
|
|
1927
|
+
if (tokenizer.state !== 1) {
|
|
1928
|
+
switch (tokenizer.state) {
|
|
1929
|
+
case 5:
|
|
1930
|
+
case 8:
|
|
1931
|
+
emitError(5, end);
|
|
1932
|
+
break;
|
|
1933
|
+
case 3:
|
|
1934
|
+
case 4:
|
|
1935
|
+
emitError(
|
|
1936
|
+
25,
|
|
1937
|
+
tokenizer.sectionStart
|
|
1938
|
+
);
|
|
1939
|
+
break;
|
|
1940
|
+
case 28:
|
|
1941
|
+
if (tokenizer.currentSequence === Sequences.CdataEnd) {
|
|
1942
|
+
emitError(6, end);
|
|
1943
|
+
} else {
|
|
1944
|
+
emitError(7, end);
|
|
1945
|
+
}
|
|
1946
|
+
break;
|
|
1947
|
+
case 6:
|
|
1948
|
+
case 7:
|
|
1949
|
+
case 9:
|
|
1950
|
+
case 11:
|
|
1951
|
+
case 12:
|
|
1952
|
+
case 13:
|
|
1953
|
+
case 14:
|
|
1954
|
+
case 15:
|
|
1955
|
+
case 16:
|
|
1956
|
+
case 17:
|
|
1957
|
+
case 18:
|
|
1958
|
+
case 19:
|
|
1959
|
+
case 20:
|
|
1960
|
+
case 21:
|
|
1961
|
+
emitError(9, end);
|
|
1962
|
+
break;
|
|
1028
1963
|
}
|
|
1029
1964
|
}
|
|
1965
|
+
for (let index = 0; index < stack.length; index++) {
|
|
1966
|
+
onCloseTag(stack[index], end - 1);
|
|
1967
|
+
emitError(24, stack[index].loc.start.offset);
|
|
1968
|
+
}
|
|
1969
|
+
},
|
|
1970
|
+
oncdata(start, end) {
|
|
1971
|
+
if (stack[0].ns !== 0) {
|
|
1972
|
+
onText(getSlice(start, end), start, end);
|
|
1973
|
+
} else {
|
|
1974
|
+
emitError(1, start - 9);
|
|
1975
|
+
}
|
|
1976
|
+
},
|
|
1977
|
+
onprocessinginstruction(start) {
|
|
1978
|
+
if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
1979
|
+
emitError(
|
|
1980
|
+
21,
|
|
1981
|
+
start - 1
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1030
1984
|
}
|
|
1031
|
-
|
|
1985
|
+
});
|
|
1986
|
+
const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
|
1987
|
+
const stripParensRE = /^\(|\)$/g;
|
|
1988
|
+
function parseForExpression(input) {
|
|
1989
|
+
const loc = input.loc;
|
|
1990
|
+
const exp = input.content;
|
|
1991
|
+
const inMatch = exp.match(forAliasRE);
|
|
1992
|
+
if (!inMatch)
|
|
1993
|
+
return;
|
|
1994
|
+
const [, LHS, RHS] = inMatch;
|
|
1995
|
+
const createAliasExpression = (content, offset) => {
|
|
1996
|
+
const start = loc.start.offset + offset;
|
|
1997
|
+
const end = start + content.length;
|
|
1998
|
+
return createSimpleExpression(content, false, getLoc(start, end));
|
|
1999
|
+
};
|
|
2000
|
+
const result = {
|
|
2001
|
+
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
2002
|
+
value: void 0,
|
|
2003
|
+
key: void 0,
|
|
2004
|
+
index: void 0,
|
|
2005
|
+
finalized: false
|
|
2006
|
+
};
|
|
2007
|
+
let valueContent = LHS.trim().replace(stripParensRE, "").trim();
|
|
2008
|
+
const trimmedOffset = LHS.indexOf(valueContent);
|
|
2009
|
+
const iteratorMatch = valueContent.match(forIteratorRE);
|
|
2010
|
+
if (iteratorMatch) {
|
|
2011
|
+
valueContent = valueContent.replace(forIteratorRE, "").trim();
|
|
2012
|
+
const keyContent = iteratorMatch[1].trim();
|
|
2013
|
+
let keyOffset;
|
|
2014
|
+
if (keyContent) {
|
|
2015
|
+
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
2016
|
+
result.key = createAliasExpression(keyContent, keyOffset);
|
|
2017
|
+
}
|
|
2018
|
+
if (iteratorMatch[2]) {
|
|
2019
|
+
const indexContent = iteratorMatch[2].trim();
|
|
2020
|
+
if (indexContent) {
|
|
2021
|
+
result.index = createAliasExpression(
|
|
2022
|
+
indexContent,
|
|
2023
|
+
exp.indexOf(
|
|
2024
|
+
indexContent,
|
|
2025
|
+
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
2026
|
+
)
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
if (valueContent) {
|
|
2032
|
+
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
2033
|
+
}
|
|
2034
|
+
return result;
|
|
1032
2035
|
}
|
|
1033
|
-
function
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
2036
|
+
function getSlice(start, end) {
|
|
2037
|
+
return currentInput.slice(start, end);
|
|
2038
|
+
}
|
|
2039
|
+
function endOpenTag(end) {
|
|
2040
|
+
addNode(currentOpenTag);
|
|
2041
|
+
const { tag, ns } = currentOpenTag;
|
|
2042
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2043
|
+
inPre++;
|
|
2044
|
+
}
|
|
2045
|
+
if (currentOptions.isVoidTag(tag)) {
|
|
2046
|
+
onCloseTag(currentOpenTag, end);
|
|
2047
|
+
} else {
|
|
2048
|
+
stack.unshift(currentOpenTag);
|
|
2049
|
+
if (ns === 1 || ns === 2) {
|
|
2050
|
+
tokenizer.inXML = true;
|
|
1041
2051
|
}
|
|
1042
2052
|
}
|
|
1043
|
-
|
|
2053
|
+
currentOpenTag = null;
|
|
1044
2054
|
}
|
|
1045
|
-
function
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
2055
|
+
function onText(content, start, end) {
|
|
2056
|
+
var _a;
|
|
2057
|
+
{
|
|
2058
|
+
const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
|
|
2059
|
+
if (tag !== "script" && tag !== "style" && content.includes("&")) {
|
|
2060
|
+
content = currentOptions.decodeEntities(content, false);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
const parent = stack[0] || currentRoot;
|
|
2064
|
+
const lastNode = parent.children[parent.children.length - 1];
|
|
2065
|
+
if ((lastNode == null ? void 0 : lastNode.type) === 2) {
|
|
2066
|
+
lastNode.content += content;
|
|
2067
|
+
setLocEnd(lastNode.loc, end);
|
|
1050
2068
|
} else {
|
|
1051
|
-
|
|
2069
|
+
parent.children.push({
|
|
2070
|
+
type: 2,
|
|
2071
|
+
content,
|
|
2072
|
+
loc: getLoc(start, end)
|
|
2073
|
+
});
|
|
1052
2074
|
}
|
|
1053
|
-
return nodes;
|
|
1054
2075
|
}
|
|
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);
|
|
2076
|
+
function onCloseTag(el, end, isImplied = false) {
|
|
2077
|
+
if (isImplied) {
|
|
2078
|
+
setLocEnd(el.loc, backTrack(end, 60));
|
|
1063
2079
|
} else {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
2080
|
+
setLocEnd(el.loc, end + fastForward(end) + 1);
|
|
2081
|
+
}
|
|
2082
|
+
if (tokenizer.inSFCRoot) {
|
|
2083
|
+
if (el.children.length) {
|
|
2084
|
+
el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
|
|
2085
|
+
} else {
|
|
2086
|
+
el.innerLoc.end = extend({}, el.innerLoc.start);
|
|
1069
2087
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
2088
|
+
el.innerLoc.source = getSlice(
|
|
2089
|
+
el.innerLoc.start.offset,
|
|
2090
|
+
el.innerLoc.end.offset
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
const { tag, ns } = el;
|
|
2094
|
+
if (!inVPre) {
|
|
2095
|
+
if (tag === "slot") {
|
|
2096
|
+
el.tagType = 2;
|
|
2097
|
+
} else if (isFragmentTemplate(el)) {
|
|
2098
|
+
el.tagType = 3;
|
|
2099
|
+
} else if (isComponent(el)) {
|
|
2100
|
+
el.tagType = 1;
|
|
1079
2101
|
}
|
|
1080
|
-
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1081
2102
|
}
|
|
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);
|
|
2103
|
+
if (!tokenizer.inRCDATA) {
|
|
2104
|
+
el.children = condenseWhitespace(el.children, el.tag);
|
|
2105
|
+
}
|
|
2106
|
+
if (ns === 0 && currentOptions.isPreTag(tag)) {
|
|
2107
|
+
inPre--;
|
|
2108
|
+
}
|
|
2109
|
+
if (currentVPreBoundary === el) {
|
|
2110
|
+
inVPre = false;
|
|
2111
|
+
currentVPreBoundary = null;
|
|
2112
|
+
}
|
|
2113
|
+
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
2114
|
+
tokenizer.inXML = false;
|
|
1099
2115
|
}
|
|
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
2116
|
{
|
|
1127
|
-
const
|
|
2117
|
+
const props = el.props;
|
|
2118
|
+
if (isCompatEnabled(
|
|
2119
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2120
|
+
currentOptions
|
|
2121
|
+
)) {
|
|
2122
|
+
let hasIf = false;
|
|
2123
|
+
let hasFor = false;
|
|
2124
|
+
for (let i = 0; i < props.length; i++) {
|
|
2125
|
+
const p = props[i];
|
|
2126
|
+
if (p.type === 7) {
|
|
2127
|
+
if (p.name === "if") {
|
|
2128
|
+
hasIf = true;
|
|
2129
|
+
} else if (p.name === "for") {
|
|
2130
|
+
hasFor = true;
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
if (hasIf && hasFor) {
|
|
2134
|
+
warnDeprecation(
|
|
2135
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
2136
|
+
currentOptions,
|
|
2137
|
+
el.loc
|
|
2138
|
+
);
|
|
2139
|
+
break;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
if (isCompatEnabled(
|
|
2144
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2145
|
+
currentOptions
|
|
2146
|
+
) && el.tag === "template" && !isFragmentTemplate(el)) {
|
|
2147
|
+
warnDeprecation(
|
|
2148
|
+
"COMPILER_NATIVE_TEMPLATE",
|
|
2149
|
+
currentOptions,
|
|
2150
|
+
el.loc
|
|
2151
|
+
);
|
|
2152
|
+
const parent = stack[0] || currentRoot;
|
|
2153
|
+
const index = parent.children.indexOf(el);
|
|
2154
|
+
parent.children.splice(index, 1, ...el.children);
|
|
2155
|
+
}
|
|
2156
|
+
const inlineTemplateProp = props.find(
|
|
1128
2157
|
(p) => p.type === 6 && p.name === "inline-template"
|
|
1129
2158
|
);
|
|
1130
2159
|
if (inlineTemplateProp && checkCompatEnabled(
|
|
1131
2160
|
"COMPILER_INLINE_TEMPLATE",
|
|
1132
|
-
|
|
2161
|
+
currentOptions,
|
|
1133
2162
|
inlineTemplateProp.loc
|
|
1134
|
-
)) {
|
|
1135
|
-
const loc = getSelection(context, element.loc.end);
|
|
2163
|
+
) && el.children.length) {
|
|
1136
2164
|
inlineTemplateProp.value = {
|
|
1137
2165
|
type: 2,
|
|
1138
|
-
content:
|
|
1139
|
-
|
|
2166
|
+
content: getSlice(
|
|
2167
|
+
el.children[0].loc.start.offset,
|
|
2168
|
+
el.children[el.children.length - 1].loc.end.offset
|
|
2169
|
+
),
|
|
2170
|
+
loc: inlineTemplateProp.loc
|
|
1140
2171
|
};
|
|
1141
2172
|
}
|
|
1142
2173
|
}
|
|
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
2174
|
}
|
|
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;
|
|
2175
|
+
function fastForward(start, c) {
|
|
2176
|
+
let offset = 0;
|
|
2177
|
+
while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
|
|
2178
|
+
offset++;
|
|
1198
2179
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
2180
|
+
return offset;
|
|
2181
|
+
}
|
|
2182
|
+
function backTrack(index, c) {
|
|
2183
|
+
let i = index;
|
|
2184
|
+
while (currentInput.charCodeAt(i) !== c && i >= 0)
|
|
2185
|
+
i--;
|
|
2186
|
+
return i;
|
|
2187
|
+
}
|
|
2188
|
+
const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
|
|
2189
|
+
function isFragmentTemplate({ tag, props }) {
|
|
2190
|
+
if (tag === "template") {
|
|
1205
2191
|
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;
|
|
2192
|
+
if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
|
|
2193
|
+
return true;
|
|
1233
2194
|
}
|
|
1234
|
-
} else if (isComponent(tag, props, context)) {
|
|
1235
|
-
tagType = 1;
|
|
1236
2195
|
}
|
|
1237
2196
|
}
|
|
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
|
-
};
|
|
2197
|
+
return false;
|
|
1250
2198
|
}
|
|
1251
|
-
function isComponent(tag, props
|
|
1252
|
-
|
|
1253
|
-
if (
|
|
2199
|
+
function isComponent({ tag, props }) {
|
|
2200
|
+
var _a;
|
|
2201
|
+
if (currentOptions.isCustomElement(tag)) {
|
|
1254
2202
|
return false;
|
|
1255
2203
|
}
|
|
1256
|
-
if (tag === "component" ||
|
|
2204
|
+
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
2205
|
return true;
|
|
1258
2206
|
}
|
|
1259
2207
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1264,374 +2212,179 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
1264
2212
|
return true;
|
|
1265
2213
|
} else if (checkCompatEnabled(
|
|
1266
2214
|
"COMPILER_IS_ON_ELEMENT",
|
|
1267
|
-
|
|
2215
|
+
currentOptions,
|
|
1268
2216
|
p.loc
|
|
1269
2217
|
)) {
|
|
1270
2218
|
return true;
|
|
1271
2219
|
}
|
|
1272
2220
|
}
|
|
1273
|
-
} else
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
context,
|
|
1281
|
-
p.loc
|
|
1282
|
-
)
|
|
1283
|
-
) {
|
|
1284
|
-
return true;
|
|
1285
|
-
}
|
|
2221
|
+
} else if (// :is on plain element - only treat as component in compat mode
|
|
2222
|
+
p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
|
|
2223
|
+
"COMPILER_IS_ON_ELEMENT",
|
|
2224
|
+
currentOptions,
|
|
2225
|
+
p.loc
|
|
2226
|
+
)) {
|
|
2227
|
+
return true;
|
|
1286
2228
|
}
|
|
1287
2229
|
}
|
|
2230
|
+
return false;
|
|
1288
2231
|
}
|
|
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;
|
|
2232
|
+
function isUpperCase(c) {
|
|
2233
|
+
return c > 64 && c < 91;
|
|
1315
2234
|
}
|
|
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);
|
|
2235
|
+
const windowsNewlineRE = /\r\n/g;
|
|
2236
|
+
function condenseWhitespace(nodes, tag) {
|
|
2237
|
+
var _a, _b;
|
|
2238
|
+
const shouldCondense = currentOptions.whitespace !== "preserve";
|
|
2239
|
+
let removedWhitespace = false;
|
|
2240
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
2241
|
+
const node = nodes[i];
|
|
2242
|
+
if (node.type === 2) {
|
|
2243
|
+
if (!inPre) {
|
|
2244
|
+
if (isAllWhitespace(node.content)) {
|
|
2245
|
+
const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
|
|
2246
|
+
const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
|
|
2247
|
+
if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
|
|
2248
|
+
removedWhitespace = true;
|
|
2249
|
+
nodes[i] = null;
|
|
2250
|
+
} else {
|
|
2251
|
+
node.content = " ";
|
|
2252
|
+
}
|
|
2253
|
+
} else if (shouldCondense) {
|
|
2254
|
+
node.content = condense(node.content);
|
|
1385
2255
|
}
|
|
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
|
-
);
|
|
2256
|
+
} else {
|
|
2257
|
+
node.content = node.content.replace(windowsNewlineRE, "\n");
|
|
1423
2258
|
}
|
|
1424
2259
|
}
|
|
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
2260
|
}
|
|
1442
|
-
if (
|
|
1443
|
-
|
|
2261
|
+
if (inPre && tag && currentOptions.isPreTag(tag)) {
|
|
2262
|
+
const first = nodes[0];
|
|
2263
|
+
if (first && first.type === 2) {
|
|
2264
|
+
first.content = first.content.replace(/^\r?\n/, "");
|
|
2265
|
+
}
|
|
1444
2266
|
}
|
|
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
|
-
};
|
|
2267
|
+
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1455
2268
|
}
|
|
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
|
-
);
|
|
2269
|
+
function isAllWhitespace(str) {
|
|
2270
|
+
for (let i = 0; i < str.length; i++) {
|
|
2271
|
+
if (!isWhitespace(str.charCodeAt(i))) {
|
|
2272
|
+
return false;
|
|
1487
2273
|
}
|
|
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
|
-
};
|
|
2274
|
+
}
|
|
2275
|
+
return true;
|
|
1526
2276
|
}
|
|
1527
|
-
function
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
if (index !== -1 && endIndex > index) {
|
|
1533
|
-
endIndex = index;
|
|
2277
|
+
function hasNewlineChar(str) {
|
|
2278
|
+
for (let i = 0; i < str.length; i++) {
|
|
2279
|
+
const c = str.charCodeAt(i);
|
|
2280
|
+
if (c === 10 || c === 13) {
|
|
2281
|
+
return true;
|
|
1534
2282
|
}
|
|
1535
2283
|
}
|
|
1536
|
-
|
|
1537
|
-
const content = parseTextData(context, endIndex, mode);
|
|
1538
|
-
return {
|
|
1539
|
-
type: 2,
|
|
1540
|
-
content,
|
|
1541
|
-
loc: getSelection(context, start)
|
|
1542
|
-
};
|
|
2284
|
+
return false;
|
|
1543
2285
|
}
|
|
1544
|
-
function
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
2286
|
+
function condense(str) {
|
|
2287
|
+
let ret = "";
|
|
2288
|
+
let prevCharIsWhitespace = false;
|
|
2289
|
+
for (let i = 0; i < str.length; i++) {
|
|
2290
|
+
if (isWhitespace(str.charCodeAt(i))) {
|
|
2291
|
+
if (!prevCharIsWhitespace) {
|
|
2292
|
+
ret += " ";
|
|
2293
|
+
prevCharIsWhitespace = true;
|
|
2294
|
+
}
|
|
2295
|
+
} else {
|
|
2296
|
+
ret += str[i];
|
|
2297
|
+
prevCharIsWhitespace = false;
|
|
2298
|
+
}
|
|
1554
2299
|
}
|
|
2300
|
+
return ret;
|
|
1555
2301
|
}
|
|
1556
|
-
function
|
|
1557
|
-
|
|
1558
|
-
return { column, line, offset };
|
|
2302
|
+
function addNode(node) {
|
|
2303
|
+
(stack[0] || currentRoot).children.push(node);
|
|
1559
2304
|
}
|
|
1560
|
-
function
|
|
1561
|
-
end = end || getCursor(context);
|
|
2305
|
+
function getLoc(start, end) {
|
|
1562
2306
|
return {
|
|
1563
|
-
start,
|
|
1564
|
-
|
|
1565
|
-
|
|
2307
|
+
start: tokenizer.getPos(start),
|
|
2308
|
+
// @ts-expect-error allow late attachment
|
|
2309
|
+
end: end == null ? end : tokenizer.getPos(end),
|
|
2310
|
+
// @ts-expect-error allow late attachment
|
|
2311
|
+
source: end == null ? end : getSlice(start, end)
|
|
1566
2312
|
};
|
|
1567
2313
|
}
|
|
1568
|
-
function
|
|
1569
|
-
|
|
2314
|
+
function setLocEnd(loc, end) {
|
|
2315
|
+
loc.end = tokenizer.getPos(end);
|
|
2316
|
+
loc.source = getSlice(loc.start.offset, end);
|
|
1570
2317
|
}
|
|
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;
|
|
2318
|
+
function dirToAttr(dir) {
|
|
2319
|
+
const attr = {
|
|
2320
|
+
type: 6,
|
|
2321
|
+
name: dir.rawName,
|
|
2322
|
+
nameLoc: getLoc(
|
|
2323
|
+
dir.loc.start.offset,
|
|
2324
|
+
dir.loc.start.offset + dir.rawName.length
|
|
2325
|
+
),
|
|
2326
|
+
value: void 0,
|
|
2327
|
+
loc: dir.loc
|
|
2328
|
+
};
|
|
2329
|
+
if (dir.exp) {
|
|
2330
|
+
const loc = dir.exp.loc;
|
|
2331
|
+
if (loc.end.offset < dir.loc.end.offset) {
|
|
2332
|
+
loc.start.offset--;
|
|
2333
|
+
loc.start.column--;
|
|
2334
|
+
loc.end.offset++;
|
|
2335
|
+
loc.end.column++;
|
|
2336
|
+
}
|
|
2337
|
+
attr.value = {
|
|
2338
|
+
type: 2,
|
|
2339
|
+
content: dir.exp.content,
|
|
2340
|
+
loc
|
|
2341
|
+
};
|
|
1596
2342
|
}
|
|
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;
|
|
2343
|
+
return attr;
|
|
2344
|
+
}
|
|
2345
|
+
function emitError(code, index) {
|
|
2346
|
+
currentOptions.onError(createCompilerError(code, getLoc(index, index)));
|
|
2347
|
+
}
|
|
2348
|
+
function reset() {
|
|
2349
|
+
tokenizer.reset();
|
|
2350
|
+
currentOpenTag = null;
|
|
2351
|
+
currentProp = null;
|
|
2352
|
+
currentAttrValue = "";
|
|
2353
|
+
currentAttrStartIndex = -1;
|
|
2354
|
+
currentAttrEndIndex = -1;
|
|
2355
|
+
stack.length = 0;
|
|
2356
|
+
}
|
|
2357
|
+
function baseParse(input, options) {
|
|
2358
|
+
reset();
|
|
2359
|
+
currentInput = input;
|
|
2360
|
+
currentOptions = extend({}, defaultParserOptions);
|
|
2361
|
+
if (options) {
|
|
2362
|
+
let key;
|
|
2363
|
+
for (key in options) {
|
|
2364
|
+
if (options[key] != null) {
|
|
2365
|
+
currentOptions[key] = options[key];
|
|
1622
2366
|
}
|
|
1623
|
-
break;
|
|
1624
2367
|
}
|
|
1625
|
-
case 3:
|
|
1626
|
-
if (startsWith(s, "]]>")) {
|
|
1627
|
-
return true;
|
|
1628
|
-
}
|
|
1629
|
-
break;
|
|
1630
2368
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
2369
|
+
{
|
|
2370
|
+
if (!currentOptions.decodeEntities) {
|
|
2371
|
+
throw new Error(
|
|
2372
|
+
`[@vue/compiler-core] decodeEntities option is required in browser builds.`
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2377
|
+
const delimiters = options == null ? void 0 : options.delimiters;
|
|
2378
|
+
if (delimiters) {
|
|
2379
|
+
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
2380
|
+
tokenizer.delimiterClose = toCharCodes(delimiters[1]);
|
|
2381
|
+
}
|
|
2382
|
+
const root = currentRoot = createRoot([], input);
|
|
2383
|
+
tokenizer.parse(currentInput);
|
|
2384
|
+
root.loc = getLoc(0, input.length);
|
|
2385
|
+
root.children = condenseWhitespace(root.children);
|
|
2386
|
+
currentRoot = null;
|
|
2387
|
+
return root;
|
|
1635
2388
|
}
|
|
1636
2389
|
|
|
1637
2390
|
function hoistStatic(root, context) {
|
|
@@ -2043,6 +2796,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2043
2796
|
root.hoists = context.hoists;
|
|
2044
2797
|
root.temps = context.temps;
|
|
2045
2798
|
root.cached = context.cached;
|
|
2799
|
+
root.transformed = true;
|
|
2046
2800
|
{
|
|
2047
2801
|
root.filters = [...context.filters];
|
|
2048
2802
|
}
|
|
@@ -2199,7 +2953,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2199
2953
|
ssr,
|
|
2200
2954
|
isTS,
|
|
2201
2955
|
inSSR,
|
|
2202
|
-
source: ast.
|
|
2956
|
+
source: ast.source,
|
|
2203
2957
|
code: ``,
|
|
2204
2958
|
column: 1,
|
|
2205
2959
|
line: 1,
|
|
@@ -2210,7 +2964,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2210
2964
|
helper(key) {
|
|
2211
2965
|
return `_${helperNameMap[key]}`;
|
|
2212
2966
|
},
|
|
2213
|
-
push(code, node) {
|
|
2967
|
+
push(code, newlineIndex = -2 /* None */, node) {
|
|
2214
2968
|
context.code += code;
|
|
2215
2969
|
},
|
|
2216
2970
|
indent() {
|
|
@@ -2228,7 +2982,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2228
2982
|
}
|
|
2229
2983
|
};
|
|
2230
2984
|
function newline(n) {
|
|
2231
|
-
context.push("\n" + ` `.repeat(n));
|
|
2985
|
+
context.push("\n" + ` `.repeat(n), 0 /* Start */);
|
|
2232
2986
|
}
|
|
2233
2987
|
return context;
|
|
2234
2988
|
}
|
|
@@ -2265,9 +3019,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2265
3019
|
push(`with (_ctx) {`);
|
|
2266
3020
|
indent();
|
|
2267
3021
|
if (hasHelpers) {
|
|
2268
|
-
push(
|
|
2269
|
-
|
|
2270
|
-
|
|
3022
|
+
push(
|
|
3023
|
+
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3024
|
+
`,
|
|
3025
|
+
-1 /* End */
|
|
3026
|
+
);
|
|
2271
3027
|
newline();
|
|
2272
3028
|
}
|
|
2273
3029
|
}
|
|
@@ -2296,7 +3052,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2296
3052
|
}
|
|
2297
3053
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
2298
3054
|
push(`
|
|
2299
|
-
|
|
3055
|
+
`, 0 /* Start */);
|
|
2300
3056
|
newline();
|
|
2301
3057
|
}
|
|
2302
3058
|
if (!ssr) {
|
|
@@ -2317,7 +3073,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2317
3073
|
ast,
|
|
2318
3074
|
code: context.code,
|
|
2319
3075
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
2320
|
-
// SourceMapGenerator does have toJSON() method but it's not in the types
|
|
2321
3076
|
map: context.map ? context.map.toJSON() : void 0
|
|
2322
3077
|
};
|
|
2323
3078
|
}
|
|
@@ -2336,7 +3091,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2336
3091
|
if (helpers.length > 0) {
|
|
2337
3092
|
{
|
|
2338
3093
|
push(`const _Vue = ${VueBinding}
|
|
2339
|
-
|
|
3094
|
+
`, -1 /* End */);
|
|
2340
3095
|
if (ast.hoists.length) {
|
|
2341
3096
|
const staticHelpers = [
|
|
2342
3097
|
CREATE_VNODE,
|
|
@@ -2346,7 +3101,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2346
3101
|
CREATE_STATIC
|
|
2347
3102
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
2348
3103
|
push(`const { ${staticHelpers} } = _Vue
|
|
2349
|
-
|
|
3104
|
+
`, -1 /* End */);
|
|
2350
3105
|
}
|
|
2351
3106
|
}
|
|
2352
3107
|
}
|
|
@@ -2407,7 +3162,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2407
3162
|
for (let i = 0; i < nodes.length; i++) {
|
|
2408
3163
|
const node = nodes[i];
|
|
2409
3164
|
if (isString(node)) {
|
|
2410
|
-
push(node);
|
|
3165
|
+
push(node, -3 /* Unknown */);
|
|
2411
3166
|
} else if (isArray(node)) {
|
|
2412
3167
|
genNodeListAsArray(node, context);
|
|
2413
3168
|
} else {
|
|
@@ -2425,7 +3180,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2425
3180
|
}
|
|
2426
3181
|
function genNode(node, context) {
|
|
2427
3182
|
if (isString(node)) {
|
|
2428
|
-
context.push(node);
|
|
3183
|
+
context.push(node, -3 /* Unknown */);
|
|
2429
3184
|
return;
|
|
2430
3185
|
}
|
|
2431
3186
|
if (isSymbol(node)) {
|
|
@@ -2505,11 +3260,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2505
3260
|
}
|
|
2506
3261
|
}
|
|
2507
3262
|
function genText(node, context) {
|
|
2508
|
-
context.push(JSON.stringify(node.content), node);
|
|
3263
|
+
context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
|
|
2509
3264
|
}
|
|
2510
3265
|
function genExpression(node, context) {
|
|
2511
3266
|
const { content, isStatic } = node;
|
|
2512
|
-
context.push(
|
|
3267
|
+
context.push(
|
|
3268
|
+
isStatic ? JSON.stringify(content) : content,
|
|
3269
|
+
-3 /* Unknown */,
|
|
3270
|
+
node
|
|
3271
|
+
);
|
|
2513
3272
|
}
|
|
2514
3273
|
function genInterpolation(node, context) {
|
|
2515
3274
|
const { push, helper, pure } = context;
|
|
@@ -2523,7 +3282,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2523
3282
|
for (let i = 0; i < node.children.length; i++) {
|
|
2524
3283
|
const child = node.children[i];
|
|
2525
3284
|
if (isString(child)) {
|
|
2526
|
-
context.push(child);
|
|
3285
|
+
context.push(child, -3 /* Unknown */);
|
|
2527
3286
|
} else {
|
|
2528
3287
|
genNode(child, context);
|
|
2529
3288
|
}
|
|
@@ -2537,9 +3296,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2537
3296
|
push(`]`);
|
|
2538
3297
|
} else if (node.isStatic) {
|
|
2539
3298
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
2540
|
-
push(text, node);
|
|
3299
|
+
push(text, -2 /* None */, node);
|
|
2541
3300
|
} else {
|
|
2542
|
-
push(`[${node.content}]`, node);
|
|
3301
|
+
push(`[${node.content}]`, -3 /* Unknown */, node);
|
|
2543
3302
|
}
|
|
2544
3303
|
}
|
|
2545
3304
|
function genComment(node, context) {
|
|
@@ -2547,7 +3306,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2547
3306
|
if (pure) {
|
|
2548
3307
|
push(PURE_ANNOTATION);
|
|
2549
3308
|
}
|
|
2550
|
-
push(
|
|
3309
|
+
push(
|
|
3310
|
+
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3311
|
+
-3 /* Unknown */,
|
|
3312
|
+
node
|
|
3313
|
+
);
|
|
2551
3314
|
}
|
|
2552
3315
|
function genVNodeCall(node, context) {
|
|
2553
3316
|
const { push, helper, pure } = context;
|
|
@@ -2572,7 +3335,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2572
3335
|
push(PURE_ANNOTATION);
|
|
2573
3336
|
}
|
|
2574
3337
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
2575
|
-
push(helper(callHelper) + `(`, node);
|
|
3338
|
+
push(helper(callHelper) + `(`, -2 /* None */, node);
|
|
2576
3339
|
genNodeList(
|
|
2577
3340
|
genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
|
|
2578
3341
|
context
|
|
@@ -2601,7 +3364,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2601
3364
|
if (pure) {
|
|
2602
3365
|
push(PURE_ANNOTATION);
|
|
2603
3366
|
}
|
|
2604
|
-
push(callee + `(`, node);
|
|
3367
|
+
push(callee + `(`, -2 /* None */, node);
|
|
2605
3368
|
genNodeList(node.arguments, context);
|
|
2606
3369
|
push(`)`);
|
|
2607
3370
|
}
|
|
@@ -2609,7 +3372,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2609
3372
|
const { push, indent, deindent, newline } = context;
|
|
2610
3373
|
const { properties } = node;
|
|
2611
3374
|
if (!properties.length) {
|
|
2612
|
-
push(`{}`, node);
|
|
3375
|
+
push(`{}`, -2 /* None */, node);
|
|
2613
3376
|
return;
|
|
2614
3377
|
}
|
|
2615
3378
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -2637,7 +3400,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2637
3400
|
if (isSlot) {
|
|
2638
3401
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
2639
3402
|
}
|
|
2640
|
-
push(`(`, node);
|
|
3403
|
+
push(`(`, -2 /* None */, node);
|
|
2641
3404
|
if (isArray(params)) {
|
|
2642
3405
|
genNodeList(params, context);
|
|
2643
3406
|
} else if (params) {
|
|
@@ -2772,6 +3535,15 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2772
3535
|
if (stmt.declare || !stmt.id)
|
|
2773
3536
|
continue;
|
|
2774
3537
|
onIdent(stmt.id);
|
|
3538
|
+
} else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
|
|
3539
|
+
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
3540
|
+
if (variable && variable.type === "VariableDeclaration") {
|
|
3541
|
+
for (const decl of variable.declarations) {
|
|
3542
|
+
for (const id of extractIdentifiers(decl.id)) {
|
|
3543
|
+
onIdent(id);
|
|
3544
|
+
}
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
2775
3547
|
}
|
|
2776
3548
|
}
|
|
2777
3549
|
}
|
|
@@ -2982,7 +3754,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
2982
3754
|
context.removeNode();
|
|
2983
3755
|
const branch = createIfBranch(node, dir);
|
|
2984
3756
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2985
|
-
!(context.parent && context.parent.type === 1 &&
|
|
3757
|
+
!(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
|
|
2986
3758
|
branch.children = [...comments, ...branch.children];
|
|
2987
3759
|
}
|
|
2988
3760
|
{
|
|
@@ -3264,18 +4036,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3264
4036
|
);
|
|
3265
4037
|
return;
|
|
3266
4038
|
}
|
|
3267
|
-
const parseResult =
|
|
3268
|
-
// can only be simple expression because vFor transform is applied
|
|
3269
|
-
// before expression transform.
|
|
3270
|
-
dir.exp,
|
|
3271
|
-
context
|
|
3272
|
-
);
|
|
4039
|
+
const parseResult = dir.forParseResult;
|
|
3273
4040
|
if (!parseResult) {
|
|
3274
4041
|
context.onError(
|
|
3275
4042
|
createCompilerError(32, dir.loc)
|
|
3276
4043
|
);
|
|
3277
4044
|
return;
|
|
3278
4045
|
}
|
|
4046
|
+
finalizeForParseResult(parseResult, context);
|
|
3279
4047
|
const { addIdentifiers, removeIdentifiers, scopes } = context;
|
|
3280
4048
|
const { source, value, key, index } = parseResult;
|
|
3281
4049
|
const forNode = {
|
|
@@ -3297,71 +4065,26 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3297
4065
|
onExit();
|
|
3298
4066
|
};
|
|
3299
4067
|
}
|
|
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)
|
|
4068
|
+
function finalizeForParseResult(result, context) {
|
|
4069
|
+
if (result.finalized)
|
|
3308
4070
|
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
4071
|
{
|
|
3321
4072
|
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
|
-
}
|
|
4073
|
+
if (result.key) {
|
|
4074
|
+
validateBrowserExpression(
|
|
4075
|
+
result.key,
|
|
4076
|
+
context,
|
|
4077
|
+
true
|
|
4078
|
+
);
|
|
3340
4079
|
}
|
|
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
|
-
}
|
|
4080
|
+
if (result.index) {
|
|
4081
|
+
validateBrowserExpression(
|
|
4082
|
+
result.index,
|
|
4083
|
+
context,
|
|
4084
|
+
true
|
|
4085
|
+
);
|
|
3360
4086
|
}
|
|
3361
|
-
|
|
3362
|
-
if (valueContent) {
|
|
3363
|
-
result.value = createAliasExpression(loc, valueContent, trimmedOffset);
|
|
3364
|
-
{
|
|
4087
|
+
if (result.value) {
|
|
3365
4088
|
validateBrowserExpression(
|
|
3366
4089
|
result.value,
|
|
3367
4090
|
context,
|
|
@@ -3369,14 +4092,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3369
4092
|
);
|
|
3370
4093
|
}
|
|
3371
4094
|
}
|
|
3372
|
-
|
|
3373
|
-
}
|
|
3374
|
-
function createAliasExpression(range, content, offset) {
|
|
3375
|
-
return createSimpleExpression(
|
|
3376
|
-
content,
|
|
3377
|
-
false,
|
|
3378
|
-
getInnerRange(range, offset, content.length)
|
|
3379
|
-
);
|
|
4095
|
+
result.finalized = true;
|
|
3380
4096
|
}
|
|
3381
4097
|
function createForLoopParams({ value, key, index }, memoArgs = []) {
|
|
3382
4098
|
return createParamsList([value, key, index, ...memoArgs]);
|
|
@@ -3406,11 +4122,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3406
4122
|
const trackVForSlotScopes = (node, context) => {
|
|
3407
4123
|
let vFor;
|
|
3408
4124
|
if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
|
|
3409
|
-
const result = vFor.
|
|
3410
|
-
vFor.exp,
|
|
3411
|
-
context
|
|
3412
|
-
);
|
|
4125
|
+
const result = vFor.forParseResult;
|
|
3413
4126
|
if (result) {
|
|
4127
|
+
finalizeForParseResult(result, context);
|
|
3414
4128
|
const { value, key, index } = result;
|
|
3415
4129
|
const { addIdentifiers, removeIdentifiers } = context;
|
|
3416
4130
|
value && addIdentifiers(value);
|
|
@@ -3484,12 +4198,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3484
4198
|
hasDynamicSlots = true;
|
|
3485
4199
|
}
|
|
3486
4200
|
const vFor = findDir(slotElement, "for");
|
|
3487
|
-
const slotFunction = buildSlotFn(
|
|
3488
|
-
slotProps,
|
|
3489
|
-
vFor == null ? void 0 : vFor.exp,
|
|
3490
|
-
slotChildren,
|
|
3491
|
-
slotLoc
|
|
3492
|
-
);
|
|
4201
|
+
const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
|
|
3493
4202
|
let vIf;
|
|
3494
4203
|
let vElse;
|
|
3495
4204
|
if (vIf = findDir(slotElement, "if")) {
|
|
@@ -3538,8 +4247,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3538
4247
|
}
|
|
3539
4248
|
} else if (vFor) {
|
|
3540
4249
|
hasDynamicSlots = true;
|
|
3541
|
-
const parseResult = vFor.
|
|
4250
|
+
const parseResult = vFor.forParseResult;
|
|
3542
4251
|
if (parseResult) {
|
|
4252
|
+
finalizeForParseResult(parseResult, context);
|
|
3543
4253
|
dynamicSlots.push(
|
|
3544
4254
|
createCallExpression(context.helper(RENDER_LIST), [
|
|
3545
4255
|
parseResult.source,
|
|
@@ -3800,17 +4510,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3800
4510
|
tag = isProp.value.content.slice(4);
|
|
3801
4511
|
}
|
|
3802
4512
|
}
|
|
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
4513
|
const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
|
|
3815
4514
|
if (builtIn) {
|
|
3816
4515
|
if (!ssr)
|
|
@@ -3882,7 +4581,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3882
4581
|
for (let i = 0; i < props.length; i++) {
|
|
3883
4582
|
const prop = props[i];
|
|
3884
4583
|
if (prop.type === 6) {
|
|
3885
|
-
const { loc, name, value } = prop;
|
|
4584
|
+
const { loc, name, nameLoc, value } = prop;
|
|
3886
4585
|
let isStatic = true;
|
|
3887
4586
|
if (name === "ref") {
|
|
3888
4587
|
hasRef = true;
|
|
@@ -3903,11 +4602,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3903
4602
|
}
|
|
3904
4603
|
properties.push(
|
|
3905
4604
|
createObjectProperty(
|
|
3906
|
-
createSimpleExpression(
|
|
3907
|
-
name,
|
|
3908
|
-
true,
|
|
3909
|
-
getInnerRange(loc, 0, name.length)
|
|
3910
|
-
),
|
|
4605
|
+
createSimpleExpression(name, true, nameLoc),
|
|
3911
4606
|
createSimpleExpression(
|
|
3912
4607
|
value ? value.content : "",
|
|
3913
4608
|
isStatic,
|
|
@@ -3916,7 +4611,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
3916
4611
|
)
|
|
3917
4612
|
);
|
|
3918
4613
|
} else {
|
|
3919
|
-
const { name, arg, exp, loc } = prop;
|
|
4614
|
+
const { name, arg, exp, loc, modifiers } = prop;
|
|
3920
4615
|
const isVBind = name === "bind";
|
|
3921
4616
|
const isVOn = name === "on";
|
|
3922
4617
|
if (name === "slot") {
|
|
@@ -4009,6 +4704,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4009
4704
|
}
|
|
4010
4705
|
continue;
|
|
4011
4706
|
}
|
|
4707
|
+
if (isVBind && modifiers.includes("prop")) {
|
|
4708
|
+
patchFlag |= 32;
|
|
4709
|
+
}
|
|
4012
4710
|
const directiveTransform = context.directiveTransforms[name];
|
|
4013
4711
|
if (directiveTransform) {
|
|
4014
4712
|
const { props: props2, needRuntime } = directiveTransform(prop, node, context);
|
|
@@ -4386,8 +5084,13 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4386
5084
|
};
|
|
4387
5085
|
|
|
4388
5086
|
const transformBind = (dir, _node, context) => {
|
|
4389
|
-
const {
|
|
5087
|
+
const { modifiers, loc } = dir;
|
|
4390
5088
|
const arg = dir.arg;
|
|
5089
|
+
let { exp } = dir;
|
|
5090
|
+
if (!exp && arg.type === 4) {
|
|
5091
|
+
const propName = camelize(arg.content);
|
|
5092
|
+
exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
|
|
5093
|
+
}
|
|
4391
5094
|
if (arg.type !== 4) {
|
|
4392
5095
|
arg.children.unshift(`(`);
|
|
4393
5096
|
arg.children.push(`) || ""`);
|
|
@@ -4786,7 +5489,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4786
5489
|
}
|
|
4787
5490
|
];
|
|
4788
5491
|
}
|
|
4789
|
-
function baseCompile(
|
|
5492
|
+
function baseCompile(source, options = {}) {
|
|
4790
5493
|
const onError = options.onError || defaultOnError;
|
|
4791
5494
|
const isModuleMode = options.mode === "module";
|
|
4792
5495
|
{
|
|
@@ -4803,7 +5506,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4803
5506
|
if (options.scopeId && !isModuleMode) {
|
|
4804
5507
|
onError(createCompilerError(50));
|
|
4805
5508
|
}
|
|
4806
|
-
const ast = isString(
|
|
5509
|
+
const ast = isString(source) ? baseParse(source, options) : source;
|
|
4807
5510
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
|
|
4808
5511
|
transform(
|
|
4809
5512
|
ast,
|
|
@@ -4869,25 +5572,22 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4869
5572
|
}
|
|
4870
5573
|
}
|
|
4871
5574
|
|
|
4872
|
-
const isRawTextContainer = /* @__PURE__ */ makeMap(
|
|
4873
|
-
"style,iframe,script,noscript",
|
|
4874
|
-
true
|
|
4875
|
-
);
|
|
4876
5575
|
const parserOptions = {
|
|
5576
|
+
parseMode: "html",
|
|
4877
5577
|
isVoidTag,
|
|
4878
5578
|
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag),
|
|
4879
5579
|
isPreTag: (tag) => tag === "pre",
|
|
4880
5580
|
decodeEntities: decodeHtmlBrowser ,
|
|
4881
5581
|
isBuiltInComponent: (tag) => {
|
|
4882
|
-
if (
|
|
5582
|
+
if (tag === "Transition" || tag === "transition") {
|
|
4883
5583
|
return TRANSITION;
|
|
4884
|
-
} else if (
|
|
5584
|
+
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
|
4885
5585
|
return TRANSITION_GROUP;
|
|
4886
5586
|
}
|
|
4887
5587
|
},
|
|
4888
5588
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
|
4889
|
-
getNamespace(tag, parent) {
|
|
4890
|
-
let ns = parent ? parent.ns :
|
|
5589
|
+
getNamespace(tag, parent, rootNamespace) {
|
|
5590
|
+
let ns = parent ? parent.ns : rootNamespace;
|
|
4891
5591
|
if (parent && ns === 2) {
|
|
4892
5592
|
if (parent.tag === "annotation-xml") {
|
|
4893
5593
|
if (tag === "svg") {
|
|
@@ -4915,18 +5615,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
4915
5615
|
}
|
|
4916
5616
|
}
|
|
4917
5617
|
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
5618
|
}
|
|
4931
5619
|
};
|
|
4932
5620
|
|
|
@@ -5041,8 +5729,8 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5041
5729
|
);
|
|
5042
5730
|
}
|
|
5043
5731
|
function checkDuplicatedValue() {
|
|
5044
|
-
const value =
|
|
5045
|
-
if (value) {
|
|
5732
|
+
const value = findDir(node, "bind");
|
|
5733
|
+
if (value && isStaticArgOf(value.arg, "value")) {
|
|
5046
5734
|
context.onError(
|
|
5047
5735
|
createDOMCompilerError(
|
|
5048
5736
|
60,
|
|
@@ -5247,6 +5935,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5247
5935
|
node.props.push({
|
|
5248
5936
|
type: 6,
|
|
5249
5937
|
name: "persisted",
|
|
5938
|
+
nameLoc: node.loc,
|
|
5250
5939
|
value: void 0,
|
|
5251
5940
|
loc: node.loc
|
|
5252
5941
|
});
|
|
@@ -5291,9 +5980,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5291
5980
|
// override compiler-core
|
|
5292
5981
|
show: transformShow
|
|
5293
5982
|
};
|
|
5294
|
-
function compile(
|
|
5983
|
+
function compile(src, options = {}) {
|
|
5295
5984
|
return baseCompile(
|
|
5296
|
-
|
|
5985
|
+
src,
|
|
5297
5986
|
extend({}, parserOptions, options, {
|
|
5298
5987
|
nodeTransforms: [
|
|
5299
5988
|
// ignore <script> and <tag>
|
|
@@ -5407,11 +6096,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5407
6096
|
exports.extractIdentifiers = extractIdentifiers;
|
|
5408
6097
|
exports.findDir = findDir;
|
|
5409
6098
|
exports.findProp = findProp;
|
|
6099
|
+
exports.forAliasRE = forAliasRE;
|
|
5410
6100
|
exports.generate = generate;
|
|
5411
6101
|
exports.generateCodeFrame = generateCodeFrame;
|
|
5412
6102
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
5413
6103
|
exports.getConstantType = getConstantType;
|
|
5414
|
-
exports.getInnerRange = getInnerRange;
|
|
5415
6104
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
5416
6105
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
5417
6106
|
exports.getVNodeHelper = getVNodeHelper;
|
|
@@ -5419,7 +6108,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
|
|
|
5419
6108
|
exports.hasScopeRef = hasScopeRef;
|
|
5420
6109
|
exports.helperNameMap = helperNameMap;
|
|
5421
6110
|
exports.injectProp = injectProp;
|
|
5422
|
-
exports.isBuiltInType = isBuiltInType;
|
|
5423
6111
|
exports.isCoreComponent = isCoreComponent;
|
|
5424
6112
|
exports.isFunctionType = isFunctionType;
|
|
5425
6113
|
exports.isInDestructureAssignment = isInDestructureAssignment;
|