From 52d87ebed047adb56dc4760f8e71f73d817a476b Mon Sep 17 00:00:00 2001 From: Jovino Xu Date: Sat, 1 Dec 2018 07:02:54 +0800 Subject: [PATCH] fix(compiler): should keep newline after unary tags in
 (#8965)

fix #8950
---
 src/compiler/parser/html-parser.js        | 2 +-
 test/unit/modules/compiler/parser.spec.js | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js
index e4925f38d34..b0ef2d649e8 100644
--- a/src/compiler/parser/html-parser.js
+++ b/src/compiler/parser/html-parser.js
@@ -106,7 +106,7 @@ export function parseHTML (html, options) {
         const startTagMatch = parseStartTag()
         if (startTagMatch) {
           handleStartTag(startTagMatch)
-          if (shouldIgnoreFirstNewline(lastTag, html)) {
+          if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
             advance(1)
           }
           continue
diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js
index bc4285b9eb8..07d6148225c 100644
--- a/test/unit/modules/compiler/parser.spec.js
+++ b/test/unit/modules/compiler/parser.spec.js
@@ -667,6 +667,15 @@ describe('parser', () => {
     expect(pre2.children[0].text).toBe('\nabc')
   })
 
+  it('keep first newline after unary tag in 
', () => {
+    const options = extend({}, baseOptions)
+    const ast = parse('
abc\ndef
', options) + expect(ast.children[1].type).toBe(1) + expect(ast.children[1].tag).toBe('input') + expect(ast.children[2].type).toBe(3) + expect(ast.children[2].text).toBe('\ndef') + }) + it('forgivingly handle < in plain text', () => { const options = extend({}, baseOptions) const ast = parse('

1 < 2 < 3

', options)