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

HTML comment is duplicated on format #400

Closed
drzax opened this issue Aug 29, 2023 · 1 comment · Fixed by #425
Closed

HTML comment is duplicated on format #400

drzax opened this issue Aug 29, 2023 · 1 comment · Fixed by #425
Labels
bug Something isn't working

Comments

@drzax
Copy link

drzax commented Aug 29, 2023

This looks to be a very similar issue to #205.

The following works as a minimum repro in Svelte for VS Code v107.10.0

<div>
  <!-- this is duplicated on format -->
  <style></style>
</div>

But both of the following work as expected

<div>
  <!-- this is *not* duplicated on format -->
  <p>Hi</p>
</div>
<!-- this is *not* duplicated on format -->
<style></style>

So it appears to be the combination of the <style> tag and nested structure that triggers the bug.

@dummdidumm dummdidumm added the bug Something isn't working label Aug 29, 2023
@alexlafroscia
Copy link

I'm seeing this as well, but with a comment preceding a <script> tag rather than a <style> tag.

Interestingly, it only happens when that <script> tag exists within a <svelte:head> tag, like so:

<svelte:head>
  <!-- Fathom Analytics -->
  <script
    src="https://xxx.alexlafroscia.com/script.js"
    data-site="xxx"
    data-spa="auto"
    defer
  ></script>
</svelte:head>

The <!-- Fathom Analytics --> line is repeated each time Prettier formats the file

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants