diff --git a/packages/compiler-core/__tests__/parse.spec.ts b/packages/compiler-core/__tests__/parse.spec.ts index dbc982b9..0e839d26 100644 --- a/packages/compiler-core/__tests__/parse.spec.ts +++ b/packages/compiler-core/__tests__/parse.spec.ts @@ -1644,6 +1644,54 @@ describe('compiler: parse', () => { }) }) + test('self-closing v-pre', () => { + const ast = baseParse( + `
\n
{{ bar }}
` + ) + // should not affect siblings after it + const divWithoutPre = ast.children[1] as ElementNode + expect(divWithoutPre.props).toMatchObject([ + { + type: NodeTypes.DIRECTIVE, + name: `bind`, + arg: { + type: NodeTypes.SIMPLE_EXPRESSION, + isStatic: true, + content: `id` + }, + exp: { + type: NodeTypes.SIMPLE_EXPRESSION, + isStatic: false, + content: `foo` + }, + loc: { + source: `:id="foo"`, + start: { + line: 2, + column: 6 + }, + end: { + line: 2, + column: 15 + } + } + } + ]) + expect(divWithoutPre.children[0]).toMatchObject({ + type: NodeTypes.ELEMENT, + tagType: ElementTypes.COMPONENT, + tag: `Comp` + }) + expect(divWithoutPre.children[1]).toMatchObject({ + type: NodeTypes.INTERPOLATION, + content: { + type: NodeTypes.SIMPLE_EXPRESSION, + content: `bar`, + isStatic: false + } + }) + }) + test('end tags are case-insensitive.', () => { const ast = baseParse('
hello
after') const element = ast.children[0] as ElementNode @@ -1884,6 +1932,15 @@ foo ) }) + it('self-closing pre tag', () => { + const ast = baseParse(`
\n  foo   bar`, {
+        isPreTag: tag => tag === 'pre'
+      })
+      const elementAfterPre = ast.children[1] as ElementNode
+      // should not affect the  and condense its whitepsace inside
+      expect((elementAfterPre.children[0] as TextNode).content).toBe(` foo bar`)
+    })
+
     it('should NOT condense whitespaces in RCDATA text mode', () => {
       const ast = baseParse(``, {
         getTextMode: ({ tag }) =>
diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts
index 47c6b4f7..31076634 100644
--- a/packages/compiler-core/src/parse.ts
+++ b/packages/compiler-core/src/parse.ts
@@ -430,6 +430,9 @@ function parseElement(
     if (isPreBoundary) {
       context.inPre = false
     }
+    if (isVPreBoundary) {
+      context.inVPre = false
+    }
     return element
   }