question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 https://github.com/vuejs/vue/issues/10485

Suggestion:

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
posvacommented, Jan 29, 2020

Shouldn’t we not touch non-breakable spaces in general? That’s what I would personally expect if I use one in my template. It would also fix the issue you mentioned

3reactions
chasebankcommented, Apr 30, 2020

Setup Vue template compiler with whitespace: ‘condense’. (it is default for vue-cli).

Wait, I’m confused. Is condense really the default? I’m seeing multiple things that claim preserve is actually the default.

I’ve been struggling to figure out why none of my non-breakable spaces are working. I was going to try forcing preserve, but then saw:

Evan saying default is preserve https://github.com/vuejs/vue/issues/9208#issuecomment-450012518

And compiler option docs that echo that statement https://github.com/vuejs/vue/tree/dev/packages/vue-template-compiler#options

Now after seeing @aimozg say condense is actually default, I went ahead and manually set preserve and sure enough! Everything’s back to normal!

Are the docs/implementation wrong?

Either way, why would condense eliminate nbsp? Very unexpected behavior. I agree they shouldn’t be touched.

Read more comments on GitHub >

github_iconTop Results From Across the Web

164700 - css word-spacing applies at &nbsp; at paint time but ...
Looking over this bug I'm wondering if this is 2 different bugs - one for the additional space the nbsps are getting when...
Read more >
Spaces are gone in HTML after upgrading to vue-cli 3
Now I upgraded to cli3 and i noticed in the processed HTML it removes ALL whitespace. e.g. if my original html is this:...
Read more >
Ability to ignore whitespace changes in the diffs (BB-11120)
I would like to see the option to ignore space changes in the diff viewer as well. It allows us to focus on...
Read more >
Converting a Git repo from tabs to spaces / fuzzy notepad
As a side effect, the smudge command will be run, converting all your tabs to spaces. You will end up with a whole...
Read more >
Whitespace and Comments — Idris 1.3.3 documentation
In some grammars whitespace and comments would not be considered significant and so we might be tempted not to generate any tokens for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found