-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Svelte 5: behavior of svelte-ignore is different between Svelte 4 and Svelte 5 #11482
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
Comments
Sorry, this is because there is comma between warning messages. |
But I found a strange pattern, so I'll reopen it. Svelte 4 (Ignore warnings properly)https://svelte.dev/repl/98c0dfc386d34e5ea8d15c8a7b1e54df?version=4.2.15 <!-- svelte-ignore a11y-label-has-associated-control a11y-no-noninteractive-tabindex -->
TEXT
<div class="dropdown">
<label tabindex="0">Click</label>
<ul tabindex="0"></ul>
</div> Svelte 5 (warnings are not ignored)<!-- svelte-ignore a11y_label_has_associated_control a11y_no_noninteractive_tabindex -->
TEXT
<div class="dropdown">
<label tabindex="0">Click</label>
<ul tabindex="0"></ul>
</div>
|
So I'm guessing the ignore comment on the second preview is not working because it's expecting to have an element right below the comment. But if the ignore comment is on the first line of the file, then the warnings for the entire file should be ignored, is that right? |
Instead of hacking an ignores array onto each node (and possibly degrading perf a bit because the object shape is mutated) we keep track of ignores in a stack. The new approach also avoids the indirection the old one had to do because the new approach looks upwards (checking if parent is a fragment) instead of iterating the children (checking for comments in them). Also fixes #11482 because text nodes of all shapes are ok
Instead of hacking an ignores array onto each node (and possibly degrading perf a bit because the object shape is mutated) we keep track of ignores in a stack. The new approach also avoids the indirection the old one had to do because the new approach looks upwards (checking if parent is a fragment) instead of iterating the children (checking for comments in them). As a bonus unknown code warnings are now in order (line-column-wise) with the other warnings. Also fixes #11482 because text nodes of all shapes are ok
Describe the bug
In Svelte 4, if we wrote
<!-- svelte-ignore —>
, warnings that occur on child elements were also ignored, but Svelte 5 is not.Reproduction
Svelte 4: https://svelte.dev/repl/6e5aed69999a482cbd33c8370d33b05e?version=4.2.15
Svelte 5: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE2WPwUrEMBBAfyWOF4XGuuKpxIL4A96NhGwzuw6mk5JMq0vpv0tbPXmceY83zAwniligeZuBfY_QwPMwQAVyGdahTBgFoYKSxtytGxNoai1bMVdaq51rOnPKqPzhcHGcHCcmFsy-E5rQiT8SB_yudiH6I0b34YvzpaSOvGBwXWLJKSqtt_h87b88iXrNqaeCdxlLihPePD7cLiu3YraM-ms_Wbi30L5E6j5NvbH2Vxz_WaYedzrX25nFsqnXv6CCPgU6EQZoJI-4vC8_ZPo62iMBAAA=
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: