Преглед изворни кода

sfc parser: treat all custom blocks as special tags

Evan You пре 9 година
родитељ
комит
6c7bc69328
2 измењених фајлова са 8 додато и 9 уклоњено
  1. 7 8
      src/compiler/parser/html-parser.js
  2. 1 1
      test/unit/modules/sfc/sfc-parser.spec.js

+ 7 - 8
src/compiler/parser/html-parser.js

@@ -52,14 +52,13 @@ const isSpecialTag = (tag, isSFC, stack) => {
   if (isScriptOrStyle(tag)) {
     return true
   }
-  // top-level template that has a pre-processor
-  if (
-    isSFC &&
-    tag === 'template' &&
-    stack.length === 1 &&
-    stack[0].attrs.some(hasLang)
-  ) {
-    return true
+  if (isSFC) {
+    // top-level template that has no pre-processor
+    if (tag === 'template' && stack.length === 1 && !stack[0].attrs.some(hasLang)) {
+      return false
+    } else {
+      return true
+    }
   }
   return false
 }

+ 1 - 1
test/unit/modules/sfc/sfc-parser.spec.js

@@ -78,7 +78,7 @@ describe('Single File Component parser', () => {
     expect(res.template.content.trim()).toBe(`div\n  h1(v-if='1 < 2') hello`)
   })
 
-  it('should handle custom blocks without without parsing them', () => {
+  it('should handle custom blocks without parsing them', () => {
     const res = parseComponent(`
       <template>
         <div></div>