From b4203ffe4ab1fcac95f9ceaca171b99e53b03bd1 Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 13 Sep 2024 10:00:11 +0800 Subject: [PATCH 1/2] fix(compiler-core): fix handling of delimiterOpen in VPre --- packages/compiler-core/src/tokenizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compiler-core/src/tokenizer.ts b/packages/compiler-core/src/tokenizer.ts index 35c49fa6545..329e8b48181 100644 --- a/packages/compiler-core/src/tokenizer.ts +++ b/packages/compiler-core/src/tokenizer.ts @@ -438,7 +438,7 @@ export default class Tokenizer { // We have to parse entities in 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 From 2619f3aa4eb884af3ce61e1fd08fb93b9c62490a Mon Sep 17 00:00:00 2001 From: daiwei <daiwei521@126.com> Date: Fri, 13 Sep 2024 11:20:52 +0800 Subject: [PATCH 2/2] test: add test case --- packages/compiler-core/__tests__/parse.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/compiler-core/__tests__/parse.spec.ts b/packages/compiler-core/__tests__/parse.spec.ts index 37e81e64924..77211b2f5fb 100644 --- a/packages/compiler-core/__tests__/parse.spec.ts +++ b/packages/compiler-core/__tests__/parse.spec.ts @@ -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', () => {