@vue/compiler-core 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.
@@ -1,83 +1,6 @@
1
- import { isString, hyphenate, NOOP, extend, isObject, NO, isArray, makeMap, isSymbol, capitalize, camelize, EMPTY_OBJ, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
1
+ import { isString, NOOP, isObject, NO, extend, isSymbol, isArray, capitalize, camelize, EMPTY_OBJ, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
2
2
  export { generateCodeFrame } from '@vue/shared';
3
3
 
4
- function defaultOnError(error) {
5
- throw error;
6
- }
7
- function defaultOnWarn(msg) {
8
- !!(process.env.NODE_ENV !== "production") && console.warn(`[Vue warn] ${msg.message}`);
9
- }
10
- function createCompilerError(code, loc, messages, additionalMessage) {
11
- const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
12
- const error = new SyntaxError(String(msg));
13
- error.code = code;
14
- error.loc = loc;
15
- return error;
16
- }
17
- const errorMessages = {
18
- // parse errors
19
- [0]: "Illegal comment.",
20
- [1]: "CDATA section is allowed only in XML context.",
21
- [2]: "Duplicate attribute.",
22
- [3]: "End tag cannot have attributes.",
23
- [4]: "Illegal '/' in tags.",
24
- [5]: "Unexpected EOF in tag.",
25
- [6]: "Unexpected EOF in CDATA section.",
26
- [7]: "Unexpected EOF in comment.",
27
- [8]: "Unexpected EOF in script.",
28
- [9]: "Unexpected EOF in tag.",
29
- [10]: "Incorrectly closed comment.",
30
- [11]: "Incorrectly opened comment.",
31
- [12]: "Illegal tag name. Use '&lt;' to print '<'.",
32
- [13]: "Attribute value was expected.",
33
- [14]: "End tag name was expected.",
34
- [15]: "Whitespace was expected.",
35
- [16]: "Unexpected '<!--' in comment.",
36
- [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
37
- [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
38
- [19]: "Attribute name cannot start with '='.",
39
- [21]: "'<?' is allowed only in XML context.",
40
- [20]: `Unexpected null character.`,
41
- [22]: "Illegal '/' in tags.",
42
- // Vue-specific parse errors
43
- [23]: "Invalid end tag.",
44
- [24]: "Element is missing end tag.",
45
- [25]: "Interpolation end sign was not found.",
46
- [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
47
- [26]: "Legal directive name was expected.",
48
- // transform errors
49
- [28]: `v-if/v-else-if is missing expression.`,
50
- [29]: `v-if/else branches must use unique keys.`,
51
- [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
52
- [31]: `v-for is missing expression.`,
53
- [32]: `v-for has invalid expression.`,
54
- [33]: `<template v-for> key should be placed on the <template> tag.`,
55
- [34]: `v-bind is missing expression.`,
56
- [35]: `v-on is missing expression.`,
57
- [36]: `Unexpected custom directive on <slot> outlet.`,
58
- [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.`,
59
- [38]: `Duplicate slot names found. `,
60
- [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
61
- [40]: `v-slot can only be used on components or <template> tags.`,
62
- [41]: `v-model is missing expression.`,
63
- [42]: `v-model value must be a valid JavaScript member expression.`,
64
- [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
65
- [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
66
- Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
67
- [45]: `Error parsing JavaScript expression: `,
68
- [46]: `<KeepAlive> expects exactly one child component.`,
69
- // generic errors
70
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
71
- [48]: `ES module mode is not supported in this build of compiler.`,
72
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
73
- [50]: `"scopeId" option is only supported in module mode.`,
74
- // deprecations
75
- [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.`,
76
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
77
- // just to fulfill types
78
- [53]: ``
79
- };
80
-
81
4
  const FRAGMENT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Fragment` : ``);
82
5
  const TELEPORT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Teleport` : ``);
83
6
  const SUSPENSE = Symbol(!!(process.env.NODE_ENV !== "production") ? `Suspense` : ``);
@@ -167,13 +90,14 @@ function registerRuntimeHelpers(helpers) {
167
90
  }
168
91
 
169
92
  const locStub = {
170
- source: "",
171
93
  start: { line: 1, column: 1, offset: 0 },
172
- end: { line: 1, column: 1, offset: 0 }
94
+ end: { line: 1, column: 1, offset: 0 },
95
+ source: ""
173
96
  };
174
- function createRoot(children, loc = locStub) {
97
+ function createRoot(children, source = "") {
175
98
  return {
176
99
  type: 0,
100
+ source,
177
101
  children,
178
102
  helpers: /* @__PURE__ */ new Set(),
179
103
  components: [],
@@ -183,7 +107,7 @@ function createRoot(children, loc = locStub) {
183
107
  cached: 0,
184
108
  temps: 0,
185
109
  codegenNode: void 0,
186
- loc
110
+ loc: locStub
187
111
  };
188
112
  }
189
113
  function createVNodeCall(context, tag, props, children, patchFlag, dynamicProps, directives, isBlock = false, disableTracking = false, isComponent = false, loc = locStub) {
@@ -354,17 +278,970 @@ function convertToBlock(node, { helper, removeHelper, inSSR }) {
354
278
  }
355
279
  }
356
280
 
281
+ const defaultDelimitersOpen = new Uint8Array([123, 123]);
282
+ const defaultDelimitersClose = new Uint8Array([125, 125]);
283
+ function isTagStartChar(c) {
284
+ return c >= 97 && c <= 122 || c >= 65 && c <= 90;
285
+ }
286
+ function isWhitespace(c) {
287
+ return c === 32 || c === 10 || c === 9 || c === 12 || c === 13;
288
+ }
289
+ function isEndOfTagSection(c) {
290
+ return c === 47 || c === 62 || isWhitespace(c);
291
+ }
292
+ function toCharCodes(str) {
293
+ const ret = new Uint8Array(str.length);
294
+ for (let i = 0; i < str.length; i++) {
295
+ ret[i] = str.charCodeAt(i);
296
+ }
297
+ return ret;
298
+ }
299
+ const Sequences = {
300
+ Cdata: new Uint8Array([67, 68, 65, 84, 65, 91]),
301
+ // CDATA[
302
+ CdataEnd: new Uint8Array([93, 93, 62]),
303
+ // ]]>
304
+ CommentEnd: new Uint8Array([45, 45, 62]),
305
+ // `-->`
306
+ ScriptEnd: new Uint8Array([60, 47, 115, 99, 114, 105, 112, 116]),
307
+ // `<\/script`
308
+ StyleEnd: new Uint8Array([60, 47, 115, 116, 121, 108, 101]),
309
+ // `</style`
310
+ TitleEnd: new Uint8Array([60, 47, 116, 105, 116, 108, 101]),
311
+ // `</title`
312
+ TextareaEnd: new Uint8Array([
313
+ 60,
314
+ 47,
315
+ 116,
316
+ 101,
317
+ 120,
318
+ 116,
319
+ 97,
320
+ 114,
321
+ 101,
322
+ 97
323
+ ])
324
+ // `</textarea
325
+ };
326
+ class Tokenizer {
327
+ constructor(stack, cbs) {
328
+ this.stack = stack;
329
+ this.cbs = cbs;
330
+ /** The current state the tokenizer is in. */
331
+ this.state = 1;
332
+ /** The read buffer. */
333
+ this.buffer = "";
334
+ /** The beginning of the section that is currently being read. */
335
+ this.sectionStart = 0;
336
+ /** The index within the buffer that we are currently looking at. */
337
+ this.index = 0;
338
+ /** The start of the last entity. */
339
+ this.entityStart = 0;
340
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
341
+ this.baseState = 1;
342
+ /** For special parsing behavior inside of script and style tags. */
343
+ this.inRCDATA = false;
344
+ /** For disabling RCDATA tags handling */
345
+ this.inXML = false;
346
+ /** Reocrd newline positions for fast line / column calculation */
347
+ this.newlines = [];
348
+ this.mode = 0;
349
+ this.delimiterOpen = defaultDelimitersOpen;
350
+ this.delimiterClose = defaultDelimitersClose;
351
+ this.delimiterIndex = -1;
352
+ this.currentSequence = void 0;
353
+ this.sequenceIndex = 0;
354
+ }
355
+ get inSFCRoot() {
356
+ return this.mode === 2 && this.stack.length === 0;
357
+ }
358
+ reset() {
359
+ this.state = 1;
360
+ this.mode = 0;
361
+ this.buffer = "";
362
+ this.sectionStart = 0;
363
+ this.index = 0;
364
+ this.baseState = 1;
365
+ this.currentSequence = void 0;
366
+ this.newlines.length = 0;
367
+ this.delimiterOpen = defaultDelimitersOpen;
368
+ this.delimiterClose = defaultDelimitersClose;
369
+ }
370
+ /**
371
+ * Generate Position object with line / column information using recorded
372
+ * newline positions. We know the index is always going to be an already
373
+ * processed index, so all the newlines up to this index should have been
374
+ * recorded.
375
+ */
376
+ getPos(index) {
377
+ let line = 1;
378
+ let column = index + 1;
379
+ for (let i = this.newlines.length - 1; i >= 0; i--) {
380
+ const newlineIndex = this.newlines[i];
381
+ if (index > newlineIndex) {
382
+ line = i + 2;
383
+ column = index - newlineIndex;
384
+ break;
385
+ }
386
+ }
387
+ return {
388
+ column,
389
+ line,
390
+ offset: index
391
+ };
392
+ }
393
+ peek() {
394
+ return this.buffer.charCodeAt(this.index + 1);
395
+ }
396
+ stateText(c) {
397
+ if (c === 60) {
398
+ if (this.index > this.sectionStart) {
399
+ this.cbs.ontext(this.sectionStart, this.index);
400
+ }
401
+ this.state = 5;
402
+ this.sectionStart = this.index;
403
+ } else if (c === this.delimiterOpen[0]) {
404
+ this.state = 2;
405
+ this.delimiterIndex = 0;
406
+ this.stateInterpolationOpen(c);
407
+ }
408
+ }
409
+ stateInterpolationOpen(c) {
410
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
411
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
412
+ const start = this.index + 1 - this.delimiterOpen.length;
413
+ if (start > this.sectionStart) {
414
+ this.cbs.ontext(this.sectionStart, start);
415
+ }
416
+ this.state = 3;
417
+ this.sectionStart = start;
418
+ } else {
419
+ this.delimiterIndex++;
420
+ }
421
+ } else if (this.inRCDATA) {
422
+ this.state = 32;
423
+ this.stateInRCDATA(c);
424
+ } else {
425
+ this.state = 1;
426
+ this.stateText(c);
427
+ }
428
+ }
429
+ stateInterpolation(c) {
430
+ if (c === this.delimiterClose[0]) {
431
+ this.state = 4;
432
+ this.delimiterIndex = 0;
433
+ this.stateInterpolationClose(c);
434
+ }
435
+ }
436
+ stateInterpolationClose(c) {
437
+ if (c === this.delimiterClose[this.delimiterIndex]) {
438
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
439
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
440
+ if (this.inRCDATA) {
441
+ this.state = 32;
442
+ } else {
443
+ this.state = 1;
444
+ }
445
+ this.sectionStart = this.index + 1;
446
+ } else {
447
+ this.delimiterIndex++;
448
+ }
449
+ } else {
450
+ this.state = 3;
451
+ this.stateInterpolation(c);
452
+ }
453
+ }
454
+ stateSpecialStartSequence(c) {
455
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
456
+ const isMatch = isEnd ? (
457
+ // If we are at the end of the sequence, make sure the tag name has ended
458
+ isEndOfTagSection(c)
459
+ ) : (
460
+ // Otherwise, do a case-insensitive comparison
461
+ (c | 32) === this.currentSequence[this.sequenceIndex]
462
+ );
463
+ if (!isMatch) {
464
+ this.inRCDATA = false;
465
+ } else if (!isEnd) {
466
+ this.sequenceIndex++;
467
+ return;
468
+ }
469
+ this.sequenceIndex = 0;
470
+ this.state = 6;
471
+ this.stateInTagName(c);
472
+ }
473
+ /** Look for an end tag. For <title> and <textarea>, also decode entities. */
474
+ stateInRCDATA(c) {
475
+ if (this.sequenceIndex === this.currentSequence.length) {
476
+ if (c === 62 || isWhitespace(c)) {
477
+ const endOfText = this.index - this.currentSequence.length;
478
+ if (this.sectionStart < endOfText) {
479
+ const actualIndex = this.index;
480
+ this.index = endOfText;
481
+ this.cbs.ontext(this.sectionStart, endOfText);
482
+ this.index = actualIndex;
483
+ }
484
+ this.sectionStart = endOfText + 2;
485
+ this.stateInClosingTagName(c);
486
+ this.inRCDATA = false;
487
+ return;
488
+ }
489
+ this.sequenceIndex = 0;
490
+ }
491
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) {
492
+ this.sequenceIndex += 1;
493
+ } else if (this.sequenceIndex === 0) {
494
+ if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
495
+ if (c === this.delimiterOpen[0]) {
496
+ this.state = 2;
497
+ this.delimiterIndex = 0;
498
+ this.stateInterpolationOpen(c);
499
+ }
500
+ } else if (this.fastForwardTo(60)) {
501
+ this.sequenceIndex = 1;
502
+ }
503
+ } else {
504
+ this.sequenceIndex = Number(c === 60);
505
+ }
506
+ }
507
+ stateCDATASequence(c) {
508
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
509
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
510
+ this.state = 28;
511
+ this.currentSequence = Sequences.CdataEnd;
512
+ this.sequenceIndex = 0;
513
+ this.sectionStart = this.index + 1;
514
+ }
515
+ } else {
516
+ this.sequenceIndex = 0;
517
+ this.state = 23;
518
+ this.stateInDeclaration(c);
519
+ }
520
+ }
521
+ /**
522
+ * When we wait for one specific character, we can speed things up
523
+ * by skipping through the buffer until we find it.
524
+ *
525
+ * @returns Whether the character was found.
526
+ */
527
+ fastForwardTo(c) {
528
+ while (++this.index < this.buffer.length) {
529
+ const cc = this.buffer.charCodeAt(this.index);
530
+ if (cc === 10) {
531
+ this.newlines.push(this.index);
532
+ }
533
+ if (cc === c) {
534
+ return true;
535
+ }
536
+ }
537
+ this.index = this.buffer.length - 1;
538
+ return false;
539
+ }
540
+ /**
541
+ * Comments and CDATA end with `-->` and `]]>`.
542
+ *
543
+ * Their common qualities are:
544
+ * - Their end sequences have a distinct character they start with.
545
+ * - That character is then repeated, so we have to check multiple repeats.
546
+ * - All characters but the start character of the sequence can be skipped.
547
+ */
548
+ stateInCommentLike(c) {
549
+ if (c === this.currentSequence[this.sequenceIndex]) {
550
+ if (++this.sequenceIndex === this.currentSequence.length) {
551
+ if (this.currentSequence === Sequences.CdataEnd) {
552
+ this.cbs.oncdata(this.sectionStart, this.index - 2);
553
+ } else {
554
+ this.cbs.oncomment(this.sectionStart, this.index - 2);
555
+ }
556
+ this.sequenceIndex = 0;
557
+ this.sectionStart = this.index + 1;
558
+ this.state = 1;
559
+ }
560
+ } else if (this.sequenceIndex === 0) {
561
+ if (this.fastForwardTo(this.currentSequence[0])) {
562
+ this.sequenceIndex = 1;
563
+ }
564
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) {
565
+ this.sequenceIndex = 0;
566
+ }
567
+ }
568
+ startSpecial(sequence, offset) {
569
+ this.enterRCDATA(sequence, offset);
570
+ this.state = 31;
571
+ }
572
+ enterRCDATA(sequence, offset) {
573
+ this.inRCDATA = true;
574
+ this.currentSequence = sequence;
575
+ this.sequenceIndex = offset;
576
+ }
577
+ stateBeforeTagName(c) {
578
+ if (c === 33) {
579
+ this.state = 22;
580
+ this.sectionStart = this.index + 1;
581
+ } else if (c === 63) {
582
+ this.state = 24;
583
+ this.sectionStart = this.index + 1;
584
+ } else if (isTagStartChar(c)) {
585
+ this.sectionStart = this.index;
586
+ if (this.mode === 0) {
587
+ this.state = 6;
588
+ } else if (this.inSFCRoot) {
589
+ this.state = 34;
590
+ } else if (!this.inXML) {
591
+ const lower = c | 32;
592
+ if (lower === 116) {
593
+ this.state = 30;
594
+ } else {
595
+ this.state = lower === 115 ? 29 : 6;
596
+ }
597
+ } else {
598
+ this.state = 6;
599
+ }
600
+ } else if (c === 47) {
601
+ this.state = 8;
602
+ } else {
603
+ this.state = 1;
604
+ this.stateText(c);
605
+ }
606
+ }
607
+ stateInTagName(c) {
608
+ if (isEndOfTagSection(c)) {
609
+ this.handleTagName(c);
610
+ }
611
+ }
612
+ stateInSFCRootTagName(c) {
613
+ if (isEndOfTagSection(c)) {
614
+ const tag = this.buffer.slice(this.sectionStart, this.index);
615
+ if (tag !== "template") {
616
+ this.enterRCDATA(toCharCodes(`</` + tag), 0);
617
+ }
618
+ this.handleTagName(c);
619
+ }
620
+ }
621
+ handleTagName(c) {
622
+ this.cbs.onopentagname(this.sectionStart, this.index);
623
+ this.sectionStart = -1;
624
+ this.state = 11;
625
+ this.stateBeforeAttrName(c);
626
+ }
627
+ stateBeforeClosingTagName(c) {
628
+ if (isWhitespace(c)) ; else if (c === 62) {
629
+ if (!!(process.env.NODE_ENV !== "production") || false) {
630
+ this.cbs.onerr(14, this.index);
631
+ }
632
+ this.state = 1;
633
+ this.sectionStart = this.index + 1;
634
+ } else {
635
+ this.state = isTagStartChar(c) ? 9 : 27;
636
+ this.sectionStart = this.index;
637
+ }
638
+ }
639
+ stateInClosingTagName(c) {
640
+ if (c === 62 || isWhitespace(c)) {
641
+ this.cbs.onclosetag(this.sectionStart, this.index);
642
+ this.sectionStart = -1;
643
+ this.state = 10;
644
+ this.stateAfterClosingTagName(c);
645
+ }
646
+ }
647
+ stateAfterClosingTagName(c) {
648
+ if (c === 62) {
649
+ this.state = 1;
650
+ this.sectionStart = this.index + 1;
651
+ }
652
+ }
653
+ stateBeforeAttrName(c) {
654
+ if (c === 62) {
655
+ this.cbs.onopentagend(this.index);
656
+ if (this.inRCDATA) {
657
+ this.state = 32;
658
+ } else {
659
+ this.state = 1;
660
+ }
661
+ this.sectionStart = this.index + 1;
662
+ } else if (c === 47) {
663
+ this.state = 7;
664
+ if ((!!(process.env.NODE_ENV !== "production") || false) && this.peek() !== 62) {
665
+ this.cbs.onerr(22, this.index);
666
+ }
667
+ } else if (c === 60 && this.peek() === 47) {
668
+ this.cbs.onopentagend(this.index);
669
+ this.state = 5;
670
+ this.sectionStart = this.index;
671
+ } else if (!isWhitespace(c)) {
672
+ if ((!!(process.env.NODE_ENV !== "production") || false) && c === 61) {
673
+ this.cbs.onerr(
674
+ 19,
675
+ this.index
676
+ );
677
+ }
678
+ this.handleAttrStart(c);
679
+ }
680
+ }
681
+ handleAttrStart(c) {
682
+ if (c === 118 && this.peek() === 45) {
683
+ this.state = 13;
684
+ this.sectionStart = this.index;
685
+ } else if (c === 46 || c === 58 || c === 64 || c === 35) {
686
+ this.cbs.ondirname(this.index, this.index + 1);
687
+ this.state = 14;
688
+ this.sectionStart = this.index + 1;
689
+ } else {
690
+ this.state = 12;
691
+ this.sectionStart = this.index;
692
+ }
693
+ }
694
+ stateInSelfClosingTag(c) {
695
+ if (c === 62) {
696
+ this.cbs.onselfclosingtag(this.index);
697
+ this.state = 1;
698
+ this.sectionStart = this.index + 1;
699
+ this.inRCDATA = false;
700
+ } else if (!isWhitespace(c)) {
701
+ this.state = 11;
702
+ this.stateBeforeAttrName(c);
703
+ }
704
+ }
705
+ stateInAttrName(c) {
706
+ if (c === 61 || isEndOfTagSection(c)) {
707
+ this.cbs.onattribname(this.sectionStart, this.index);
708
+ this.handleAttrNameEnd(c);
709
+ } else if ((!!(process.env.NODE_ENV !== "production") || false) && (c === 34 || c === 39 || c === 60)) {
710
+ this.cbs.onerr(
711
+ 17,
712
+ this.index
713
+ );
714
+ }
715
+ }
716
+ stateInDirName(c) {
717
+ if (c === 61 || isEndOfTagSection(c)) {
718
+ this.cbs.ondirname(this.sectionStart, this.index);
719
+ this.handleAttrNameEnd(c);
720
+ } else if (c === 58) {
721
+ this.cbs.ondirname(this.sectionStart, this.index);
722
+ this.state = 14;
723
+ this.sectionStart = this.index + 1;
724
+ } else if (c === 46) {
725
+ this.cbs.ondirname(this.sectionStart, this.index);
726
+ this.state = 16;
727
+ this.sectionStart = this.index + 1;
728
+ }
729
+ }
730
+ stateInDirArg(c) {
731
+ if (c === 61 || isEndOfTagSection(c)) {
732
+ this.cbs.ondirarg(this.sectionStart, this.index);
733
+ this.handleAttrNameEnd(c);
734
+ } else if (c === 91) {
735
+ this.state = 15;
736
+ } else if (c === 46) {
737
+ this.cbs.ondirarg(this.sectionStart, this.index);
738
+ this.state = 16;
739
+ this.sectionStart = this.index + 1;
740
+ }
741
+ }
742
+ stateInDynamicDirArg(c) {
743
+ if (c === 93) {
744
+ this.state = 14;
745
+ } else if (c === 61 || isEndOfTagSection(c)) {
746
+ this.cbs.ondirarg(this.sectionStart, this.index + 1);
747
+ this.handleAttrNameEnd(c);
748
+ if (!!(process.env.NODE_ENV !== "production") || false) {
749
+ this.cbs.onerr(
750
+ 27,
751
+ this.index
752
+ );
753
+ }
754
+ }
755
+ }
756
+ stateInDirModifier(c) {
757
+ if (c === 61 || isEndOfTagSection(c)) {
758
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
759
+ this.handleAttrNameEnd(c);
760
+ } else if (c === 46) {
761
+ this.cbs.ondirmodifier(this.sectionStart, this.index);
762
+ this.sectionStart = this.index + 1;
763
+ }
764
+ }
765
+ handleAttrNameEnd(c) {
766
+ this.sectionStart = this.index;
767
+ this.state = 17;
768
+ this.cbs.onattribnameend(this.index);
769
+ this.stateAfterAttrName(c);
770
+ }
771
+ stateAfterAttrName(c) {
772
+ if (c === 61) {
773
+ this.state = 18;
774
+ } else if (c === 47 || c === 62) {
775
+ this.cbs.onattribend(0, this.sectionStart);
776
+ this.sectionStart = -1;
777
+ this.state = 11;
778
+ this.stateBeforeAttrName(c);
779
+ } else if (!isWhitespace(c)) {
780
+ this.cbs.onattribend(0, this.sectionStart);
781
+ this.handleAttrStart(c);
782
+ }
783
+ }
784
+ stateBeforeAttrValue(c) {
785
+ if (c === 34) {
786
+ this.state = 19;
787
+ this.sectionStart = this.index + 1;
788
+ } else if (c === 39) {
789
+ this.state = 20;
790
+ this.sectionStart = this.index + 1;
791
+ } else if (!isWhitespace(c)) {
792
+ this.sectionStart = this.index;
793
+ this.state = 21;
794
+ this.stateInAttrValueNoQuotes(c);
795
+ }
796
+ }
797
+ handleInAttrValue(c, quote) {
798
+ if (c === quote || this.fastForwardTo(quote)) {
799
+ this.cbs.onattribdata(this.sectionStart, this.index);
800
+ this.sectionStart = -1;
801
+ this.cbs.onattribend(
802
+ quote === 34 ? 3 : 2,
803
+ this.index + 1
804
+ );
805
+ this.state = 11;
806
+ }
807
+ }
808
+ stateInAttrValueDoubleQuotes(c) {
809
+ this.handleInAttrValue(c, 34);
810
+ }
811
+ stateInAttrValueSingleQuotes(c) {
812
+ this.handleInAttrValue(c, 39);
813
+ }
814
+ stateInAttrValueNoQuotes(c) {
815
+ if (isWhitespace(c) || c === 62) {
816
+ this.cbs.onattribdata(this.sectionStart, this.index);
817
+ this.sectionStart = -1;
818
+ this.cbs.onattribend(1, this.index);
819
+ this.state = 11;
820
+ this.stateBeforeAttrName(c);
821
+ } else if ((!!(process.env.NODE_ENV !== "production") || false) && c === 34 || c === 39 || c === 60 || c === 61 || c === 96) {
822
+ this.cbs.onerr(
823
+ 18,
824
+ this.index
825
+ );
826
+ } else ;
827
+ }
828
+ stateBeforeDeclaration(c) {
829
+ if (c === 91) {
830
+ this.state = 26;
831
+ this.sequenceIndex = 0;
832
+ } else {
833
+ this.state = c === 45 ? 25 : 23;
834
+ }
835
+ }
836
+ stateInDeclaration(c) {
837
+ if (c === 62 || this.fastForwardTo(62)) {
838
+ this.state = 1;
839
+ this.sectionStart = this.index + 1;
840
+ }
841
+ }
842
+ stateInProcessingInstruction(c) {
843
+ if (c === 62 || this.fastForwardTo(62)) {
844
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
845
+ this.state = 1;
846
+ this.sectionStart = this.index + 1;
847
+ }
848
+ }
849
+ stateBeforeComment(c) {
850
+ if (c === 45) {
851
+ this.state = 28;
852
+ this.currentSequence = Sequences.CommentEnd;
853
+ this.sequenceIndex = 2;
854
+ this.sectionStart = this.index + 1;
855
+ } else {
856
+ this.state = 23;
857
+ }
858
+ }
859
+ stateInSpecialComment(c) {
860
+ if (c === 62 || this.fastForwardTo(62)) {
861
+ this.cbs.oncomment(this.sectionStart, this.index);
862
+ this.state = 1;
863
+ this.sectionStart = this.index + 1;
864
+ }
865
+ }
866
+ stateBeforeSpecialS(c) {
867
+ const lower = c | 32;
868
+ if (lower === Sequences.ScriptEnd[3]) {
869
+ this.startSpecial(Sequences.ScriptEnd, 4);
870
+ } else if (lower === Sequences.StyleEnd[3]) {
871
+ this.startSpecial(Sequences.StyleEnd, 4);
872
+ } else {
873
+ this.state = 6;
874
+ this.stateInTagName(c);
875
+ }
876
+ }
877
+ stateBeforeSpecialT(c) {
878
+ const lower = c | 32;
879
+ if (lower === Sequences.TitleEnd[3]) {
880
+ this.startSpecial(Sequences.TitleEnd, 4);
881
+ } else if (lower === Sequences.TextareaEnd[3]) {
882
+ this.startSpecial(Sequences.TextareaEnd, 4);
883
+ } else {
884
+ this.state = 6;
885
+ this.stateInTagName(c);
886
+ }
887
+ }
888
+ startEntity() {
889
+ }
890
+ stateInEntity() {
891
+ }
892
+ /**
893
+ * Iterates through the buffer, calling the function corresponding to the current state.
894
+ *
895
+ * States that are more likely to be hit are higher up, as a performance improvement.
896
+ */
897
+ parse(input) {
898
+ this.buffer = input;
899
+ while (this.index < this.buffer.length) {
900
+ const c = this.buffer.charCodeAt(this.index);
901
+ if (c === 10) {
902
+ this.newlines.push(this.index);
903
+ }
904
+ switch (this.state) {
905
+ case 1: {
906
+ this.stateText(c);
907
+ break;
908
+ }
909
+ case 2: {
910
+ this.stateInterpolationOpen(c);
911
+ break;
912
+ }
913
+ case 3: {
914
+ this.stateInterpolation(c);
915
+ break;
916
+ }
917
+ case 4: {
918
+ this.stateInterpolationClose(c);
919
+ break;
920
+ }
921
+ case 31: {
922
+ this.stateSpecialStartSequence(c);
923
+ break;
924
+ }
925
+ case 32: {
926
+ this.stateInRCDATA(c);
927
+ break;
928
+ }
929
+ case 26: {
930
+ this.stateCDATASequence(c);
931
+ break;
932
+ }
933
+ case 19: {
934
+ this.stateInAttrValueDoubleQuotes(c);
935
+ break;
936
+ }
937
+ case 12: {
938
+ this.stateInAttrName(c);
939
+ break;
940
+ }
941
+ case 13: {
942
+ this.stateInDirName(c);
943
+ break;
944
+ }
945
+ case 14: {
946
+ this.stateInDirArg(c);
947
+ break;
948
+ }
949
+ case 15: {
950
+ this.stateInDynamicDirArg(c);
951
+ break;
952
+ }
953
+ case 16: {
954
+ this.stateInDirModifier(c);
955
+ break;
956
+ }
957
+ case 28: {
958
+ this.stateInCommentLike(c);
959
+ break;
960
+ }
961
+ case 27: {
962
+ this.stateInSpecialComment(c);
963
+ break;
964
+ }
965
+ case 11: {
966
+ this.stateBeforeAttrName(c);
967
+ break;
968
+ }
969
+ case 6: {
970
+ this.stateInTagName(c);
971
+ break;
972
+ }
973
+ case 34: {
974
+ this.stateInSFCRootTagName(c);
975
+ break;
976
+ }
977
+ case 9: {
978
+ this.stateInClosingTagName(c);
979
+ break;
980
+ }
981
+ case 5: {
982
+ this.stateBeforeTagName(c);
983
+ break;
984
+ }
985
+ case 17: {
986
+ this.stateAfterAttrName(c);
987
+ break;
988
+ }
989
+ case 20: {
990
+ this.stateInAttrValueSingleQuotes(c);
991
+ break;
992
+ }
993
+ case 18: {
994
+ this.stateBeforeAttrValue(c);
995
+ break;
996
+ }
997
+ case 8: {
998
+ this.stateBeforeClosingTagName(c);
999
+ break;
1000
+ }
1001
+ case 10: {
1002
+ this.stateAfterClosingTagName(c);
1003
+ break;
1004
+ }
1005
+ case 29: {
1006
+ this.stateBeforeSpecialS(c);
1007
+ break;
1008
+ }
1009
+ case 30: {
1010
+ this.stateBeforeSpecialT(c);
1011
+ break;
1012
+ }
1013
+ case 21: {
1014
+ this.stateInAttrValueNoQuotes(c);
1015
+ break;
1016
+ }
1017
+ case 7: {
1018
+ this.stateInSelfClosingTag(c);
1019
+ break;
1020
+ }
1021
+ case 23: {
1022
+ this.stateInDeclaration(c);
1023
+ break;
1024
+ }
1025
+ case 22: {
1026
+ this.stateBeforeDeclaration(c);
1027
+ break;
1028
+ }
1029
+ case 25: {
1030
+ this.stateBeforeComment(c);
1031
+ break;
1032
+ }
1033
+ case 24: {
1034
+ this.stateInProcessingInstruction(c);
1035
+ break;
1036
+ }
1037
+ case 33: {
1038
+ this.stateInEntity();
1039
+ break;
1040
+ }
1041
+ }
1042
+ this.index++;
1043
+ }
1044
+ this.cleanup();
1045
+ this.finish();
1046
+ }
1047
+ /**
1048
+ * Remove data that has already been consumed from the buffer.
1049
+ */
1050
+ cleanup() {
1051
+ if (this.sectionStart !== this.index) {
1052
+ if (this.state === 1 || this.state === 32 && this.sequenceIndex === 0) {
1053
+ this.cbs.ontext(this.sectionStart, this.index);
1054
+ this.sectionStart = this.index;
1055
+ } else if (this.state === 19 || this.state === 20 || this.state === 21) {
1056
+ this.cbs.onattribdata(this.sectionStart, this.index);
1057
+ this.sectionStart = this.index;
1058
+ }
1059
+ }
1060
+ }
1061
+ finish() {
1062
+ this.handleTrailingData();
1063
+ this.cbs.onend();
1064
+ }
1065
+ /** Handle any trailing data. */
1066
+ handleTrailingData() {
1067
+ const endIndex = this.buffer.length;
1068
+ if (this.sectionStart >= endIndex) {
1069
+ return;
1070
+ }
1071
+ if (this.state === 28) {
1072
+ if (this.currentSequence === Sequences.CdataEnd) {
1073
+ this.cbs.oncdata(this.sectionStart, endIndex);
1074
+ } else {
1075
+ this.cbs.oncomment(this.sectionStart, endIndex);
1076
+ }
1077
+ } 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 {
1078
+ this.cbs.ontext(this.sectionStart, endIndex);
1079
+ }
1080
+ }
1081
+ emitCodePoint(cp, consumed) {
1082
+ }
1083
+ }
1084
+
1085
+ const deprecationData = {
1086
+ ["COMPILER_IS_ON_ELEMENT"]: {
1087
+ 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:".`,
1088
+ link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
1089
+ },
1090
+ ["COMPILER_V_BIND_SYNC"]: {
1091
+ 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}\`.`,
1092
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
1093
+ },
1094
+ ["COMPILER_V_BIND_OBJECT_ORDER"]: {
1095
+ 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.`,
1096
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
1097
+ },
1098
+ ["COMPILER_V_ON_NATIVE"]: {
1099
+ message: `.native modifier for v-on has been removed as is no longer necessary.`,
1100
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
1101
+ },
1102
+ ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
1103
+ 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.`,
1104
+ link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
1105
+ },
1106
+ ["COMPILER_NATIVE_TEMPLATE"]: {
1107
+ message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
1108
+ },
1109
+ ["COMPILER_INLINE_TEMPLATE"]: {
1110
+ message: `"inline-template" has been removed in Vue 3.`,
1111
+ link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
1112
+ },
1113
+ ["COMPILER_FILTER"]: {
1114
+ 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.`,
1115
+ link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
1116
+ }
1117
+ };
1118
+ function getCompatValue(key, { compatConfig }) {
1119
+ const value = compatConfig && compatConfig[key];
1120
+ if (key === "MODE") {
1121
+ return value || 3;
1122
+ } else {
1123
+ return value;
1124
+ }
1125
+ }
1126
+ function isCompatEnabled(key, context) {
1127
+ const mode = getCompatValue("MODE", context);
1128
+ const value = getCompatValue(key, context);
1129
+ return mode === 3 ? value === true : value !== false;
1130
+ }
1131
+ function checkCompatEnabled(key, context, loc, ...args) {
1132
+ const enabled = isCompatEnabled(key, context);
1133
+ if (!!(process.env.NODE_ENV !== "production") && enabled) {
1134
+ warnDeprecation(key, context, loc, ...args);
1135
+ }
1136
+ return enabled;
1137
+ }
1138
+ function warnDeprecation(key, context, loc, ...args) {
1139
+ const val = getCompatValue(key, context);
1140
+ if (val === "suppress-warning") {
1141
+ return;
1142
+ }
1143
+ const { message, link } = deprecationData[key];
1144
+ const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
1145
+ Details: ${link}` : ``}`;
1146
+ const err = new SyntaxError(msg);
1147
+ err.code = key;
1148
+ if (loc)
1149
+ err.loc = loc;
1150
+ context.onWarn(err);
1151
+ }
1152
+
1153
+ function defaultOnError(error) {
1154
+ throw error;
1155
+ }
1156
+ function defaultOnWarn(msg) {
1157
+ !!(process.env.NODE_ENV !== "production") && console.warn(`[Vue warn] ${msg.message}`);
1158
+ }
1159
+ function createCompilerError(code, loc, messages, additionalMessage) {
1160
+ const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : `https://vuejs.org/errors/#compiler-${code}`;
1161
+ const error = new SyntaxError(String(msg));
1162
+ error.code = code;
1163
+ error.loc = loc;
1164
+ return error;
1165
+ }
1166
+ const errorMessages = {
1167
+ // parse errors
1168
+ [0]: "Illegal comment.",
1169
+ [1]: "CDATA section is allowed only in XML context.",
1170
+ [2]: "Duplicate attribute.",
1171
+ [3]: "End tag cannot have attributes.",
1172
+ [4]: "Illegal '/' in tags.",
1173
+ [5]: "Unexpected EOF in tag.",
1174
+ [6]: "Unexpected EOF in CDATA section.",
1175
+ [7]: "Unexpected EOF in comment.",
1176
+ [8]: "Unexpected EOF in script.",
1177
+ [9]: "Unexpected EOF in tag.",
1178
+ [10]: "Incorrectly closed comment.",
1179
+ [11]: "Incorrectly opened comment.",
1180
+ [12]: "Illegal tag name. Use '&lt;' to print '<'.",
1181
+ [13]: "Attribute value was expected.",
1182
+ [14]: "End tag name was expected.",
1183
+ [15]: "Whitespace was expected.",
1184
+ [16]: "Unexpected '<!--' in comment.",
1185
+ [17]: `Attribute name cannot contain U+0022 ("), U+0027 ('), and U+003C (<).`,
1186
+ [18]: "Unquoted attribute value cannot contain U+0022 (\"), U+0027 ('), U+003C (<), U+003D (=), and U+0060 (`).",
1187
+ [19]: "Attribute name cannot start with '='.",
1188
+ [21]: "'<?' is allowed only in XML context.",
1189
+ [20]: `Unexpected null character.`,
1190
+ [22]: "Illegal '/' in tags.",
1191
+ // Vue-specific parse errors
1192
+ [23]: "Invalid end tag.",
1193
+ [24]: "Element is missing end tag.",
1194
+ [25]: "Interpolation end sign was not found.",
1195
+ [27]: "End bracket for dynamic directive argument was not found. Note that dynamic directive argument cannot contain spaces.",
1196
+ [26]: "Legal directive name was expected.",
1197
+ // transform errors
1198
+ [28]: `v-if/v-else-if is missing expression.`,
1199
+ [29]: `v-if/else branches must use unique keys.`,
1200
+ [30]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
1201
+ [31]: `v-for is missing expression.`,
1202
+ [32]: `v-for has invalid expression.`,
1203
+ [33]: `<template v-for> key should be placed on the <template> tag.`,
1204
+ [34]: `v-bind is missing expression.`,
1205
+ [35]: `v-on is missing expression.`,
1206
+ [36]: `Unexpected custom directive on <slot> outlet.`,
1207
+ [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.`,
1208
+ [38]: `Duplicate slot names found. `,
1209
+ [39]: `Extraneous children found when component already has explicitly named default slot. These children will be ignored.`,
1210
+ [40]: `v-slot can only be used on components or <template> tags.`,
1211
+ [41]: `v-model is missing expression.`,
1212
+ [42]: `v-model value must be a valid JavaScript member expression.`,
1213
+ [43]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
1214
+ [44]: `v-model cannot be used on a prop, because local prop bindings are not writable.
1215
+ Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
1216
+ [45]: `Error parsing JavaScript expression: `,
1217
+ [46]: `<KeepAlive> expects exactly one child component.`,
1218
+ // generic errors
1219
+ [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1220
+ [48]: `ES module mode is not supported in this build of compiler.`,
1221
+ [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1222
+ [50]: `"scopeId" option is only supported in module mode.`,
1223
+ // deprecations
1224
+ [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.`,
1225
+ [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
1226
+ // just to fulfill types
1227
+ [53]: ``
1228
+ };
1229
+
357
1230
  const isStaticExp = (p) => p.type === 4 && p.isStatic;
358
- const isBuiltInType = (tag, expected) => tag === expected || tag === hyphenate(expected);
359
1231
  function isCoreComponent(tag) {
360
- if (isBuiltInType(tag, "Teleport")) {
361
- return TELEPORT;
362
- } else if (isBuiltInType(tag, "Suspense")) {
363
- return SUSPENSE;
364
- } else if (isBuiltInType(tag, "KeepAlive")) {
365
- return KEEP_ALIVE;
366
- } else if (isBuiltInType(tag, "BaseTransition")) {
367
- return BASE_TRANSITION;
1232
+ switch (tag) {
1233
+ case "Teleport":
1234
+ case "teleport":
1235
+ return TELEPORT;
1236
+ case "Suspense":
1237
+ case "suspense":
1238
+ return SUSPENSE;
1239
+ case "KeepAlive":
1240
+ case "keep-alive":
1241
+ return KEEP_ALIVE;
1242
+ case "BaseTransition":
1243
+ case "base-transition":
1244
+ return BASE_TRANSITION;
368
1245
  }
369
1246
  }
370
1247
  const nonIdentifierRE = /^\d|[^\$\w]/;
@@ -436,25 +1313,13 @@ const isMemberExpressionBrowser = (path) => {
436
1313
  };
437
1314
  const isMemberExpressionNode = NOOP ;
438
1315
  const isMemberExpression = isMemberExpressionBrowser ;
439
- function getInnerRange(loc, offset, length) {
440
- const source = loc.source.slice(offset, offset + length);
441
- const newLoc = {
442
- source,
443
- start: advancePositionWithClone(loc.start, loc.source, offset),
444
- end: loc.end
445
- };
446
- if (length != null) {
447
- newLoc.end = advancePositionWithClone(
448
- loc.start,
449
- loc.source,
450
- offset + length
451
- );
452
- }
453
- return newLoc;
454
- }
455
1316
  function advancePositionWithClone(pos, source, numberOfCharacters = source.length) {
456
1317
  return advancePositionWithMutation(
457
- extend({}, pos),
1318
+ {
1319
+ offset: pos.offset,
1320
+ line: pos.line,
1321
+ column: pos.column
1322
+ },
458
1323
  source,
459
1324
  numberOfCharacters
460
1325
  );
@@ -656,471 +1521,562 @@ function getMemoedVNodeCall(node) {
656
1521
  return node;
657
1522
  }
658
1523
  }
1524
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
659
1525
 
660
- const deprecationData = {
661
- ["COMPILER_IS_ON_ELEMENT"]: {
662
- 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:".`,
663
- link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
664
- },
665
- ["COMPILER_V_BIND_SYNC"]: {
666
- 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}\`.`,
667
- link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
668
- },
669
- ["COMPILER_V_BIND_PROP"]: {
670
- 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.`
671
- },
672
- ["COMPILER_V_BIND_OBJECT_ORDER"]: {
673
- 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.`,
674
- link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
675
- },
676
- ["COMPILER_V_ON_NATIVE"]: {
677
- message: `.native modifier for v-on has been removed as is no longer necessary.`,
678
- link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
679
- },
680
- ["COMPILER_V_IF_V_FOR_PRECEDENCE"]: {
681
- 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.`,
682
- link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
683
- },
684
- ["COMPILER_NATIVE_TEMPLATE"]: {
685
- message: `<template> with no special directives will render as a native template element instead of its inner content in Vue 3.`
686
- },
687
- ["COMPILER_INLINE_TEMPLATE"]: {
688
- message: `"inline-template" has been removed in Vue 3.`,
689
- link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
690
- },
691
- ["COMPILER_FILTER"]: {
692
- 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.`,
693
- link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
694
- }
695
- };
696
- function getCompatValue(key, context) {
697
- const config = context.options ? context.options.compatConfig : context.compatConfig;
698
- const value = config && config[key];
699
- if (key === "MODE") {
700
- return value || 3;
701
- } else {
702
- return value;
703
- }
704
- }
705
- function isCompatEnabled(key, context) {
706
- const mode = getCompatValue("MODE", context);
707
- const value = getCompatValue(key, context);
708
- return mode === 3 ? value === true : value !== false;
709
- }
710
- function checkCompatEnabled(key, context, loc, ...args) {
711
- const enabled = isCompatEnabled(key, context);
712
- if (!!(process.env.NODE_ENV !== "production") && enabled) {
713
- warnDeprecation(key, context, loc, ...args);
714
- }
715
- return enabled;
716
- }
717
- function warnDeprecation(key, context, loc, ...args) {
718
- const val = getCompatValue(key, context);
719
- if (val === "suppress-warning") {
720
- return;
721
- }
722
- const { message, link } = deprecationData[key];
723
- const msg = `(deprecation ${key}) ${typeof message === "function" ? message(...args) : message}${link ? `
724
- Details: ${link}` : ``}`;
725
- const err = new SyntaxError(msg);
726
- err.code = key;
727
- if (loc)
728
- err.loc = loc;
729
- context.onWarn(err);
730
- }
731
-
732
- const decodeRE = /&(gt|lt|amp|apos|quot);/g;
733
- const decodeMap = {
734
- gt: ">",
735
- lt: "<",
736
- amp: "&",
737
- apos: "'",
738
- quot: '"'
739
- };
740
1526
  const defaultParserOptions = {
1527
+ parseMode: "base",
1528
+ ns: 0,
741
1529
  delimiters: [`{{`, `}}`],
742
1530
  getNamespace: () => 0,
743
- getTextMode: () => 0,
744
1531
  isVoidTag: NO,
745
1532
  isPreTag: NO,
746
1533
  isCustomElement: NO,
747
- decodeEntities: (rawText) => rawText.replace(decodeRE, (_, p1) => decodeMap[p1]),
748
1534
  onError: defaultOnError,
749
1535
  onWarn: defaultOnWarn,
750
1536
  comments: !!(process.env.NODE_ENV !== "production")
751
1537
  };
752
- function baseParse(content, options = {}) {
753
- const context = createParserContext(content, options);
754
- const start = getCursor(context);
755
- return createRoot(
756
- parseChildren(context, 0, []),
757
- getSelection(context, start)
758
- );
759
- }
760
- function createParserContext(content, rawOptions) {
761
- const options = extend({}, defaultParserOptions);
762
- let key;
763
- for (key in rawOptions) {
764
- options[key] = rawOptions[key] === void 0 ? defaultParserOptions[key] : rawOptions[key];
765
- }
766
- return {
767
- options,
768
- column: 1,
769
- line: 1,
770
- offset: 0,
771
- originalSource: content,
772
- source: content,
773
- inPre: false,
774
- inVPre: false,
775
- onWarn: options.onWarn
776
- };
777
- }
778
- function parseChildren(context, mode, ancestors) {
779
- const parent = last(ancestors);
780
- const ns = parent ? parent.ns : 0;
781
- const nodes = [];
782
- while (!isEnd(context, mode, ancestors)) {
783
- const s = context.source;
784
- let node = void 0;
785
- if (mode === 0 || mode === 1) {
786
- if (!context.inVPre && startsWith(s, context.options.delimiters[0])) {
787
- node = parseInterpolation(context, mode);
788
- } else if (mode === 0 && s[0] === "<") {
789
- if (s.length === 1) {
790
- emitError(context, 5, 1);
791
- } else if (s[1] === "!") {
792
- if (startsWith(s, "<!--")) {
793
- node = parseComment(context);
794
- } else if (startsWith(s, "<!DOCTYPE")) {
795
- node = parseBogusComment(context);
796
- } else if (startsWith(s, "<![CDATA[")) {
797
- if (ns !== 0) {
798
- node = parseCDATA(context, ancestors);
799
- } else {
800
- emitError(context, 1);
801
- node = parseBogusComment(context);
802
- }
803
- } else {
804
- emitError(context, 11);
805
- node = parseBogusComment(context);
1538
+ let currentOptions = defaultParserOptions;
1539
+ let currentRoot = null;
1540
+ let currentInput = "";
1541
+ let currentOpenTag = null;
1542
+ let currentProp = null;
1543
+ let currentAttrValue = "";
1544
+ let currentAttrStartIndex = -1;
1545
+ let currentAttrEndIndex = -1;
1546
+ let inPre = 0;
1547
+ let inVPre = false;
1548
+ let currentVPreBoundary = null;
1549
+ const stack = [];
1550
+ const tokenizer = new Tokenizer(stack, {
1551
+ onerr: emitError,
1552
+ ontext(start, end) {
1553
+ onText(getSlice(start, end), start, end);
1554
+ },
1555
+ ontextentity(char, start, end) {
1556
+ onText(char, start, end);
1557
+ },
1558
+ oninterpolation(start, end) {
1559
+ if (inVPre) {
1560
+ return onText(getSlice(start, end), start, end);
1561
+ }
1562
+ let innerStart = start + tokenizer.delimiterOpen.length;
1563
+ let innerEnd = end - tokenizer.delimiterClose.length;
1564
+ while (isWhitespace(currentInput.charCodeAt(innerStart))) {
1565
+ innerStart++;
1566
+ }
1567
+ while (isWhitespace(currentInput.charCodeAt(innerEnd - 1))) {
1568
+ innerEnd--;
1569
+ }
1570
+ let exp = getSlice(innerStart, innerEnd);
1571
+ if (exp.includes("&")) {
1572
+ {
1573
+ exp = currentOptions.decodeEntities(exp, false);
1574
+ }
1575
+ }
1576
+ addNode({
1577
+ type: 5,
1578
+ content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
1579
+ loc: getLoc(start, end)
1580
+ });
1581
+ },
1582
+ onopentagname(start, end) {
1583
+ const name = getSlice(start, end);
1584
+ currentOpenTag = {
1585
+ type: 1,
1586
+ tag: name,
1587
+ ns: currentOptions.getNamespace(name, stack[0], currentOptions.ns),
1588
+ tagType: 0,
1589
+ // will be refined on tag close
1590
+ props: [],
1591
+ children: [],
1592
+ loc: getLoc(start - 1, end),
1593
+ codegenNode: void 0
1594
+ };
1595
+ if (tokenizer.inSFCRoot) {
1596
+ currentOpenTag.innerLoc = getLoc(
1597
+ end + fastForward(end) + 1,
1598
+ end
1599
+ );
1600
+ }
1601
+ },
1602
+ onopentagend(end) {
1603
+ endOpenTag(end);
1604
+ },
1605
+ onclosetag(start, end) {
1606
+ const name = getSlice(start, end);
1607
+ if (!currentOptions.isVoidTag(name)) {
1608
+ let found = false;
1609
+ for (let i = 0; i < stack.length; i++) {
1610
+ const e = stack[i];
1611
+ if (e.tag.toLowerCase() === name.toLowerCase()) {
1612
+ found = true;
1613
+ if (i > 0) {
1614
+ emitError(24, stack[0].loc.start.offset);
806
1615
  }
807
- } else if (s[1] === "/") {
808
- if (s.length === 2) {
809
- emitError(context, 5, 2);
810
- } else if (s[2] === ">") {
811
- emitError(context, 14, 2);
812
- advanceBy(context, 3);
813
- continue;
814
- } else if (/[a-z]/i.test(s[2])) {
815
- emitError(context, 23);
816
- parseTag(context, 1 /* End */, parent);
817
- continue;
818
- } else {
819
- emitError(
820
- context,
821
- 12,
822
- 2
823
- );
824
- node = parseBogusComment(context);
1616
+ for (let j = 0; j <= i; j++) {
1617
+ const el = stack.shift();
1618
+ onCloseTag(el, end, j < i);
825
1619
  }
826
- } else if (/[a-z]/i.test(s[1])) {
827
- node = parseElement(context, ancestors);
828
- if (isCompatEnabled(
829
- "COMPILER_NATIVE_TEMPLATE",
830
- context
831
- ) && node && node.tag === "template" && !node.props.some(
832
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
833
- )) {
834
- !!(process.env.NODE_ENV !== "production") && warnDeprecation(
835
- "COMPILER_NATIVE_TEMPLATE",
836
- context,
837
- node.loc
838
- );
839
- node = node.children;
1620
+ break;
1621
+ }
1622
+ }
1623
+ if (!found) {
1624
+ emitError(23, backTrack(start, 60));
1625
+ }
1626
+ }
1627
+ },
1628
+ onselfclosingtag(end) {
1629
+ var _a;
1630
+ const name = currentOpenTag.tag;
1631
+ currentOpenTag.isSelfClosing = true;
1632
+ endOpenTag(end);
1633
+ if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
1634
+ onCloseTag(stack.shift(), end);
1635
+ }
1636
+ },
1637
+ onattribname(start, end) {
1638
+ currentProp = {
1639
+ type: 6,
1640
+ name: getSlice(start, end),
1641
+ nameLoc: getLoc(start, end),
1642
+ value: void 0,
1643
+ loc: getLoc(start)
1644
+ };
1645
+ },
1646
+ ondirname(start, end) {
1647
+ const raw = getSlice(start, end);
1648
+ const name = raw === "." || raw === ":" ? "bind" : raw === "@" ? "on" : raw === "#" ? "slot" : raw.slice(2);
1649
+ if (!inVPre && name === "") {
1650
+ emitError(26, start);
1651
+ }
1652
+ if (inVPre || name === "") {
1653
+ currentProp = {
1654
+ type: 6,
1655
+ name: raw,
1656
+ nameLoc: getLoc(start, end),
1657
+ value: void 0,
1658
+ loc: getLoc(start)
1659
+ };
1660
+ } else {
1661
+ currentProp = {
1662
+ type: 7,
1663
+ name,
1664
+ rawName: raw,
1665
+ exp: void 0,
1666
+ arg: void 0,
1667
+ modifiers: raw === "." ? ["prop"] : [],
1668
+ loc: getLoc(start)
1669
+ };
1670
+ if (name === "pre") {
1671
+ inVPre = true;
1672
+ currentVPreBoundary = currentOpenTag;
1673
+ const props = currentOpenTag.props;
1674
+ for (let i = 0; i < props.length; i++) {
1675
+ if (props[i].type === 7) {
1676
+ props[i] = dirToAttr(props[i]);
840
1677
  }
841
- } else if (s[1] === "?") {
842
- emitError(
843
- context,
844
- 21,
845
- 1
846
- );
847
- node = parseBogusComment(context);
848
- } else {
849
- emitError(context, 12, 1);
850
1678
  }
851
1679
  }
852
1680
  }
853
- if (!node) {
854
- node = parseText(context, mode);
1681
+ },
1682
+ ondirarg(start, end) {
1683
+ if (start === end)
1684
+ return;
1685
+ const arg = getSlice(start, end);
1686
+ if (inVPre) {
1687
+ currentProp.name += arg;
1688
+ setLocEnd(currentProp.nameLoc, end);
1689
+ } else {
1690
+ const isStatic = arg[0] !== `[`;
1691
+ currentProp.arg = createSimpleExpression(
1692
+ isStatic ? arg : arg.slice(1, -1),
1693
+ isStatic,
1694
+ getLoc(start, end),
1695
+ isStatic ? 3 : 0
1696
+ );
855
1697
  }
856
- if (isArray(node)) {
857
- for (let i = 0; i < node.length; i++) {
858
- pushNode(nodes, node[i]);
1698
+ },
1699
+ ondirmodifier(start, end) {
1700
+ const mod = getSlice(start, end);
1701
+ if (inVPre) {
1702
+ currentProp.name += "." + mod;
1703
+ setLocEnd(currentProp.nameLoc, end);
1704
+ } else if (currentProp.name === "slot") {
1705
+ const arg = currentProp.arg;
1706
+ if (arg) {
1707
+ arg.content += "." + mod;
1708
+ setLocEnd(arg.loc, end);
859
1709
  }
860
1710
  } else {
861
- pushNode(nodes, node);
1711
+ currentProp.modifiers.push(mod);
862
1712
  }
863
- }
864
- let removedWhitespace = false;
865
- if (mode !== 2 && mode !== 1) {
866
- const shouldCondense = context.options.whitespace !== "preserve";
867
- for (let i = 0; i < nodes.length; i++) {
868
- const node = nodes[i];
869
- if (node.type === 2) {
870
- if (!context.inPre) {
871
- if (!/[^\t\r\n\f ]/.test(node.content)) {
872
- const prev = nodes[i - 1];
873
- const next = nodes[i + 1];
874
- if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
875
- removedWhitespace = true;
876
- nodes[i] = null;
877
- } else {
878
- node.content = " ";
879
- }
880
- } else if (shouldCondense) {
881
- node.content = node.content.replace(/[\t\r\n\f ]+/g, " ");
1713
+ },
1714
+ onattribdata(start, end) {
1715
+ currentAttrValue += getSlice(start, end);
1716
+ if (currentAttrStartIndex < 0)
1717
+ currentAttrStartIndex = start;
1718
+ currentAttrEndIndex = end;
1719
+ },
1720
+ onattribentity(char, start, end) {
1721
+ currentAttrValue += char;
1722
+ if (currentAttrStartIndex < 0)
1723
+ currentAttrStartIndex = start;
1724
+ currentAttrEndIndex = end;
1725
+ },
1726
+ onattribnameend(end) {
1727
+ const start = currentProp.loc.start.offset;
1728
+ const name = getSlice(start, end);
1729
+ if (currentProp.type === 7) {
1730
+ currentProp.rawName = name;
1731
+ }
1732
+ if (currentOpenTag.props.some(
1733
+ (p) => (p.type === 7 ? p.rawName : p.name) === name
1734
+ )) {
1735
+ emitError(2, start);
1736
+ }
1737
+ },
1738
+ onattribend(quote, end) {
1739
+ if (currentOpenTag && currentProp) {
1740
+ setLocEnd(currentProp.loc, end);
1741
+ if (quote !== 0) {
1742
+ if (currentAttrValue.includes("&")) {
1743
+ currentAttrValue = currentOptions.decodeEntities(
1744
+ currentAttrValue,
1745
+ true
1746
+ );
1747
+ }
1748
+ if (currentProp.type === 6) {
1749
+ if (currentProp.name === "class") {
1750
+ currentAttrValue = condense(currentAttrValue).trim();
1751
+ }
1752
+ if (quote === 1 && !currentAttrValue) {
1753
+ emitError(13, end);
1754
+ }
1755
+ currentProp.value = {
1756
+ type: 2,
1757
+ content: currentAttrValue,
1758
+ loc: quote === 1 ? getLoc(currentAttrStartIndex, currentAttrEndIndex) : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
1759
+ };
1760
+ if (tokenizer.inSFCRoot && currentOpenTag.tag === "template" && currentProp.name === "lang" && currentAttrValue && currentAttrValue !== "html") {
1761
+ tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
882
1762
  }
883
1763
  } else {
884
- node.content = node.content.replace(/\r\n/g, "\n");
1764
+ currentProp.exp = createSimpleExpression(
1765
+ currentAttrValue,
1766
+ false,
1767
+ getLoc(currentAttrStartIndex, currentAttrEndIndex)
1768
+ );
1769
+ if (currentProp.name === "for") {
1770
+ currentProp.forParseResult = parseForExpression(currentProp.exp);
1771
+ }
1772
+ let syncIndex = -1;
1773
+ if (currentProp.name === "bind" && (syncIndex = currentProp.modifiers.indexOf("sync")) > -1 && checkCompatEnabled(
1774
+ "COMPILER_V_BIND_SYNC",
1775
+ currentOptions,
1776
+ currentProp.loc,
1777
+ currentProp.rawName
1778
+ )) {
1779
+ currentProp.name = "model";
1780
+ currentProp.modifiers.splice(syncIndex, 1);
1781
+ }
885
1782
  }
886
- } else if (node.type === 3 && !context.options.comments) {
887
- removedWhitespace = true;
888
- nodes[i] = null;
889
1783
  }
1784
+ if (currentProp.type !== 7 || currentProp.name !== "pre") {
1785
+ currentOpenTag.props.push(currentProp);
1786
+ }
1787
+ }
1788
+ currentAttrValue = "";
1789
+ currentAttrStartIndex = currentAttrEndIndex = -1;
1790
+ },
1791
+ oncomment(start, end) {
1792
+ if (currentOptions.comments) {
1793
+ addNode({
1794
+ type: 3,
1795
+ content: getSlice(start, end),
1796
+ loc: getLoc(start - 4, end + 3)
1797
+ });
890
1798
  }
891
- if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
892
- const first = nodes[0];
893
- if (first && first.type === 2) {
894
- first.content = first.content.replace(/^\r?\n/, "");
1799
+ },
1800
+ onend() {
1801
+ const end = currentInput.length;
1802
+ if ((!!(process.env.NODE_ENV !== "production") || false) && tokenizer.state !== 1) {
1803
+ switch (tokenizer.state) {
1804
+ case 5:
1805
+ case 8:
1806
+ emitError(5, end);
1807
+ break;
1808
+ case 3:
1809
+ case 4:
1810
+ emitError(
1811
+ 25,
1812
+ tokenizer.sectionStart
1813
+ );
1814
+ break;
1815
+ case 28:
1816
+ if (tokenizer.currentSequence === Sequences.CdataEnd) {
1817
+ emitError(6, end);
1818
+ } else {
1819
+ emitError(7, end);
1820
+ }
1821
+ break;
1822
+ case 6:
1823
+ case 7:
1824
+ case 9:
1825
+ case 11:
1826
+ case 12:
1827
+ case 13:
1828
+ case 14:
1829
+ case 15:
1830
+ case 16:
1831
+ case 17:
1832
+ case 18:
1833
+ case 19:
1834
+ case 20:
1835
+ case 21:
1836
+ emitError(9, end);
1837
+ break;
895
1838
  }
896
1839
  }
1840
+ for (let index = 0; index < stack.length; index++) {
1841
+ onCloseTag(stack[index], end - 1);
1842
+ emitError(24, stack[index].loc.start.offset);
1843
+ }
1844
+ },
1845
+ oncdata(start, end) {
1846
+ if (stack[0].ns !== 0) {
1847
+ onText(getSlice(start, end), start, end);
1848
+ } else {
1849
+ emitError(1, start - 9);
1850
+ }
1851
+ },
1852
+ onprocessinginstruction(start) {
1853
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
1854
+ emitError(
1855
+ 21,
1856
+ start - 1
1857
+ );
1858
+ }
897
1859
  }
898
- return removedWhitespace ? nodes.filter(Boolean) : nodes;
1860
+ });
1861
+ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
1862
+ const stripParensRE = /^\(|\)$/g;
1863
+ function parseForExpression(input) {
1864
+ const loc = input.loc;
1865
+ const exp = input.content;
1866
+ const inMatch = exp.match(forAliasRE);
1867
+ if (!inMatch)
1868
+ return;
1869
+ const [, LHS, RHS] = inMatch;
1870
+ const createAliasExpression = (content, offset) => {
1871
+ const start = loc.start.offset + offset;
1872
+ const end = start + content.length;
1873
+ return createSimpleExpression(content, false, getLoc(start, end));
1874
+ };
1875
+ const result = {
1876
+ source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
1877
+ value: void 0,
1878
+ key: void 0,
1879
+ index: void 0,
1880
+ finalized: false
1881
+ };
1882
+ let valueContent = LHS.trim().replace(stripParensRE, "").trim();
1883
+ const trimmedOffset = LHS.indexOf(valueContent);
1884
+ const iteratorMatch = valueContent.match(forIteratorRE);
1885
+ if (iteratorMatch) {
1886
+ valueContent = valueContent.replace(forIteratorRE, "").trim();
1887
+ const keyContent = iteratorMatch[1].trim();
1888
+ let keyOffset;
1889
+ if (keyContent) {
1890
+ keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
1891
+ result.key = createAliasExpression(keyContent, keyOffset);
1892
+ }
1893
+ if (iteratorMatch[2]) {
1894
+ const indexContent = iteratorMatch[2].trim();
1895
+ if (indexContent) {
1896
+ result.index = createAliasExpression(
1897
+ indexContent,
1898
+ exp.indexOf(
1899
+ indexContent,
1900
+ result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
1901
+ )
1902
+ );
1903
+ }
1904
+ }
1905
+ }
1906
+ if (valueContent) {
1907
+ result.value = createAliasExpression(valueContent, trimmedOffset);
1908
+ }
1909
+ return result;
899
1910
  }
900
- function pushNode(nodes, node) {
901
- if (node.type === 2) {
902
- const prev = last(nodes);
903
- if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
904
- prev.content += node.content;
905
- prev.loc.end = node.loc.end;
906
- prev.loc.source += node.loc.source;
907
- return;
1911
+ function getSlice(start, end) {
1912
+ return currentInput.slice(start, end);
1913
+ }
1914
+ function endOpenTag(end) {
1915
+ addNode(currentOpenTag);
1916
+ const { tag, ns } = currentOpenTag;
1917
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
1918
+ inPre++;
1919
+ }
1920
+ if (currentOptions.isVoidTag(tag)) {
1921
+ onCloseTag(currentOpenTag, end);
1922
+ } else {
1923
+ stack.unshift(currentOpenTag);
1924
+ if (ns === 1 || ns === 2) {
1925
+ tokenizer.inXML = true;
908
1926
  }
909
1927
  }
910
- nodes.push(node);
1928
+ currentOpenTag = null;
911
1929
  }
912
- function parseCDATA(context, ancestors) {
913
- advanceBy(context, 9);
914
- const nodes = parseChildren(context, 3, ancestors);
915
- if (context.source.length === 0) {
916
- emitError(context, 6);
1930
+ function onText(content, start, end) {
1931
+ var _a;
1932
+ {
1933
+ const tag = (_a = stack[0]) == null ? void 0 : _a.tag;
1934
+ if (tag !== "script" && tag !== "style" && content.includes("&")) {
1935
+ content = currentOptions.decodeEntities(content, false);
1936
+ }
1937
+ }
1938
+ const parent = stack[0] || currentRoot;
1939
+ const lastNode = parent.children[parent.children.length - 1];
1940
+ if ((lastNode == null ? void 0 : lastNode.type) === 2) {
1941
+ lastNode.content += content;
1942
+ setLocEnd(lastNode.loc, end);
917
1943
  } else {
918
- advanceBy(context, 3);
1944
+ parent.children.push({
1945
+ type: 2,
1946
+ content,
1947
+ loc: getLoc(start, end)
1948
+ });
919
1949
  }
920
- return nodes;
921
1950
  }
922
- function parseComment(context) {
923
- const start = getCursor(context);
924
- let content;
925
- const match = /--(\!)?>/.exec(context.source);
926
- if (!match) {
927
- content = context.source.slice(4);
928
- advanceBy(context, context.source.length);
929
- emitError(context, 7);
1951
+ function onCloseTag(el, end, isImplied = false) {
1952
+ if (isImplied) {
1953
+ setLocEnd(el.loc, backTrack(end, 60));
930
1954
  } else {
931
- if (match.index <= 3) {
932
- emitError(context, 0);
933
- }
934
- if (match[1]) {
935
- emitError(context, 10);
1955
+ setLocEnd(el.loc, end + fastForward(end) + 1);
1956
+ }
1957
+ if (tokenizer.inSFCRoot) {
1958
+ if (el.children.length) {
1959
+ el.innerLoc.end = extend({}, el.children[el.children.length - 1].loc.end);
1960
+ } else {
1961
+ el.innerLoc.end = extend({}, el.innerLoc.start);
936
1962
  }
937
- content = context.source.slice(4, match.index);
938
- const s = context.source.slice(0, match.index);
939
- let prevIndex = 1, nestedIndex = 0;
940
- while ((nestedIndex = s.indexOf("<!--", prevIndex)) !== -1) {
941
- advanceBy(context, nestedIndex - prevIndex + 1);
942
- if (nestedIndex + 4 < s.length) {
943
- emitError(context, 16);
944
- }
945
- prevIndex = nestedIndex + 1;
1963
+ el.innerLoc.source = getSlice(
1964
+ el.innerLoc.start.offset,
1965
+ el.innerLoc.end.offset
1966
+ );
1967
+ }
1968
+ const { tag, ns } = el;
1969
+ if (!inVPre) {
1970
+ if (tag === "slot") {
1971
+ el.tagType = 2;
1972
+ } else if (isFragmentTemplate(el)) {
1973
+ el.tagType = 3;
1974
+ } else if (isComponent(el)) {
1975
+ el.tagType = 1;
946
1976
  }
947
- advanceBy(context, match.index + match[0].length - prevIndex + 1);
948
1977
  }
949
- return {
950
- type: 3,
951
- content,
952
- loc: getSelection(context, start)
953
- };
954
- }
955
- function parseBogusComment(context) {
956
- const start = getCursor(context);
957
- const contentStart = context.source[1] === "?" ? 1 : 2;
958
- let content;
959
- const closeIndex = context.source.indexOf(">");
960
- if (closeIndex === -1) {
961
- content = context.source.slice(contentStart);
962
- advanceBy(context, context.source.length);
963
- } else {
964
- content = context.source.slice(contentStart, closeIndex);
965
- advanceBy(context, closeIndex + 1);
1978
+ if (!tokenizer.inRCDATA) {
1979
+ el.children = condenseWhitespace(el.children, el.tag);
1980
+ }
1981
+ if (ns === 0 && currentOptions.isPreTag(tag)) {
1982
+ inPre--;
1983
+ }
1984
+ if (currentVPreBoundary === el) {
1985
+ inVPre = false;
1986
+ currentVPreBoundary = null;
1987
+ }
1988
+ if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
1989
+ tokenizer.inXML = false;
966
1990
  }
967
- return {
968
- type: 3,
969
- content,
970
- loc: getSelection(context, start)
971
- };
972
- }
973
- function parseElement(context, ancestors) {
974
- const wasInPre = context.inPre;
975
- const wasInVPre = context.inVPre;
976
- const parent = last(ancestors);
977
- const element = parseTag(context, 0 /* Start */, parent);
978
- const isPreBoundary = context.inPre && !wasInPre;
979
- const isVPreBoundary = context.inVPre && !wasInVPre;
980
- if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
981
- if (isPreBoundary) {
982
- context.inPre = false;
983
- }
984
- if (isVPreBoundary) {
985
- context.inVPre = false;
986
- }
987
- return element;
988
- }
989
- ancestors.push(element);
990
- const mode = context.options.getTextMode(element, parent);
991
- const children = parseChildren(context, mode, ancestors);
992
- ancestors.pop();
993
1991
  {
994
- const inlineTemplateProp = element.props.find(
1992
+ const props = el.props;
1993
+ if (!!(process.env.NODE_ENV !== "production") && isCompatEnabled(
1994
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
1995
+ currentOptions
1996
+ )) {
1997
+ let hasIf = false;
1998
+ let hasFor = false;
1999
+ for (let i = 0; i < props.length; i++) {
2000
+ const p = props[i];
2001
+ if (p.type === 7) {
2002
+ if (p.name === "if") {
2003
+ hasIf = true;
2004
+ } else if (p.name === "for") {
2005
+ hasFor = true;
2006
+ }
2007
+ }
2008
+ if (hasIf && hasFor) {
2009
+ warnDeprecation(
2010
+ "COMPILER_V_IF_V_FOR_PRECEDENCE",
2011
+ currentOptions,
2012
+ el.loc
2013
+ );
2014
+ break;
2015
+ }
2016
+ }
2017
+ }
2018
+ if (isCompatEnabled(
2019
+ "COMPILER_NATIVE_TEMPLATE",
2020
+ currentOptions
2021
+ ) && el.tag === "template" && !isFragmentTemplate(el)) {
2022
+ !!(process.env.NODE_ENV !== "production") && warnDeprecation(
2023
+ "COMPILER_NATIVE_TEMPLATE",
2024
+ currentOptions,
2025
+ el.loc
2026
+ );
2027
+ const parent = stack[0] || currentRoot;
2028
+ const index = parent.children.indexOf(el);
2029
+ parent.children.splice(index, 1, ...el.children);
2030
+ }
2031
+ const inlineTemplateProp = props.find(
995
2032
  (p) => p.type === 6 && p.name === "inline-template"
996
2033
  );
997
2034
  if (inlineTemplateProp && checkCompatEnabled(
998
2035
  "COMPILER_INLINE_TEMPLATE",
999
- context,
2036
+ currentOptions,
1000
2037
  inlineTemplateProp.loc
1001
- )) {
1002
- const loc = getSelection(context, element.loc.end);
2038
+ ) && el.children.length) {
1003
2039
  inlineTemplateProp.value = {
1004
2040
  type: 2,
1005
- content: loc.source,
1006
- loc
2041
+ content: getSlice(
2042
+ el.children[0].loc.start.offset,
2043
+ el.children[el.children.length - 1].loc.end.offset
2044
+ ),
2045
+ loc: inlineTemplateProp.loc
1007
2046
  };
1008
2047
  }
1009
2048
  }
1010
- element.children = children;
1011
- if (startsWithEndTagOpen(context.source, element.tag)) {
1012
- parseTag(context, 1 /* End */, parent);
1013
- } else {
1014
- emitError(context, 24, 0, element.loc.start);
1015
- if (context.source.length === 0 && element.tag.toLowerCase() === "script") {
1016
- const first = children[0];
1017
- if (first && startsWith(first.loc.source, "<!--")) {
1018
- emitError(context, 8);
1019
- }
1020
- }
1021
- }
1022
- element.loc = getSelection(context, element.loc.start);
1023
- if (isPreBoundary) {
1024
- context.inPre = false;
1025
- }
1026
- if (isVPreBoundary) {
1027
- context.inVPre = false;
1028
- }
1029
- return element;
1030
2049
  }
1031
- const isSpecialTemplateDirective = /* @__PURE__ */ makeMap(
1032
- `if,else,else-if,for,slot`
1033
- );
1034
- function parseTag(context, type, parent) {
1035
- const start = getCursor(context);
1036
- const match = /^<\/?([a-z][^\t\r\n\f />]*)/i.exec(context.source);
1037
- const tag = match[1];
1038
- const ns = context.options.getNamespace(tag, parent);
1039
- advanceBy(context, match[0].length);
1040
- advanceSpaces(context);
1041
- const cursor = getCursor(context);
1042
- const currentSource = context.source;
1043
- if (context.options.isPreTag(tag)) {
1044
- context.inPre = true;
1045
- }
1046
- let props = parseAttributes(context, type);
1047
- if (type === 0 /* Start */ && !context.inVPre && props.some((p) => p.type === 7 && p.name === "pre")) {
1048
- context.inVPre = true;
1049
- extend(context, cursor);
1050
- context.source = currentSource;
1051
- props = parseAttributes(context, type).filter((p) => p.name !== "v-pre");
1052
- }
1053
- let isSelfClosing = false;
1054
- if (context.source.length === 0) {
1055
- emitError(context, 9);
1056
- } else {
1057
- isSelfClosing = startsWith(context.source, "/>");
1058
- if (type === 1 /* End */ && isSelfClosing) {
1059
- emitError(context, 4);
1060
- }
1061
- advanceBy(context, isSelfClosing ? 2 : 1);
1062
- }
1063
- if (type === 1 /* End */) {
1064
- return;
2050
+ function fastForward(start, c) {
2051
+ let offset = 0;
2052
+ while (currentInput.charCodeAt(start + offset) !== 62 && start + offset < currentInput.length) {
2053
+ offset++;
1065
2054
  }
1066
- if (!!(process.env.NODE_ENV !== "production") && isCompatEnabled(
1067
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
1068
- context
1069
- )) {
1070
- let hasIf = false;
1071
- let hasFor = false;
2055
+ return offset;
2056
+ }
2057
+ function backTrack(index, c) {
2058
+ let i = index;
2059
+ while (currentInput.charCodeAt(i) !== c && i >= 0)
2060
+ i--;
2061
+ return i;
2062
+ }
2063
+ const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
2064
+ function isFragmentTemplate({ tag, props }) {
2065
+ if (tag === "template") {
1072
2066
  for (let i = 0; i < props.length; i++) {
1073
- const p = props[i];
1074
- if (p.type === 7) {
1075
- if (p.name === "if") {
1076
- hasIf = true;
1077
- } else if (p.name === "for") {
1078
- hasFor = true;
1079
- }
1080
- }
1081
- if (hasIf && hasFor) {
1082
- warnDeprecation(
1083
- "COMPILER_V_IF_V_FOR_PRECEDENCE",
1084
- context,
1085
- getSelection(context, start)
1086
- );
1087
- break;
1088
- }
1089
- }
1090
- }
1091
- let tagType = 0;
1092
- if (!context.inVPre) {
1093
- if (tag === "slot") {
1094
- tagType = 2;
1095
- } else if (tag === "template") {
1096
- if (props.some(
1097
- (p) => p.type === 7 && isSpecialTemplateDirective(p.name)
1098
- )) {
1099
- tagType = 3;
2067
+ if (props[i].type === 7 && specialTemplateDir.has(props[i].name)) {
2068
+ return true;
1100
2069
  }
1101
- } else if (isComponent(tag, props, context)) {
1102
- tagType = 1;
1103
2070
  }
1104
2071
  }
1105
- return {
1106
- type: 1,
1107
- ns,
1108
- tag,
1109
- tagType,
1110
- props,
1111
- isSelfClosing,
1112
- children: [],
1113
- loc: getSelection(context, start),
1114
- codegenNode: void 0
1115
- // to be created during transform phase
1116
- };
2072
+ return false;
1117
2073
  }
1118
- function isComponent(tag, props, context) {
1119
- const options = context.options;
1120
- if (options.isCustomElement(tag)) {
2074
+ function isComponent({ tag, props }) {
2075
+ var _a;
2076
+ if (currentOptions.isCustomElement(tag)) {
1121
2077
  return false;
1122
2078
  }
1123
- if (tag === "component" || /^[A-Z]/.test(tag) || isCoreComponent(tag) || options.isBuiltInComponent && options.isBuiltInComponent(tag) || options.isNativeTag && !options.isNativeTag(tag)) {
2079
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
1124
2080
  return true;
1125
2081
  }
1126
2082
  for (let i = 0; i < props.length; i++) {
@@ -1131,374 +2087,179 @@ function isComponent(tag, props, context) {
1131
2087
  return true;
1132
2088
  } else if (checkCompatEnabled(
1133
2089
  "COMPILER_IS_ON_ELEMENT",
1134
- context,
2090
+ currentOptions,
1135
2091
  p.loc
1136
2092
  )) {
1137
2093
  return true;
1138
2094
  }
1139
2095
  }
1140
- } else {
1141
- if (p.name === "is") {
1142
- return true;
1143
- } else if (
1144
- // :is on plain element - only treat as component in compat mode
1145
- p.name === "bind" && isStaticArgOf(p.arg, "is") && true && checkCompatEnabled(
1146
- "COMPILER_IS_ON_ELEMENT",
1147
- context,
1148
- p.loc
1149
- )
1150
- ) {
1151
- return true;
1152
- }
2096
+ } else if (// :is on plain element - only treat as component in compat mode
2097
+ p.name === "bind" && isStaticArgOf(p.arg, "is") && checkCompatEnabled(
2098
+ "COMPILER_IS_ON_ELEMENT",
2099
+ currentOptions,
2100
+ p.loc
2101
+ )) {
2102
+ return true;
1153
2103
  }
1154
2104
  }
2105
+ return false;
1155
2106
  }
1156
- function parseAttributes(context, type) {
1157
- const props = [];
1158
- const attributeNames = /* @__PURE__ */ new Set();
1159
- while (context.source.length > 0 && !startsWith(context.source, ">") && !startsWith(context.source, "/>")) {
1160
- if (startsWith(context.source, "/")) {
1161
- emitError(context, 22);
1162
- advanceBy(context, 1);
1163
- advanceSpaces(context);
1164
- continue;
1165
- }
1166
- if (type === 1 /* End */) {
1167
- emitError(context, 3);
1168
- }
1169
- const attr = parseAttribute(context, attributeNames);
1170
- if (attr.type === 6 && attr.value && attr.name === "class") {
1171
- attr.value.content = attr.value.content.replace(/\s+/g, " ").trim();
1172
- }
1173
- if (type === 0 /* Start */) {
1174
- props.push(attr);
1175
- }
1176
- if (/^[^\t\r\n\f />]/.test(context.source)) {
1177
- emitError(context, 15);
1178
- }
1179
- advanceSpaces(context);
1180
- }
1181
- return props;
2107
+ function isUpperCase(c) {
2108
+ return c > 64 && c < 91;
1182
2109
  }
1183
- function parseAttribute(context, nameSet) {
1184
- var _a;
1185
- const start = getCursor(context);
1186
- const match = /^[^\t\r\n\f />][^\t\r\n\f />=]*/.exec(context.source);
1187
- const name = match[0];
1188
- if (nameSet.has(name)) {
1189
- emitError(context, 2);
1190
- }
1191
- nameSet.add(name);
1192
- if (name[0] === "=") {
1193
- emitError(context, 19);
1194
- }
1195
- {
1196
- const pattern = /["'<]/g;
1197
- let m;
1198
- while (m = pattern.exec(name)) {
1199
- emitError(
1200
- context,
1201
- 17,
1202
- m.index
1203
- );
1204
- }
1205
- }
1206
- advanceBy(context, name.length);
1207
- let value = void 0;
1208
- if (/^[\t\r\n\f ]*=/.test(context.source)) {
1209
- advanceSpaces(context);
1210
- advanceBy(context, 1);
1211
- advanceSpaces(context);
1212
- value = parseAttributeValue(context);
1213
- if (!value) {
1214
- emitError(context, 13);
1215
- }
1216
- }
1217
- const loc = getSelection(context, start);
1218
- if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
1219
- const match2 = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
1220
- name
1221
- );
1222
- let isPropShorthand = startsWith(name, ".");
1223
- let dirName = match2[1] || (isPropShorthand || startsWith(name, ":") ? "bind" : startsWith(name, "@") ? "on" : "slot");
1224
- let arg;
1225
- if (match2[2]) {
1226
- const isSlot = dirName === "slot";
1227
- const startOffset = name.lastIndexOf(
1228
- match2[2],
1229
- name.length - (((_a = match2[3]) == null ? void 0 : _a.length) || 0)
1230
- );
1231
- const loc2 = getSelection(
1232
- context,
1233
- getNewPosition(context, start, startOffset),
1234
- getNewPosition(
1235
- context,
1236
- start,
1237
- startOffset + match2[2].length + (isSlot && match2[3] || "").length
1238
- )
1239
- );
1240
- let content = match2[2];
1241
- let isStatic = true;
1242
- if (content.startsWith("[")) {
1243
- isStatic = false;
1244
- if (!content.endsWith("]")) {
1245
- emitError(
1246
- context,
1247
- 27
1248
- );
1249
- content = content.slice(1);
1250
- } else {
1251
- content = content.slice(1, content.length - 1);
2110
+ const windowsNewlineRE = /\r\n/g;
2111
+ function condenseWhitespace(nodes, tag) {
2112
+ var _a, _b;
2113
+ const shouldCondense = currentOptions.whitespace !== "preserve";
2114
+ let removedWhitespace = false;
2115
+ for (let i = 0; i < nodes.length; i++) {
2116
+ const node = nodes[i];
2117
+ if (node.type === 2) {
2118
+ if (!inPre) {
2119
+ if (isAllWhitespace(node.content)) {
2120
+ const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
2121
+ const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
2122
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2123
+ removedWhitespace = true;
2124
+ nodes[i] = null;
2125
+ } else {
2126
+ node.content = " ";
2127
+ }
2128
+ } else if (shouldCondense) {
2129
+ node.content = condense(node.content);
1252
2130
  }
1253
- } else if (isSlot) {
1254
- content += match2[3] || "";
1255
- }
1256
- arg = {
1257
- type: 4,
1258
- content,
1259
- isStatic,
1260
- constType: isStatic ? 3 : 0,
1261
- loc: loc2
1262
- };
1263
- }
1264
- if (value && value.isQuoted) {
1265
- const valueLoc = value.loc;
1266
- valueLoc.start.offset++;
1267
- valueLoc.start.column++;
1268
- valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
1269
- valueLoc.source = valueLoc.source.slice(1, -1);
1270
- }
1271
- const modifiers = match2[3] ? match2[3].slice(1).split(".") : [];
1272
- if (isPropShorthand)
1273
- modifiers.push("prop");
1274
- if (dirName === "bind" && arg) {
1275
- if (modifiers.includes("sync") && checkCompatEnabled(
1276
- "COMPILER_V_BIND_SYNC",
1277
- context,
1278
- loc,
1279
- arg.loc.source
1280
- )) {
1281
- dirName = "model";
1282
- modifiers.splice(modifiers.indexOf("sync"), 1);
1283
- }
1284
- if (!!(process.env.NODE_ENV !== "production") && modifiers.includes("prop")) {
1285
- checkCompatEnabled(
1286
- "COMPILER_V_BIND_PROP",
1287
- context,
1288
- loc
1289
- );
2131
+ } else {
2132
+ node.content = node.content.replace(windowsNewlineRE, "\n");
1290
2133
  }
1291
2134
  }
1292
- return {
1293
- type: 7,
1294
- name: dirName,
1295
- exp: value && {
1296
- type: 4,
1297
- content: value.content,
1298
- isStatic: false,
1299
- // Treat as non-constant by default. This can be potentially set to
1300
- // other values by `transformExpression` to make it eligible for hoisting.
1301
- constType: 0,
1302
- loc: value.loc
1303
- },
1304
- arg,
1305
- modifiers,
1306
- loc
1307
- };
1308
2135
  }
1309
- if (!context.inVPre && startsWith(name, "v-")) {
1310
- emitError(context, 26);
2136
+ if (inPre && tag && currentOptions.isPreTag(tag)) {
2137
+ const first = nodes[0];
2138
+ if (first && first.type === 2) {
2139
+ first.content = first.content.replace(/^\r?\n/, "");
2140
+ }
1311
2141
  }
1312
- return {
1313
- type: 6,
1314
- name,
1315
- value: value && {
1316
- type: 2,
1317
- content: value.content,
1318
- loc: value.loc
1319
- },
1320
- loc
1321
- };
2142
+ return removedWhitespace ? nodes.filter(Boolean) : nodes;
1322
2143
  }
1323
- function parseAttributeValue(context) {
1324
- const start = getCursor(context);
1325
- let content;
1326
- const quote = context.source[0];
1327
- const isQuoted = quote === `"` || quote === `'`;
1328
- if (isQuoted) {
1329
- advanceBy(context, 1);
1330
- const endIndex = context.source.indexOf(quote);
1331
- if (endIndex === -1) {
1332
- content = parseTextData(
1333
- context,
1334
- context.source.length,
1335
- 4
1336
- );
1337
- } else {
1338
- content = parseTextData(context, endIndex, 4);
1339
- advanceBy(context, 1);
1340
- }
1341
- } else {
1342
- const match = /^[^\t\r\n\f >]+/.exec(context.source);
1343
- if (!match) {
1344
- return void 0;
1345
- }
1346
- const unexpectedChars = /["'<=`]/g;
1347
- let m;
1348
- while (m = unexpectedChars.exec(match[0])) {
1349
- emitError(
1350
- context,
1351
- 18,
1352
- m.index
1353
- );
2144
+ function isAllWhitespace(str) {
2145
+ for (let i = 0; i < str.length; i++) {
2146
+ if (!isWhitespace(str.charCodeAt(i))) {
2147
+ return false;
1354
2148
  }
1355
- content = parseTextData(context, match[0].length, 4);
1356
- }
1357
- return { content, isQuoted, loc: getSelection(context, start) };
1358
- }
1359
- function parseInterpolation(context, mode) {
1360
- const [open, close] = context.options.delimiters;
1361
- const closeIndex = context.source.indexOf(close, open.length);
1362
- if (closeIndex === -1) {
1363
- emitError(context, 25);
1364
- return void 0;
1365
- }
1366
- const start = getCursor(context);
1367
- advanceBy(context, open.length);
1368
- const innerStart = getCursor(context);
1369
- const innerEnd = getCursor(context);
1370
- const rawContentLength = closeIndex - open.length;
1371
- const rawContent = context.source.slice(0, rawContentLength);
1372
- const preTrimContent = parseTextData(context, rawContentLength, mode);
1373
- const content = preTrimContent.trim();
1374
- const startOffset = preTrimContent.indexOf(content);
1375
- if (startOffset > 0) {
1376
- advancePositionWithMutation(innerStart, rawContent, startOffset);
1377
- }
1378
- const endOffset = rawContentLength - (preTrimContent.length - content.length - startOffset);
1379
- advancePositionWithMutation(innerEnd, rawContent, endOffset);
1380
- advanceBy(context, close.length);
1381
- return {
1382
- type: 5,
1383
- content: {
1384
- type: 4,
1385
- isStatic: false,
1386
- // Set `isConstant` to false by default and will decide in transformExpression
1387
- constType: 0,
1388
- content,
1389
- loc: getSelection(context, innerStart, innerEnd)
1390
- },
1391
- loc: getSelection(context, start)
1392
- };
2149
+ }
2150
+ return true;
1393
2151
  }
1394
- function parseText(context, mode) {
1395
- const endTokens = mode === 3 ? ["]]>"] : ["<", context.options.delimiters[0]];
1396
- let endIndex = context.source.length;
1397
- for (let i = 0; i < endTokens.length; i++) {
1398
- const index = context.source.indexOf(endTokens[i], 1);
1399
- if (index !== -1 && endIndex > index) {
1400
- endIndex = index;
2152
+ function hasNewlineChar(str) {
2153
+ for (let i = 0; i < str.length; i++) {
2154
+ const c = str.charCodeAt(i);
2155
+ if (c === 10 || c === 13) {
2156
+ return true;
1401
2157
  }
1402
2158
  }
1403
- const start = getCursor(context);
1404
- const content = parseTextData(context, endIndex, mode);
1405
- return {
1406
- type: 2,
1407
- content,
1408
- loc: getSelection(context, start)
1409
- };
2159
+ return false;
1410
2160
  }
1411
- function parseTextData(context, length, mode) {
1412
- const rawText = context.source.slice(0, length);
1413
- advanceBy(context, length);
1414
- if (mode === 2 || mode === 3 || !rawText.includes("&")) {
1415
- return rawText;
1416
- } else {
1417
- return context.options.decodeEntities(
1418
- rawText,
1419
- mode === 4
1420
- );
2161
+ function condense(str) {
2162
+ let ret = "";
2163
+ let prevCharIsWhitespace = false;
2164
+ for (let i = 0; i < str.length; i++) {
2165
+ if (isWhitespace(str.charCodeAt(i))) {
2166
+ if (!prevCharIsWhitespace) {
2167
+ ret += " ";
2168
+ prevCharIsWhitespace = true;
2169
+ }
2170
+ } else {
2171
+ ret += str[i];
2172
+ prevCharIsWhitespace = false;
2173
+ }
1421
2174
  }
2175
+ return ret;
1422
2176
  }
1423
- function getCursor(context) {
1424
- const { column, line, offset } = context;
1425
- return { column, line, offset };
2177
+ function addNode(node) {
2178
+ (stack[0] || currentRoot).children.push(node);
1426
2179
  }
1427
- function getSelection(context, start, end) {
1428
- end = end || getCursor(context);
2180
+ function getLoc(start, end) {
1429
2181
  return {
1430
- start,
1431
- end,
1432
- source: context.originalSource.slice(start.offset, end.offset)
2182
+ start: tokenizer.getPos(start),
2183
+ // @ts-expect-error allow late attachment
2184
+ end: end == null ? end : tokenizer.getPos(end),
2185
+ // @ts-expect-error allow late attachment
2186
+ source: end == null ? end : getSlice(start, end)
1433
2187
  };
1434
2188
  }
1435
- function last(xs) {
1436
- return xs[xs.length - 1];
1437
- }
1438
- function startsWith(source, searchString) {
1439
- return source.startsWith(searchString);
2189
+ function setLocEnd(loc, end) {
2190
+ loc.end = tokenizer.getPos(end);
2191
+ loc.source = getSlice(loc.start.offset, end);
1440
2192
  }
1441
- function advanceBy(context, numberOfCharacters) {
1442
- const { source } = context;
1443
- advancePositionWithMutation(context, source, numberOfCharacters);
1444
- context.source = source.slice(numberOfCharacters);
1445
- }
1446
- function advanceSpaces(context) {
1447
- const match = /^[\t\r\n\f ]+/.exec(context.source);
1448
- if (match) {
1449
- advanceBy(context, match[0].length);
1450
- }
1451
- }
1452
- function getNewPosition(context, start, numberOfCharacters) {
1453
- return advancePositionWithClone(
1454
- start,
1455
- context.originalSource.slice(start.offset, numberOfCharacters),
1456
- numberOfCharacters
1457
- );
1458
- }
1459
- function emitError(context, code, offset, loc = getCursor(context)) {
1460
- if (offset) {
1461
- loc.offset += offset;
1462
- loc.column += offset;
2193
+ function dirToAttr(dir) {
2194
+ const attr = {
2195
+ type: 6,
2196
+ name: dir.rawName,
2197
+ nameLoc: getLoc(
2198
+ dir.loc.start.offset,
2199
+ dir.loc.start.offset + dir.rawName.length
2200
+ ),
2201
+ value: void 0,
2202
+ loc: dir.loc
2203
+ };
2204
+ if (dir.exp) {
2205
+ const loc = dir.exp.loc;
2206
+ if (loc.end.offset < dir.loc.end.offset) {
2207
+ loc.start.offset--;
2208
+ loc.start.column--;
2209
+ loc.end.offset++;
2210
+ loc.end.column++;
2211
+ }
2212
+ attr.value = {
2213
+ type: 2,
2214
+ content: dir.exp.content,
2215
+ loc
2216
+ };
1463
2217
  }
1464
- context.options.onError(
1465
- createCompilerError(code, {
1466
- start: loc,
1467
- end: loc,
1468
- source: ""
1469
- })
1470
- );
1471
- }
1472
- function isEnd(context, mode, ancestors) {
1473
- const s = context.source;
1474
- switch (mode) {
1475
- case 0:
1476
- if (startsWith(s, "</")) {
1477
- for (let i = ancestors.length - 1; i >= 0; --i) {
1478
- if (startsWithEndTagOpen(s, ancestors[i].tag)) {
1479
- return true;
1480
- }
1481
- }
1482
- }
1483
- break;
1484
- case 1:
1485
- case 2: {
1486
- const parent = last(ancestors);
1487
- if (parent && startsWithEndTagOpen(s, parent.tag)) {
1488
- return true;
2218
+ return attr;
2219
+ }
2220
+ function emitError(code, index) {
2221
+ currentOptions.onError(createCompilerError(code, getLoc(index, index)));
2222
+ }
2223
+ function reset() {
2224
+ tokenizer.reset();
2225
+ currentOpenTag = null;
2226
+ currentProp = null;
2227
+ currentAttrValue = "";
2228
+ currentAttrStartIndex = -1;
2229
+ currentAttrEndIndex = -1;
2230
+ stack.length = 0;
2231
+ }
2232
+ function baseParse(input, options) {
2233
+ reset();
2234
+ currentInput = input;
2235
+ currentOptions = extend({}, defaultParserOptions);
2236
+ if (options) {
2237
+ let key;
2238
+ for (key in options) {
2239
+ if (options[key] != null) {
2240
+ currentOptions[key] = options[key];
1489
2241
  }
1490
- break;
1491
2242
  }
1492
- case 3:
1493
- if (startsWith(s, "]]>")) {
1494
- return true;
1495
- }
1496
- break;
1497
2243
  }
1498
- return !s;
1499
- }
1500
- function startsWithEndTagOpen(source, tag) {
1501
- return startsWith(source, "</") && source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() && /[\t\r\n\f />]/.test(source[2 + tag.length] || ">");
2244
+ if (!!(process.env.NODE_ENV !== "production")) {
2245
+ if (!currentOptions.decodeEntities) {
2246
+ throw new Error(
2247
+ `[@vue/compiler-core] decodeEntities option is required in browser builds.`
2248
+ );
2249
+ }
2250
+ }
2251
+ tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2252
+ const delimiters = options == null ? void 0 : options.delimiters;
2253
+ if (delimiters) {
2254
+ tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
2255
+ tokenizer.delimiterClose = toCharCodes(delimiters[1]);
2256
+ }
2257
+ const root = currentRoot = createRoot([], input);
2258
+ tokenizer.parse(currentInput);
2259
+ root.loc = getLoc(0, input.length);
2260
+ root.children = condenseWhitespace(root.children);
2261
+ currentRoot = null;
2262
+ return root;
1502
2263
  }
1503
2264
 
1504
2265
  function hoistStatic(root, context) {
@@ -1911,6 +2672,7 @@ function transform(root, options) {
1911
2672
  root.hoists = context.hoists;
1912
2673
  root.temps = context.temps;
1913
2674
  root.cached = context.cached;
2675
+ root.transformed = true;
1914
2676
  {
1915
2677
  root.filters = [...context.filters];
1916
2678
  }
@@ -2067,7 +2829,7 @@ function createCodegenContext(ast, {
2067
2829
  ssr,
2068
2830
  isTS,
2069
2831
  inSSR,
2070
- source: ast.loc.source,
2832
+ source: ast.source,
2071
2833
  code: ``,
2072
2834
  column: 1,
2073
2835
  line: 1,
@@ -2078,7 +2840,7 @@ function createCodegenContext(ast, {
2078
2840
  helper(key) {
2079
2841
  return `_${helperNameMap[key]}`;
2080
2842
  },
2081
- push(code, node) {
2843
+ push(code, newlineIndex = -2 /* None */, node) {
2082
2844
  context.code += code;
2083
2845
  },
2084
2846
  indent() {
@@ -2096,7 +2858,7 @@ function createCodegenContext(ast, {
2096
2858
  }
2097
2859
  };
2098
2860
  function newline(n) {
2099
- context.push("\n" + ` `.repeat(n));
2861
+ context.push("\n" + ` `.repeat(n), 0 /* Start */);
2100
2862
  }
2101
2863
  return context;
2102
2864
  }
@@ -2133,9 +2895,11 @@ function generate(ast, options = {}) {
2133
2895
  push(`with (_ctx) {`);
2134
2896
  indent();
2135
2897
  if (hasHelpers) {
2136
- push(`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue`);
2137
- push(`
2138
- `);
2898
+ push(
2899
+ `const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
2900
+ `,
2901
+ -1 /* End */
2902
+ );
2139
2903
  newline();
2140
2904
  }
2141
2905
  }
@@ -2164,7 +2928,7 @@ function generate(ast, options = {}) {
2164
2928
  }
2165
2929
  if (ast.components.length || ast.directives.length || ast.temps) {
2166
2930
  push(`
2167
- `);
2931
+ `, 0 /* Start */);
2168
2932
  newline();
2169
2933
  }
2170
2934
  if (!ssr) {
@@ -2185,7 +2949,6 @@ function generate(ast, options = {}) {
2185
2949
  ast,
2186
2950
  code: context.code,
2187
2951
  preamble: isSetupInlined ? preambleContext.code : ``,
2188
- // SourceMapGenerator does have toJSON() method but it's not in the types
2189
2952
  map: context.map ? context.map.toJSON() : void 0
2190
2953
  };
2191
2954
  }
@@ -2204,7 +2967,7 @@ function genFunctionPreamble(ast, context) {
2204
2967
  if (helpers.length > 0) {
2205
2968
  {
2206
2969
  push(`const _Vue = ${VueBinding}
2207
- `);
2970
+ `, -1 /* End */);
2208
2971
  if (ast.hoists.length) {
2209
2972
  const staticHelpers = [
2210
2973
  CREATE_VNODE,
@@ -2214,7 +2977,7 @@ function genFunctionPreamble(ast, context) {
2214
2977
  CREATE_STATIC
2215
2978
  ].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
2216
2979
  push(`const { ${staticHelpers} } = _Vue
2217
- `);
2980
+ `, -1 /* End */);
2218
2981
  }
2219
2982
  }
2220
2983
  }
@@ -2275,7 +3038,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2275
3038
  for (let i = 0; i < nodes.length; i++) {
2276
3039
  const node = nodes[i];
2277
3040
  if (isString(node)) {
2278
- push(node);
3041
+ push(node, -3 /* Unknown */);
2279
3042
  } else if (isArray(node)) {
2280
3043
  genNodeListAsArray(node, context);
2281
3044
  } else {
@@ -2293,7 +3056,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2293
3056
  }
2294
3057
  function genNode(node, context) {
2295
3058
  if (isString(node)) {
2296
- context.push(node);
3059
+ context.push(node, -3 /* Unknown */);
2297
3060
  return;
2298
3061
  }
2299
3062
  if (isSymbol(node)) {
@@ -2373,11 +3136,15 @@ function genNode(node, context) {
2373
3136
  }
2374
3137
  }
2375
3138
  function genText(node, context) {
2376
- context.push(JSON.stringify(node.content), node);
3139
+ context.push(JSON.stringify(node.content), -3 /* Unknown */, node);
2377
3140
  }
2378
3141
  function genExpression(node, context) {
2379
3142
  const { content, isStatic } = node;
2380
- context.push(isStatic ? JSON.stringify(content) : content, node);
3143
+ context.push(
3144
+ isStatic ? JSON.stringify(content) : content,
3145
+ -3 /* Unknown */,
3146
+ node
3147
+ );
2381
3148
  }
2382
3149
  function genInterpolation(node, context) {
2383
3150
  const { push, helper, pure } = context;
@@ -2391,7 +3158,7 @@ function genCompoundExpression(node, context) {
2391
3158
  for (let i = 0; i < node.children.length; i++) {
2392
3159
  const child = node.children[i];
2393
3160
  if (isString(child)) {
2394
- context.push(child);
3161
+ context.push(child, -3 /* Unknown */);
2395
3162
  } else {
2396
3163
  genNode(child, context);
2397
3164
  }
@@ -2405,9 +3172,9 @@ function genExpressionAsPropertyKey(node, context) {
2405
3172
  push(`]`);
2406
3173
  } else if (node.isStatic) {
2407
3174
  const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
2408
- push(text, node);
3175
+ push(text, -2 /* None */, node);
2409
3176
  } else {
2410
- push(`[${node.content}]`, node);
3177
+ push(`[${node.content}]`, -3 /* Unknown */, node);
2411
3178
  }
2412
3179
  }
2413
3180
  function genComment(node, context) {
@@ -2415,7 +3182,11 @@ function genComment(node, context) {
2415
3182
  if (pure) {
2416
3183
  push(PURE_ANNOTATION);
2417
3184
  }
2418
- push(`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`, node);
3185
+ push(
3186
+ `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
3187
+ -3 /* Unknown */,
3188
+ node
3189
+ );
2419
3190
  }
2420
3191
  function genVNodeCall(node, context) {
2421
3192
  const { push, helper, pure } = context;
@@ -2440,7 +3211,7 @@ function genVNodeCall(node, context) {
2440
3211
  push(PURE_ANNOTATION);
2441
3212
  }
2442
3213
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
2443
- push(helper(callHelper) + `(`, node);
3214
+ push(helper(callHelper) + `(`, -2 /* None */, node);
2444
3215
  genNodeList(
2445
3216
  genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
2446
3217
  context
@@ -2469,7 +3240,7 @@ function genCallExpression(node, context) {
2469
3240
  if (pure) {
2470
3241
  push(PURE_ANNOTATION);
2471
3242
  }
2472
- push(callee + `(`, node);
3243
+ push(callee + `(`, -2 /* None */, node);
2473
3244
  genNodeList(node.arguments, context);
2474
3245
  push(`)`);
2475
3246
  }
@@ -2477,7 +3248,7 @@ function genObjectExpression(node, context) {
2477
3248
  const { push, indent, deindent, newline } = context;
2478
3249
  const { properties } = node;
2479
3250
  if (!properties.length) {
2480
- push(`{}`, node);
3251
+ push(`{}`, -2 /* None */, node);
2481
3252
  return;
2482
3253
  }
2483
3254
  const multilines = properties.length > 1 || !!(process.env.NODE_ENV !== "production") && properties.some((p) => p.value.type !== 4);
@@ -2505,7 +3276,7 @@ function genFunctionExpression(node, context) {
2505
3276
  if (isSlot) {
2506
3277
  push(`_${helperNameMap[WITH_CTX]}(`);
2507
3278
  }
2508
- push(`(`, node);
3279
+ push(`(`, -2 /* None */, node);
2509
3280
  if (isArray(params)) {
2510
3281
  genNodeList(params, context);
2511
3282
  } else if (params) {
@@ -2640,6 +3411,15 @@ function walkBlockDeclarations(block, onIdent) {
2640
3411
  if (stmt.declare || !stmt.id)
2641
3412
  continue;
2642
3413
  onIdent(stmt.id);
3414
+ } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
3415
+ const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
3416
+ if (variable && variable.type === "VariableDeclaration") {
3417
+ for (const decl of variable.declarations) {
3418
+ for (const id of extractIdentifiers(decl.id)) {
3419
+ onIdent(id);
3420
+ }
3421
+ }
3422
+ }
2643
3423
  }
2644
3424
  }
2645
3425
  }
@@ -2850,7 +3630,7 @@ function processIf(node, dir, context, processCodegen) {
2850
3630
  context.removeNode();
2851
3631
  const branch = createIfBranch(node, dir);
2852
3632
  if (!!(process.env.NODE_ENV !== "production") && comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
2853
- !(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
3633
+ !(context.parent && context.parent.type === 1 && (context.parent.tag === "transition" || context.parent.tag === "Transition"))) {
2854
3634
  branch.children = [...comments, ...branch.children];
2855
3635
  }
2856
3636
  if (!!(process.env.NODE_ENV !== "production") || false) {
@@ -3132,18 +3912,14 @@ function processFor(node, dir, context, processCodegen) {
3132
3912
  );
3133
3913
  return;
3134
3914
  }
3135
- const parseResult = parseForExpression(
3136
- // can only be simple expression because vFor transform is applied
3137
- // before expression transform.
3138
- dir.exp,
3139
- context
3140
- );
3915
+ const parseResult = dir.forParseResult;
3141
3916
  if (!parseResult) {
3142
3917
  context.onError(
3143
3918
  createCompilerError(32, dir.loc)
3144
3919
  );
3145
3920
  return;
3146
3921
  }
3922
+ finalizeForParseResult(parseResult, context);
3147
3923
  const { addIdentifiers, removeIdentifiers, scopes } = context;
3148
3924
  const { source, value, key, index } = parseResult;
3149
3925
  const forNode = {
@@ -3165,71 +3941,26 @@ function processFor(node, dir, context, processCodegen) {
3165
3941
  onExit();
3166
3942
  };
3167
3943
  }
3168
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
3169
- const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
3170
- const stripParensRE = /^\(|\)$/g;
3171
- function parseForExpression(input, context) {
3172
- const loc = input.loc;
3173
- const exp = input.content;
3174
- const inMatch = exp.match(forAliasRE);
3175
- if (!inMatch)
3944
+ function finalizeForParseResult(result, context) {
3945
+ if (result.finalized)
3176
3946
  return;
3177
- const [, LHS, RHS] = inMatch;
3178
- const result = {
3179
- source: createAliasExpression(
3180
- loc,
3181
- RHS.trim(),
3182
- exp.indexOf(RHS, LHS.length)
3183
- ),
3184
- value: void 0,
3185
- key: void 0,
3186
- index: void 0
3187
- };
3188
3947
  if (!!(process.env.NODE_ENV !== "production") && true) {
3189
3948
  validateBrowserExpression(result.source, context);
3190
- }
3191
- let valueContent = LHS.trim().replace(stripParensRE, "").trim();
3192
- const trimmedOffset = LHS.indexOf(valueContent);
3193
- const iteratorMatch = valueContent.match(forIteratorRE);
3194
- if (iteratorMatch) {
3195
- valueContent = valueContent.replace(forIteratorRE, "").trim();
3196
- const keyContent = iteratorMatch[1].trim();
3197
- let keyOffset;
3198
- if (keyContent) {
3199
- keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
3200
- result.key = createAliasExpression(loc, keyContent, keyOffset);
3201
- if (!!(process.env.NODE_ENV !== "production") && true) {
3202
- validateBrowserExpression(
3203
- result.key,
3204
- context,
3205
- true
3206
- );
3207
- }
3949
+ if (result.key) {
3950
+ validateBrowserExpression(
3951
+ result.key,
3952
+ context,
3953
+ true
3954
+ );
3208
3955
  }
3209
- if (iteratorMatch[2]) {
3210
- const indexContent = iteratorMatch[2].trim();
3211
- if (indexContent) {
3212
- result.index = createAliasExpression(
3213
- loc,
3214
- indexContent,
3215
- exp.indexOf(
3216
- indexContent,
3217
- result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
3218
- )
3219
- );
3220
- if (!!(process.env.NODE_ENV !== "production") && true) {
3221
- validateBrowserExpression(
3222
- result.index,
3223
- context,
3224
- true
3225
- );
3226
- }
3227
- }
3956
+ if (result.index) {
3957
+ validateBrowserExpression(
3958
+ result.index,
3959
+ context,
3960
+ true
3961
+ );
3228
3962
  }
3229
- }
3230
- if (valueContent) {
3231
- result.value = createAliasExpression(loc, valueContent, trimmedOffset);
3232
- if (!!(process.env.NODE_ENV !== "production") && true) {
3963
+ if (result.value) {
3233
3964
  validateBrowserExpression(
3234
3965
  result.value,
3235
3966
  context,
@@ -3237,14 +3968,7 @@ function parseForExpression(input, context) {
3237
3968
  );
3238
3969
  }
3239
3970
  }
3240
- return result;
3241
- }
3242
- function createAliasExpression(range, content, offset) {
3243
- return createSimpleExpression(
3244
- content,
3245
- false,
3246
- getInnerRange(range, offset, content.length)
3247
- );
3971
+ result.finalized = true;
3248
3972
  }
3249
3973
  function createForLoopParams({ value, key, index }, memoArgs = []) {
3250
3974
  return createParamsList([value, key, index, ...memoArgs]);
@@ -3274,11 +3998,9 @@ const trackSlotScopes = (node, context) => {
3274
3998
  const trackVForSlotScopes = (node, context) => {
3275
3999
  let vFor;
3276
4000
  if (isTemplateNode(node) && node.props.some(isVSlot) && (vFor = findDir(node, "for"))) {
3277
- const result = vFor.parseResult = parseForExpression(
3278
- vFor.exp,
3279
- context
3280
- );
4001
+ const result = vFor.forParseResult;
3281
4002
  if (result) {
4003
+ finalizeForParseResult(result, context);
3282
4004
  const { value, key, index } = result;
3283
4005
  const { addIdentifiers, removeIdentifiers } = context;
3284
4006
  value && addIdentifiers(value);
@@ -3352,12 +4074,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3352
4074
  hasDynamicSlots = true;
3353
4075
  }
3354
4076
  const vFor = findDir(slotElement, "for");
3355
- const slotFunction = buildSlotFn(
3356
- slotProps,
3357
- vFor == null ? void 0 : vFor.exp,
3358
- slotChildren,
3359
- slotLoc
3360
- );
4077
+ const slotFunction = buildSlotFn(slotProps, vFor, slotChildren, slotLoc);
3361
4078
  let vIf;
3362
4079
  let vElse;
3363
4080
  if (vIf = findDir(slotElement, "if")) {
@@ -3406,8 +4123,9 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3406
4123
  }
3407
4124
  } else if (vFor) {
3408
4125
  hasDynamicSlots = true;
3409
- const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
4126
+ const parseResult = vFor.forParseResult;
3410
4127
  if (parseResult) {
4128
+ finalizeForParseResult(parseResult, context);
3411
4129
  dynamicSlots.push(
3412
4130
  createCallExpression(context.helper(RENDER_LIST), [
3413
4131
  parseResult.source,
@@ -3670,17 +4388,6 @@ function resolveComponentType(node, context, ssr = false) {
3670
4388
  tag = isProp.value.content.slice(4);
3671
4389
  }
3672
4390
  }
3673
- const isDir = !isExplicitDynamic && findDir(node, "is");
3674
- if (isDir && isDir.exp) {
3675
- if (!!(process.env.NODE_ENV !== "production")) {
3676
- context.onWarn(
3677
- createCompilerError(52, isDir.loc)
3678
- );
3679
- }
3680
- return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
3681
- isDir.exp
3682
- ]);
3683
- }
3684
4391
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
3685
4392
  if (builtIn) {
3686
4393
  if (!ssr)
@@ -3752,7 +4459,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3752
4459
  for (let i = 0; i < props.length; i++) {
3753
4460
  const prop = props[i];
3754
4461
  if (prop.type === 6) {
3755
- const { loc, name, value } = prop;
4462
+ const { loc, name, nameLoc, value } = prop;
3756
4463
  let isStatic = true;
3757
4464
  if (name === "ref") {
3758
4465
  hasRef = true;
@@ -3773,11 +4480,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3773
4480
  }
3774
4481
  properties.push(
3775
4482
  createObjectProperty(
3776
- createSimpleExpression(
3777
- name,
3778
- true,
3779
- getInnerRange(loc, 0, name.length)
3780
- ),
4483
+ createSimpleExpression(name, true, nameLoc),
3781
4484
  createSimpleExpression(
3782
4485
  value ? value.content : "",
3783
4486
  isStatic,
@@ -3786,7 +4489,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3786
4489
  )
3787
4490
  );
3788
4491
  } else {
3789
- const { name, arg, exp, loc } = prop;
4492
+ const { name, arg, exp, loc, modifiers } = prop;
3790
4493
  const isVBind = name === "bind";
3791
4494
  const isVOn = name === "on";
3792
4495
  if (name === "slot") {
@@ -3879,6 +4582,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3879
4582
  }
3880
4583
  continue;
3881
4584
  }
4585
+ if (isVBind && modifiers.includes("prop")) {
4586
+ patchFlag |= 32;
4587
+ }
3882
4588
  const directiveTransform = context.directiveTransforms[name];
3883
4589
  if (directiveTransform) {
3884
4590
  const { props: props2, needRuntime } = directiveTransform(prop, node, context);
@@ -4256,8 +4962,13 @@ const transformOn = (dir, node, context, augmentor) => {
4256
4962
  };
4257
4963
 
4258
4964
  const transformBind = (dir, _node, context) => {
4259
- const { exp, modifiers, loc } = dir;
4965
+ const { modifiers, loc } = dir;
4260
4966
  const arg = dir.arg;
4967
+ let { exp } = dir;
4968
+ if (!exp && arg.type === 4) {
4969
+ const propName = camelize(arg.content);
4970
+ exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
4971
+ }
4261
4972
  if (arg.type !== 4) {
4262
4973
  arg.children.unshift(`(`);
4263
4974
  arg.children.push(`) || ""`);
@@ -4656,7 +5367,7 @@ function getBaseTransformPreset(prefixIdentifiers) {
4656
5367
  }
4657
5368
  ];
4658
5369
  }
4659
- function baseCompile(template, options = {}) {
5370
+ function baseCompile(source, options = {}) {
4660
5371
  const onError = options.onError || defaultOnError;
4661
5372
  const isModuleMode = options.mode === "module";
4662
5373
  {
@@ -4673,7 +5384,7 @@ function baseCompile(template, options = {}) {
4673
5384
  if (options.scopeId && !isModuleMode) {
4674
5385
  onError(createCompilerError(50));
4675
5386
  }
4676
- const ast = isString(template) ? baseParse(template, options) : template;
5387
+ const ast = isString(source) ? baseParse(source, options) : source;
4677
5388
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
4678
5389
  transform(
4679
5390
  ast,
@@ -4702,4 +5413,4 @@ function baseCompile(template, options = {}) {
4702
5413
 
4703
5414
  const noopDirectiveTransform = () => ({ props: [] });
4704
5415
 
4705
- export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, generate, getBaseTransformPreset, getConstantType, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
5416
+ export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };