svelteStrictMode
still causes Svelte components to self-close
svelteSelfCloseComponents
and svelteSelfCloseElements
to specify whether or not empty elements/components should self-close. svelteStrictMode
no longer has any effect on this behavior.
<div></div>
it stays as this, and if the user says <div />
that also stays like this. This is what Prettier currently does in both HTML and JSXsvelteAllowShorthand
now takes precedence over svelteStrictMode
, which no longer has any effect on that behaviorsvelteStrictMode
is deprecated as future Svelte versions might coerce numbers coming from mustache tags inside strings into stringscloses #348 closes #284 closes #279 closes #238 related to #377
<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 behaviorcloses #284 closes #279 closes #238 related to #348 related to #377 superseeds / closes #379 as less options = better
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
There's no option currently to stop this behavior, components without content are always self closed.
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.
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.
In version 3, components will be left as the user wrote them and not format one into the other.