Skip to content

Commit

Permalink
fix(compiler-sfc): the empty lang attribute should be treated as no l…
Browse files Browse the repository at this point in the history
…ang specified (#3051)
  • Loading branch information
HcySunYang committed Feb 3, 2021
1 parent f262438 commit 6d5b623
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/compiler-sfc/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-sfc/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function parse(
p.type === NodeTypes.ATTRIBUTE &&
p.name === 'lang' &&
p.value &&
p.value.content &&
p.value.content !== 'html'
))
) {
Expand Down

0 comments on commit 6d5b623

Please sign in to comment.