Skip to content

With whitespace:condense all &nbsps;, even meaningful, are converted to spaces #11059

Closed
@aimozg

Description

@aimozg

Version

2.6.11

Reproduction link

https://gist.github.com/aimozg/c073eea5a55062e3dcd8f887a8567807

Steps to reproduce

Run example.js in Node.

Alternative steps/Detailed explanation:

  1. Setup Vue template compiler with whitespace: 'condense'. (it is default for vue-cli).
  2. Render template with &nbsp; entity, e.g. <p>a&nbsp;b</p>
  3. Inspect template for actual non-breaking space character

What is expected?

&nbsp; entity rendered as non-breaking space character; example.js output should contain

---- whitespace: condense
// code
NBSP FOUND

What is actually happening?

&nbsp; entity is rendered as plain space, example.js output contains

---- whitespace: condense
// code
NBSP NOT FOUND

The whitespace is stripped by this compiler code:

if (!inPre && whitespaceOption === 'condense') {
  // condense consecutive whitespaces into single space
  text = text.replace(whitespaceRE, ' ')
}

and "&nbsp;"s are replaced by "\xA0"s with entity decoder earlier.

Related issues is #10485

Suggestion:

Narrower whitespaceRE regexp, like /[ \t\r\n]+/g.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions