I have the following html code
<head>
<script src="https://unpkg.com/vue@3"></script>
<script defer src="script.js"></script>
</head>
<body>
<div id="main">
<div>
1. This is 1st line
2. This is 2nd line
3. This is 3rd line
</div>
<br>
<div style="white-space: pre-line;">
1. This is 1st line
2. This is 2nd line
3. This is 3rd line
</div>
</div>
</body>
Which will result in
1. This is 1st line 2. This is 2nd line 3. This is 3rd line
1. This is 1st line
2. This is 2nd line
3. This is 3rd line
However, when I mount a Vue instance onto my main div, this is the result I get
1. This is 1st line 2. This is 2nd line 3. This is 3rd line
1. This is 1st line 2. This is 2nd line 3. This is 3rd line
The code for Vue instance in the script.js file is as follow
const test = Vue.createApp({
}).mount("#main")
Why did my white-space style get ignored completely?
pre-lineis taking the new line into account but it's probably not exactly the same between the behavior of the browser and what JS is doing with it. Still, it quite a minor problem here, since you could fix it by adding a<br />or even wrapping your lines into other parents. Not a big deal worth spending much time on IMO. TLDR: it's not ignored, just the compiler doing it's own stuff VS browser's default behavior.