]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-core): fix handling of delimiterOpen in VPre (#11915)
authoredison <daiwei521@126.com>
Fri, 13 Sep 2024 08:46:01 +0000 (16:46 +0800)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2024 08:46:01 +0000 (16:46 +0800)
close #11913

packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/src/tokenizer.ts

index 37e81e649249affe03b0019f8fec5b624928cf8f..77211b2f5fb55e4d3451d9b5528ebf2874b6723c 100644 (file)
@@ -2019,6 +2019,21 @@ describe('compiler: parse', () => {
           children: [{ type: NodeTypes.TEXT, content: `{{ number ` }],
         },
       ])
+
+      const ast3 = baseParse(`<div v-pre><textarea>{{ foo </textarea></div>`, {
+        parseMode: 'html',
+      })
+      expect((ast3.children[0] as ElementNode).children).toMatchObject([
+        {
+          type: NodeTypes.ELEMENT,
+          children: [
+            {
+              type: NodeTypes.TEXT,
+              content: `{{ foo `,
+            },
+          ],
+        },
+      ])
     })
 
     test('self-closing v-pre', () => {
index 35c49fa6545fd3356edd8f491b66224019df4b37..329e8b481814329442586bec16aa0ad45e05eeb9 100644 (file)
@@ -438,7 +438,7 @@ export default class Tokenizer {
         // We have to parse entities in <title> and <textarea> tags.
         if (!__BROWSER__ && c === CharCodes.Amp) {
           this.startEntity()
-        } else if (c === this.delimiterOpen[0]) {
+        } else if (!this.inVPre && c === this.delimiterOpen[0]) {
           // We also need to handle interpolation
           this.state = State.InterpolationOpen
           this.delimiterIndex = 0