]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: better fix for ec6abe8d
authorEvan You <yyx990803@gmail.com>
Mon, 19 Jul 2021 23:23:44 +0000 (19:23 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 19 Jul 2021 23:23:44 +0000 (19:23 -0400)
packages/compiler-core/src/parse.ts

index a2f22193eb80f2728afc0c1dafdc73690aefa8c5..47c6b4f7728ec07871499ff4bc5e13ab4e608d17 100644 (file)
@@ -96,8 +96,8 @@ export interface ParserContext {
   offset: number
   line: number
   column: number
-  inPre: number // HTML <pre> tag, preserve whitespaces
-  inVPre: number // v-pre, do not process directives and interpolations
+  inPre: boolean // HTML <pre> tag, preserve whitespaces
+  inVPre: boolean // v-pre, do not process directives and interpolations
   onWarn: NonNullable<ErrorHandlingOptions['onWarn']>
 }
 
@@ -134,8 +134,8 @@ function createParserContext(
     offset: 0,
     originalSource: content,
     source: content,
-    inPre: 0,
-    inVPre: 0,
+    inPre: false,
+    inVPre: false,
     onWarn: options.onWarn
   }
 }
@@ -427,8 +427,8 @@ function parseElement(
 
   if (element.isSelfClosing || context.options.isVoidTag(element.tag)) {
     // #4030 self-closing <pre> tag
-    if (context.options.isPreTag(element.tag)) {
-      context.inPre--
+    if (isPreBoundary) {
+      context.inPre = false
     }
     return element
   }
@@ -479,10 +479,10 @@ function parseElement(
   element.loc = getSelection(context, element.loc.start)
 
   if (isPreBoundary) {
-    context.inPre--
+    context.inPre = false
   }
   if (isVPreBoundary) {
-    context.inVPre--
+    context.inVPre = false
   }
   return element
 }
@@ -535,7 +535,7 @@ function parseTag(
 
   // check <pre> tag
   if (context.options.isPreTag(tag)) {
-    context.inPre++
+    context.inPre = true
   }
 
   // Attributes.
@@ -547,7 +547,7 @@ function parseTag(
     !context.inVPre &&
     props.some(p => p.type === NodeTypes.DIRECTIVE && p.name === 'pre')
   ) {
-    context.inVPre++
+    context.inVPre = true
     // reset context
     extend(context, cursor)
     context.source = currentSource