Skip to content

Commit 7e75b41

Browse files
committed
refactor: better fix for ec6abe8
1 parent bb7b130 commit 7e75b41

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/compiler-core/src/parse.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export interface ParserContext {
9696
offset: number
9797
line: number
9898
column: number
99-
inPre: number // HTML <pre> tag, preserve whitespaces
100-
inVPre: number // v-pre, do not process directives and interpolations
99+
inPre: boolean // HTML <pre> tag, preserve whitespaces
100+
inVPre: boolean // v-pre, do not process directives and interpolations
101101
onWarn: NonNullable<ErrorHandlingOptions['onWarn']>
102102
}
103103

@@ -134,8 +134,8 @@ function createParserContext(
134134
offset: 0,
135135
originalSource: content,
136136
source: content,
137-
inPre: 0,
138-
inVPre: 0,
137+
inPre: false,
138+
inVPre: false,
139139
onWarn: options.onWarn
140140
}
141141
}
@@ -427,8 +427,8 @@ function parseElement(
427427

428428
if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
429429
// #4030 self-closing <pre> tag
430-
if (context.options.isPreTag(element.tag)) {
431-
context.inPre--
430+
if (isPreBoundary) {
431+
context.inPre = false
432432
}
433433
return element
434434
}
@@ -479,10 +479,10 @@ function parseElement(
479479
element.loc = getSelection(context, element.loc.start)
480480

481481
if (isPreBoundary) {
482-
context.inPre--
482+
context.inPre = false
483483
}
484484
if (isVPreBoundary) {
485-
context.inVPre--
485+
context.inVPre = false
486486
}
487487
return element
488488
}
@@ -535,7 +535,7 @@ function parseTag(
535535

536536
// check <pre> tag
537537
if (context.options.isPreTag(tag)) {
538-
context.inPre++
538+
context.inPre = true
539539
}
540540

541541
// Attributes.
@@ -547,7 +547,7 @@ function parseTag(
547547
!context.inVPre &&
548548
props.some(p => p.type === NodeTypes.DIRECTIVE && p.name === 'pre')
549549
) {
550-
context.inVPre++
550+
context.inVPre = true
551551
// reset context
552552
extend(context, cursor)
553553
context.source = currentSource

0 commit comments

Comments
 (0)