Skip to content

Commit 02fb4d8

Browse files
committed
fix(compiler-sfc): lang="" on a html tag produces error
1 parent ca8276d commit 02fb4d8

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

packages/compiler-sfc/__tests__/parse.spec.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ h1 { color: red }
150150
})
151151

152152
test('should parse as DOM by default', () => {
153-
const { errors } = parse(`<template><input></template>`)
153+
const { errors } = parse(`
154+
<template>
155+
<div lang="">
156+
<div></div>
157+
</div>
158+
</template>
159+
`)
154160
expect(errors.length).toBe(0)
155161
})
156162

packages/compiler-sfc/src/parse.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ export function parse(
112112
if (
113113
(!parent && tag !== 'template') ||
114114
// <template lang="xxx"> should also be treated as raw text
115-
props.some(
116-
p =>
117-
p.type === NodeTypes.ATTRIBUTE &&
118-
p.name === 'lang' &&
119-
p.value &&
120-
p.value.content !== 'html'
121-
)
115+
(tag === 'template' &&
116+
props.some(
117+
p =>
118+
p.type === NodeTypes.ATTRIBUTE &&
119+
p.name === 'lang' &&
120+
p.value &&
121+
p.value.content !== 'html'
122+
))
122123
) {
123124
return TextModes.RAWTEXT
124125
} else {

0 commit comments

Comments
 (0)