Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): avoid converting &nbps; to spaces #11065

Merged
merged 2 commits into from Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/parser/index.js
Expand Up @@ -38,7 +38,7 @@ const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g
const slotRE = /^v-slot(:|$)|^#/

const lineBreakRE = /[\r\n]/
const whitespaceRE = /\s+/g
const whitespaceRE = /[ \f\t\r\n]+/g

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

Expand Down
8 changes: 8 additions & 0 deletions test/unit/modules/compiler/parser.spec.js
Expand Up @@ -845,6 +845,14 @@ describe('parser', () => {
expect(ast.children[4].children[0].text).toBe('. Have fun! ')
})

it(`maintains &nbsp; with whitespace: 'condense'`, () => {
const options = extend({}, condenseOptions)
const ast = parse('<span>&nbsp;</span>', options)
const code = ast.children[0]
expect(code.type).toBe(3)
expect(code.text).toBe('\xA0')
})

it(`preserve whitespace in <pre> tag with whitespace: 'condense'`, function () {
const options = extend({}, condenseOptions)
const ast = parse('<pre><code> \n<span>hi</span>\n </code><span> </span></pre>', options)
Expand Down