diff --git a/packages/compiler-sfc/__tests__/parse.spec.ts b/packages/compiler-sfc/__tests__/parse.spec.ts
index a782bc83779..dd16251e220 100644
--- a/packages/compiler-sfc/__tests__/parse.spec.ts
+++ b/packages/compiler-sfc/__tests__/parse.spec.ts
@@ -144,6 +144,18 @@ h1 { color: red }
expect(descriptor.template!.content).toBe(content)
})
+ //#2566
+ test('div lang should not be treated as plain text', () => {
+ const { errors } = parse(`
+
+
+
+ `)
+ expect(errors.length).toBe(0)
+ })
+
test('error tolerance', () => {
const { errors } = parse(``)
expect(errors.length).toBe(1)
diff --git a/packages/compiler-sfc/src/parse.ts b/packages/compiler-sfc/src/parse.ts
index 9a065a457e8..dcdd720c3de 100644
--- a/packages/compiler-sfc/src/parse.ts
+++ b/packages/compiler-sfc/src/parse.ts
@@ -115,13 +115,14 @@ export function parse(
if (
(!parent && tag !== 'template') ||
// should also be treated as raw text
- props.some(
- p =>
- p.type === NodeTypes.ATTRIBUTE &&
- p.name === 'lang' &&
- p.value &&
- p.value.content !== 'html'
- )
+ (tag === 'template' &&
+ props.some(
+ p =>
+ p.type === NodeTypes.ATTRIBUTE &&
+ p.name === 'lang' &&
+ p.value &&
+ p.value.content !== 'html'
+ ))
) {
return TextModes.RAWTEXT
} else {