Skip to content

Commit 55a30cf

Browse files
authored
fix(compiler): avoid converting &nbps; to spaces (#11065)
1 parent 3d46692 commit 55a30cf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/compiler/parser/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g
3838
const slotRE = /^v-slot(:|$)|^#/
3939

4040
const lineBreakRE = /[\r\n]/
41-
const whitespaceRE = /\s+/g
41+
const whitespaceRE = /[ \f\t\r\n]+/g
4242

4343
const invalidAttributeRE = /[\s"'<>\/=]/
4444

test/unit/modules/compiler/parser.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,14 @@ describe('parser', () => {
865865
expect(ast.children[4].children[0].text).toBe('. Have fun! ')
866866
})
867867

868+
it(`maintains &nbsp; with whitespace: 'condense'`, () => {
869+
const options = extend({}, condenseOptions)
870+
const ast = parse('<span>&nbsp;</span>', options)
871+
const code = ast.children[0]
872+
expect(code.type).toBe(3)
873+
expect(code.text).toBe('\xA0')
874+
})
875+
868876
it(`preserve whitespace in <pre> tag with whitespace: 'condense'`, function () {
869877
const options = extend({}, condenseOptions)
870878
const ast = parse('<pre><code> \n<span>hi</span>\n </code><span> </span></pre>', options)

0 commit comments

Comments
 (0)