Whitespace is removed when a comment appears between a tag and an interpolation
Vue version
3.2.37
Link to minimal reproduction
Steps to reproduce
In your template, have a tag followed by an interpolation that returns text, like this:
<template>
<div class="foo">
<h1>Message:</h1>
{{ msg }}
</div>
</template>
Then, add a comment between the h1 and the interpolation:
<template>
<div class="foo">
<h1>Message:</h1>
<!-- A comment explaining the interpolation below -->
{{ msg }}
</div>
</template>
What is expected?
Adding the comment should not affect the output (other than the comment being added to the output in dev mode, perhaps)
What is actually happening?
Without the comment, a space is rendered between the tag and the interpolation (as expected). With the comment, that space is not rendered, which can cause layout issues. This only happens when the text is generated by an interpolation; if it's static text, the space is always there, regardless of whether there's a comment or not.
System Info
System:
OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Memory: 1.20 GB / 15.39 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.9.1 - ~/.nvm/versions/node/v16.9.1/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v16.9.1/bin/yarn
npm: 8.5.3 - ~/.nvm/versions/node/v16.9.1/bin/npm
Browsers:
Chrome: 103.0.5060.134
Chromium: 103.0.5060.53
Firefox: 102.0
Any additional comments?
No response