Skip to content

svelteStrictMode still causes Svelte components to self-close #238

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

Closed
madupuis90 opened this issue Jul 11, 2021 · 4 comments · Fixed by #380
Closed

svelteStrictMode still causes Svelte components to self-close #238

madupuis90 opened this issue Jul 11, 2021 · 4 comments · Fixed by #380
Labels
breaking change enhancement New feature or request

Comments

@madupuis90
Copy link

I tried both of these options to stop that behaviour :

  "svelte.plugin.svelte.format.config.svelteStrictMode": true,
  "svelte.plugin.html.completions.enable": false

With "svelte.plugin.svelte.format.config.svelteStrictMode": true, <div></div> does not become <div /> when saving.
But <Container></Container> will still become <Container />

I tried to disable other html formatting but couldn't find any option that prevents self-closing of Svelte components

@dummdidumm
Copy link
Member

There's no option currently to stop this behavior, components without content are always self closed.

@dummdidumm dummdidumm added the enhancement New feature or request label Jul 11, 2021
@madupuis90
Copy link
Author

Alright thanks! It's probably a niche case, but I usually create multiple components and paste them before filling them one by one and right now I had to go back and re-open the self closing each time.

@Nukiloco
Copy link

I have a lot of elements that I like to keep open instead of being self closed. I think an option to disable self closing should be added in. Some of my components are designed to have slot elements and its annoying that some of my elements automatically self close.

dummdidumm added a commit that referenced this issue Jul 14, 2023
- 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
dummdidumm added a commit that referenced this issue Jul 14, 2023
- 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
@dummdidumm
Copy link
Member

In version 3, components will be left as the user wrote them and not format one into the other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change enhancement New feature or request
Projects
None yet
3 participants