-
Notifications
You must be signed in to change notification settings - Fork 98
Plugin is incorrectly rewriting empty non-void HTML tags in svelte files #377
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
Please consider making the defaults align with the HTML standard as well as the behavior of prettier core. Further, my initial motivation to report this issue was because I found it frustrating to write layout structure in HTML only to have several elements being rewritten as |
- add `svelteSelfCloseComponents` and `svelteSelfCloseElements` to specify whether or not empty elements/components should self-close. `svelteStrictMode` no longer has any effect on this behavior - `svelteAllowShorthand` now takes precedence over `svelteStrictMode`, which no longer has any effect on that behavior - `svelteStrictMode` is deprecated as future Svelte versions might coerce numbers coming from mustache tags inside strings into strings closes #348 closes #284 closes #279 closes #238 related to #377
- whether or not empty elements/components should self-close is now left to the user - in other words, if you write `<div />` or `<Component />` that stays as is, and so does `<div></div>`/`<Component></Component>`. `svelteStrictMode` no longer has any effect on this behavior - `svelteAllowShorthand` now takes precedence over `svelteStrictMode`, which no longer has any effect on that behavior - `svelteStrictMode` is deprecated as future Svelte versions might coerce numbers coming from mustache tags inside strings into strings closes #348 closes #284 closes #279 closes #238 related to #377 superseeds / closes #379 as less options = better
- whether or not empty elements/components should self-close is now left to the user - in other words, if you write `<div />` or `<Component />` that stays as is, and so does `<div></div>`/`<Component></Component>`. `svelteStrictMode` only has effect on elements (not allowing self-closing non-void-ones) - `svelteAllowShorthand` now takes precedence over `svelteStrictMode`, which no longer has any effect on that behavior closes #284 closes #279 closes #238 related to #348 related to #377 superseeds / closes #379 as less options = better
Version 3 of this plugin will leave tags as-is, so writing |
I'm not in favour of aligning with Prettier in case of void elements. They're explicitly mentioned as not self-closing. Prettier takes an opinionated stance on the matter and imposes its choice on the developer. I wouldn't argue, if it were up to the developer, but the HTML specs are very clear on void elements. For now, I can enable |
Related sveltejs/svelte#11052 |
Related: https://github.com/awmottaz/prettier-plugin-void-html Doesn't work with .svelte files thought. |
Rich mentioned that the latest version on prettier-plugin-svelte should prevent prettier from braking html by converting html tags into void tags. But as I can see, 3.2.3 still replaces |
No this will stay as is for the foreseeable future to align with Prettier's HTML formatting. |
Within
.svelte
files, this plugin rewrites empty<div></div>
to<div />
which is an HTML error according to the whatwg spec:non-void-html-element-start-tag-with-trailing-solidus
The list of valid void elements:
area, base, br, col, embed, hr, img, input, link, meta, source, track, wbr
The text was updated successfully, but these errors were encountered: