fix(compiler-sfc): the empty lang attribute should be treated as no lang specified (#3051)

This commit is contained in:
HcySunYang 2021-02-04 02:11:45 +08:00 committed by GitHub
parent f262438073
commit 6d5b623512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -139,6 +139,15 @@ h1 { color: red }
expect(descriptor.template!.content).toBe(content)
})
test('treat empty lang attribute as the html', () => {
const content = `<div><template v-if="ok">ok</template></div>`
const { descriptor, errors } = parse(
`<template lang="">${content}</template>`
)
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`

View File

@ -121,6 +121,7 @@ export function parse(
p.type === NodeTypes.ATTRIBUTE &&
p.name === 'lang' &&
p.value &&
p.value.content &&
p.value.content !== 'html'
))
) {