fix(compiler-sfc): fix parsing error when lang=""
is used on plain element (#2569)
fix #2566
This commit is contained in:
parent
bf16a57fc3
commit
5f2a8533ac
@ -144,6 +144,18 @@ h1 { color: red }
|
|||||||
expect(descriptor.template!.content).toBe(content)
|
expect(descriptor.template!.content).toBe(content)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//#2566
|
||||||
|
test('div lang should not be treated as plain text', () => {
|
||||||
|
const { errors } = parse(`
|
||||||
|
<template lang="pug">
|
||||||
|
<div lang="">
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
`)
|
||||||
|
expect(errors.length).toBe(0)
|
||||||
|
})
|
||||||
|
|
||||||
test('error tolerance', () => {
|
test('error tolerance', () => {
|
||||||
const { errors } = parse(`<template>`)
|
const { errors } = parse(`<template>`)
|
||||||
expect(errors.length).toBe(1)
|
expect(errors.length).toBe(1)
|
||||||
|
@ -115,13 +115,14 @@ export function parse(
|
|||||||
if (
|
if (
|
||||||
(!parent && tag !== 'template') ||
|
(!parent && tag !== 'template') ||
|
||||||
// <template lang="xxx"> should also be treated as raw text
|
// <template lang="xxx"> should also be treated as raw text
|
||||||
|
(tag === 'template' &&
|
||||||
props.some(
|
props.some(
|
||||||
p =>
|
p =>
|
||||||
p.type === NodeTypes.ATTRIBUTE &&
|
p.type === NodeTypes.ATTRIBUTE &&
|
||||||
p.name === 'lang' &&
|
p.name === 'lang' &&
|
||||||
p.value &&
|
p.value &&
|
||||||
p.value.content !== 'html'
|
p.value.content !== 'html'
|
||||||
)
|
))
|
||||||
) {
|
) {
|
||||||
return TextModes.RAWTEXT
|
return TextModes.RAWTEXT
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user