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

Newline & indentation causing issues in interpreted spaces #10924

Closed
duckness opened this issue Dec 12, 2019 · 2 comments
Closed

Newline & indentation causing issues in interpreted spaces #10924

duckness opened this issue Dec 12, 2019 · 2 comments

Comments

@duckness
Copy link

Version

2.6.10

Reproduction link

https://jsbin.com/feloyenami/2/edit?html,js,output

Steps to reproduce

Have any code written with the following format (including indentation and newlines)

<div>
  <span>span</span>
  <a 
    href="https://example.com"
    rel="s"
  >
    {{ "MESSAGE" }}
  </a>
  <span>span</span>
</div>

What is expected?

Consistent rendering of the middle element, and without spaces.

What is actually happening?

On node, the dev mode and built files will be rendered as:

node

Including Vue as a script tag (like in the repro), you will get:

html

However, what you probably really want is:

want


Personally, I feel that whitespace should be stripped out if the curly braces are the only thing within the html tag, if those are required then they can be added within the curly braces like {{ " example " }}.

You will probably encounter this if you use plugin:vue/recommended in your eslint config as that enforces the multi-line attributes in html tags.

Workaround:

<span>span</span>
<a 
  href="https://example.com"
  rel="s"
>
  <template>{{ "MESSAGE" }}</template>
</a>
<span>span</span>
@duckness
Copy link
Author

duckness commented Dec 12, 2019

You may also encounter something similar in the following case:

<span
  v-if="true"
  rel="a"
>
  <span style="color: red;">asd</span>
  {{ "MESSAGE" }}
  <span style="color: red;">asd</span>
</span>

Spaces will be added between MESSAGE which might not be what you want (will also be added on both sides if only one of the inner spans are there), workaround is the same.This result may be unexpected considering that indentation & newline is being interpreted as actual characters.

@duckness
Copy link
Author

just realised this is discussed in #10443 #9208

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

1 participant