Subscribe on changes!

when use v-slot, the default slot around with space

avatar
Nov 19th 2020

Version

3.0.2

Reproduction link

https://codesandbox.io/s/flamboyant-wiles-cdjbf?file=/src/App.vue

Steps to reproduce

skip

What is expected?

<p>test</p>

What is actually happening?

<p> test </p>

avatar
Nov 19th 2020

I'd rather say that <p> test </p> is expected, because the text (test) exists in a new line:

  <HelloWorld msg="Hello Vue 3 in CodeSandbox!">
    <template #test>
      test
    </template>
    test  
  </HelloWorld>

To meet your expectations, you can remove newline like below:

  <HelloWorld msg="Hello Vue 3 in CodeSandbox!">
    <template #test>
      test
    </template>test</HelloWorld>

And if you are wondering about wrapping lines into spaces, test below HTML and then you can find that Vue behaves like HTML (different places: Vue replace \s+ to a whitespace forwardly but this does not affect render view)

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="wrapper">
    <span>123</span>456<span>789</span>
    abc
    <span>def</span>
  </div>
</body>

</html>
avatar
Jun 16th 2022

I'd rather say that <p> test </p> is expected, because the text (test) exists in a new line:

  <HelloWorld msg="Hello Vue 3 in CodeSandbox!">
    <template #test>
      test
    </template>
    test  
  </HelloWorld>

To meet your expectations, you can remove newline like below:

  <HelloWorld msg="Hello Vue 3 in CodeSandbox!">
    <template #test>
      test
    </template>test</HelloWorld>

And if you are wondering about wrapping lines into spaces, test below HTML and then you can find that Vue behaves like HTML (different places: Vue replace \s+ to a whitespace forwardly but this does not affect render view)

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="wrapper">
    <span>123</span>456<span>789</span>
    abc
    <span>def</span>
  </div>
</body>

</html>

Your mean

<pre>a     b</pre>

will be

<pre>a b</pre>