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

further improve end tag check (close #4408)

Evan You 9 лет назад
Родитель
Сommit
f59aef08e6

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

@@ -277,7 +277,9 @@ export function parseHTML (html, options) {
     if (pos >= 0) {
       // Close all the open elements, up the stack
       for (let i = stack.length - 1; i >= pos; i--) {
-        if (process.env.NODE_ENV !== 'production' && i > pos && options.warn) {
+        if (process.env.NODE_ENV !== 'production' &&
+            (i > pos || !tagName) &&
+            options.warn) {
           options.warn(
             `tag <${stack[i].tag}> has no matching end tag.`
           )

+ 1 - 1
test/unit/features/directives/for.spec.js

@@ -449,7 +449,7 @@ describe('Directive v-for', () => {
       },
       template: `
         <div>
-          <span v-for="letter in text">{{ letter }}.</span
+          <span v-for="letter in text">{{ letter }}.</span>
         </div>
       `
     }).$mount()

+ 1 - 1
test/unit/modules/compiler/codegen.spec.js

@@ -200,7 +200,7 @@ describe('codegen', () => {
     )
     // non input
     assertCodegen(
-      '<p :value="msg">',
+      '<p :value="msg"/>',
       `with(this){return _c('p',{attrs:{"value":msg}})}`
     )
   })

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

@@ -248,7 +248,7 @@ describe('parser', () => {
   })
 
   it('v-for directive iteration syntax', () => {
-    const ast = parse('<ul><li v-for="(item, index) in items"></li><ul/>', baseOptions)
+    const ast = parse('<ul><li v-for="(item, index) in items"></li></ul>', baseOptions)
     const liAst = ast.children[0]
     expect(liAst.for).toBe('items')
     expect(liAst.alias).toBe('item')