Просмотр исходного кода

fix sfc-parser unary tags handling

Evan You 10 лет назад
Родитель
Сommit
439ca63f9f

+ 3 - 1
src/compiler/parser/sfc-parser.js

@@ -52,7 +52,9 @@ export function parseComponent (
         sfc[tag] = currentBlock
       }
     }
-    depth++
+    if (!unary) {
+      depth++
+    }
   }
 
   function checkAttrs (block: SFCBlock, attrs: Array<Attribute>) {

+ 2 - 2
test/unit/modules/compiler/sfc-parser.spec.js

@@ -30,14 +30,14 @@ describe('Single File Component parser', () => {
     expect(res.script.content.trim()).toBe('export default {}')
   })
 
-  fit('should parse template with closed input', () => {
+  it('should parse template with closed input', () => {
     const res = parseComponent(`
       <template>
         <input type="text"/>
       </template>
     `)
 
-    expect(res.template.content.trim()).toBe('<input type="text">')
+    expect(res.template.content.trim()).toBe('<input type="text"/>')
   })
 
   it('should handle nested template', () => {