diff --git a/src/compiler/parser/html-parser.js b/src/compiler/parser/html-parser.js index dbc59146331..7a98202975f 100644 --- a/src/compiler/parser/html-parser.js +++ b/src/compiler/parser/html-parser.js @@ -31,6 +31,7 @@ export const isPlainTextElement = makeMap('script,style,textarea', true) const reCache = {} const decodingMap = { + ' ': ' ', '<': '<', '>': '>', '"': '"', @@ -39,8 +40,8 @@ const decodingMap = { ' ': '\t', ''': "'" } -const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g -const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g +const encodedAttr = /&(?:lt|gt|quot|amp|#39|nbsp);/g +const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|nbsp|#10|#9);/g // #5992 const isIgnoreNewlineTag = makeMap('pre,textarea', true) diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index d6521bbf625..3bffc06e9ba 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -881,4 +881,10 @@ describe('parser', () => { expect(ast.children[2].type).toBe(3) expect(ast.children[2].text).toBe('\ndef') }) + + it(`should decode   in the value of attribute`, () => { + const options = extend({}, baseOptions) + const ast = parse('', options) + expect(ast.attrsList[0].value).toBe('white space') + }) })