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'`, elements contain only   and spaces are condensed into empty tags

See original GitHub issue

Version

4.0.0-rc.1

Reproduction link

https://github.com/tobyzerner/vue-cli-nbsp-bug

Environment info

Environment Info:
  System:
    OS: macOS 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    Yarn: 1.17.3 - ~/.npm-global/bin/yarn
    npm: 6.11.3 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 76.0.3809.132
    Firefox: 68.0.2
    Safari: 12.1.2
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0
    @vue/babel-plugin-transform-vue-jsx:  1.0.0
    @vue/babel-preset-app:  4.0.0-rc.1
    @vue/babel-preset-jsx:  1.1.0
    @vue/babel-sugar-functional-vue:  1.0.0
    @vue/babel-sugar-inject-h:  1.0.0
    @vue/babel-sugar-v-model:  1.0.0
    @vue/babel-sugar-v-on:  1.1.0
    @vue/cli-overlay:  4.0.0-rc.1
    @vue/cli-plugin-babel: ^4.0.0-rc.1 => 4.0.0-rc.1
    @vue/cli-plugin-eslint: ^4.0.0-rc.1 => 4.0.0-rc.1
    @vue/cli-service: ^4.0.0-rc.1 => 4.0.0-rc.1
    @vue/cli-shared-utils:  4.0.0-rc.1
    @vue/component-compiler-utils:  3.0.0
    @vue/preload-webpack-plugin:  1.1.1
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.3
    vue: ^2.6.10 => 2.6.10
    vue-eslint-parser:  5.0.0
    vue-hot-reload-api:  2.3.3
    vue-loader:  15.7.1
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.6.10 => 2.6.10
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: 4.0.0-rc.1

Steps to reproduce

Clone the repo, npm install && npm run serve

What is expected?

The template contains a span containing a   character. This span has a red background. Thus you should see a small red box on the page.

What is actually happening?

The   in the template is being ignored and converted into a normal space, which means the span element is not displayed.


I cannot replicate this bug in a plain Vue jsfiddle, nor a project using vue-loader without vue-cli. Thus I think something in vue-cli may be the culprit rather than vue-template-compiler or Vue itself.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
sodateacommented, Sep 6, 2019

I’ve transferred this issue to the vue repository because I believe it’s a bug introduced in https://github.com/vuejs/vue/commit/e1abedb9e66b21da8a7e93e175b9dabe334dfebd

See another bug report at https://github.com/vuejs/vue/issues/9208#issuecomment-477811927

Current workaround:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.module
      .rule('vue')
        .use('vue-loader')
          .tap(args => {
            args.compilerOptions.whitespace = 'preserve'
          })
  }
}
3reactions
antoniandrecommented, Sep 29, 2020

I’ve transferred this issue to the vue repository because I believe it’s a bug introduced in e1abedb

See another bug report at #9208 (comment)

Current workaround:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.module
      .rule('vue')
        .use('vue-loader')
          .tap(args => {
            args.compilerOptions.whitespace = 'preserve'
          })
  }
}

This doesn’t seem to work anymore with Vue 3, it throws the error: “TypeError: Cannot set property ‘whitespace’ of undefined”. Any workaround for Vue 3?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserve whitespace between <span>s in Vue - Stack Overflow
A whitespace-only text node between element tags is removed if it contains new lines. Otherwise, it is condensed into a single space.
Read more >
&nbsp and HTML Space Challenges and Tricks | Mailtrap Blog
Another method is with <td> HTML tags. Normally, <td> tags define typical data cells. When left empty, they create invisible cells that can...
Read more >
Changelog for pandoc-1.9.4.1 - Hackage
It was always possible to include raw DocBook tags in a markdown document, ... so that paragraphs containing only HTML tags and blank...
Read more >
Formatting the text - MSU Libraries
Empty element = An element that has only a single tag (which may have ... spaces to a line of text; only one...
Read more >
Why is blade trimming left spaces and how to avoid??
That's purely an html display issue. HTML will only output a single consecutive space, unless   is used. Try it with regular html...
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