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

Missing space between HTML elements #9021

Closed
revolter opened this issue Nov 3, 2018 · 5 comments
Closed

Missing space between HTML elements #9021

revolter opened this issue Nov 3, 2018 · 5 comments

Comments

@revolter
Copy link

revolter commented Nov 3, 2018

Version

2.5.17

Reproduction link

https://github.com/revolter/website/tree/demo/missing-space-bug

Steps to reproduce

Run the app and navigate to the about page.

What is expected?

A space between the abbr and code tags as in the About.vue file.

What is actually happening?

The mentioned space is missing when rendered in the browser.

@sqal
Copy link
Contributor

sqal commented Nov 3, 2018

Whitespace characters between HTML tags are removed because preserveWhitespace option in vue-loader is set to false by default in vue-cli, here: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/config/base.js#L87. In order to enable this option you have to modify webpack config using either chainWebpack or configureWebpack in your vue.config.js.

https://cli.vuejs.org/guide/webpack.html#chaining-advanced

The first one is simpler imho, actually here's what you need to do:

vue.config.js

module.exports = {
  chainWebpack(config) {
    config.module
      .rule('vue')
      .use('vue-loader')
      .loader('vue-loader')
      .tap(options => ({
        ...options,
        compilerOptions: {
          ...options.compilerOptions,
          preserveWhitespace: true,
        },
      }));
  },
};

@Justineo
Copy link
Member

Justineo commented Nov 3, 2018

As @sqal said.

@Justineo Justineo closed this as completed Nov 3, 2018
@revolter
Copy link
Author

revolter commented Nov 3, 2018

Thank you!

@frasern
Copy link

frasern commented Jul 27, 2019

Quick tip if you really need a space to be present between particular tags... you can always explicitly insert one using the   HTML entity.

e.g.

<span>lorem</span>&#32;<span>ipsum</span>

@pmrotule
Copy link

Quick tip if you really need a space to be present between particular tags... you can always explicitly insert one using the &#32; HTML entity.

e.g.

<span>lorem</span>&#32;<span>ipsum</span>

You can also explicitly insert one using mustache:

<span>lorem</span>{{ ' ' }}<span>ipsum</span>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants