Skip to content

Commit

Permalink
fix(compiler/parser/html-parser.js): Line breaks in textareas are not…
Browse files Browse the repository at this point in the history
… removed.(fix: vuejs#11446)
  • Loading branch information
wonhyoung05 committed Jun 18, 2020
1 parent 98b4d68 commit cd06afd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/parser/html-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g

// #5992
const isIgnoreNewlineTag = makeMap('pre,textarea', true)
const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n'
const shouldIgnoreFirstNewline = (tag, html) => tag && isIgnoreNewlineTag(tag) && html[0] === '\n' && html[1] && html[1] !== '\n'

function decodeAttr (value, shouldDecodeNewlines) {
const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr
Expand Down
4 changes: 2 additions & 2 deletions test/unit/modules/compiler/parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ describe('parser', () => {
expect(text.text).toBe('\ndef')
const pre2 = ast.children[2]
expect(pre2.children[0].type).toBe(3)
expect(pre2.children[0].text).toBe('\nabc')
expect(pre2.children[0].text).toBe('\n\nabc')
})

it('keep first newline after unary tag in <pre>', () => {
Expand Down Expand Up @@ -870,7 +870,7 @@ describe('parser', () => {
expect(text.text).toBe(' def')
const pre2 = ast.children[2]
expect(pre2.children[0].type).toBe(3)
expect(pre2.children[0].text).toBe('\nabc')
expect(pre2.children[0].text).toBe('\n\nabc')
})

it(`keep first newline after unary tag in <pre> with whitespace: 'condense'`, () => {
Expand Down

0 comments on commit cd06afd

Please sign in to comment.