Bläddra i källkod

fix sfc-parser unary tags handling

Evan You 10 år sedan
förälder
incheckning
439ca63f9f
2 ändrade filer med 5 tillägg och 3 borttagningar
  1. 3 1
      src/compiler/parser/sfc-parser.js
  2. 2 2
      test/unit/modules/compiler/sfc-parser.spec.js

+ 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', () => {