From: HcySunYang Date: Wed, 3 Feb 2021 18:11:45 +0000 (+0800) Subject: fix(compiler-sfc): the empty lang attribute should be treated as no lang specified... X-Git-Tag: v3.0.6~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d5b62351248780663d2612a1f483f7ea9f5e5a2;p=thirdparty%2Fvuejs%2Fcore.git fix(compiler-sfc): the empty lang attribute should be treated as no lang specified (#3051) --- diff --git a/packages/compiler-sfc/__tests__/parse.spec.ts b/packages/compiler-sfc/__tests__/parse.spec.ts index dc25c848c4..aa4b5b48be 100644 --- a/packages/compiler-sfc/__tests__/parse.spec.ts +++ b/packages/compiler-sfc/__tests__/parse.spec.ts @@ -139,6 +139,15 @@ h1 { color: red } expect(descriptor.template!.content).toBe(content) }) + test('treat empty lang attribute as the html', () => { + const content = `
` + const { descriptor, errors } = parse( + `` + ) + expect(descriptor.template!.content).toBe(content) + expect(errors.length).toBe(0) + }) + // #1120 test('alternative template lang should be treated as plain text', () => { const content = `p(v-if="1 < 2") test` diff --git a/packages/compiler-sfc/src/parse.ts b/packages/compiler-sfc/src/parse.ts index ac3456e645..303babe18f 100644 --- a/packages/compiler-sfc/src/parse.ts +++ b/packages/compiler-sfc/src/parse.ts @@ -121,6 +121,7 @@ export function parse( p.type === NodeTypes.ATTRIBUTE && p.name === 'lang' && p.value && + p.value.content && p.value.content !== 'html' )) ) {