Skip to content

Commit

Permalink
fix: SFC AST broken with embedded script tag
Browse files Browse the repository at this point in the history
close #1982
  • Loading branch information
johnsoncodehk committed Oct 14, 2022
1 parent ad33f04 commit 1ef24b0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions vue-language-tools/vue-language-core/src/utils/parseSfc.ts
Expand Up @@ -11,14 +11,19 @@ export function parse(source: string): SFCParseResult {
// preserve all whitespaces
isPreTag: () => true,
getTextMode: ({ tag, props }, parent) => {
if (!parent && tag !== 'template' && props.some(
p =>
p.type === compiler.NodeTypes.ATTRIBUTE &&
p.name === 'lang' &&
p.value &&
p.value.content &&
p.value.content !== 'html'
)) {
if (
(!parent && tag !== 'template')
|| (
tag === 'template'
&& props.some(
p =>
p.type === compiler.NodeTypes.ATTRIBUTE &&
p.name === 'lang' &&
p.value &&
p.value.content &&
p.value.content !== 'html'
)
)) {
return compiler.TextModes.RAWTEXT;
}
else {
Expand Down

0 comments on commit 1ef24b0

Please sign in to comment.