Skip to content

Commit 6d5b623

Browse files
authoredFeb 3, 2021
fix(compiler-sfc): the empty lang attribute should be treated as no lang specified (#3051)
1 parent f262438 commit 6d5b623

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

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

+9
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ h1 { color: red }
139139
expect(descriptor.template!.content).toBe(content)
140140
})
141141

142+
test('treat empty lang attribute as the html', () => {
143+
const content = `<div><template v-if="ok">ok</template></div>`
144+
const { descriptor, errors } = parse(
145+
`<template lang="">${content}</template>`
146+
)
147+
expect(descriptor.template!.content).toBe(content)
148+
expect(errors.length).toBe(0)
149+
})
150+
142151
// #1120
143152
test('alternative template lang should be treated as plain text', () => {
144153
const content = `p(v-if="1 < 2") test`

‎packages/compiler-sfc/src/parse.ts

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function parse(
121121
p.type === NodeTypes.ATTRIBUTE &&
122122
p.name === 'lang' &&
123123
p.value &&
124+
p.value.content &&
124125
p.value.content !== 'html'
125126
))
126127
) {

0 commit comments

Comments
 (0)
Please sign in to comment.