Skip to content

Commit 539169b

Browse files
authored
fix: do not force slots to be self-closed (#435)
Related to sveltejs/kit#12102
1 parent 601ee41 commit 539169b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/print/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,10 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D
215215
((((node.type === 'Element' && !options.svelteStrictMode) ||
216216
node.type === 'Head' ||
217217
node.type === 'InlineComponent' ||
218+
node.type === 'Slot' ||
218219
node.type === 'SlotTemplate' ||
219220
node.type === 'Title') &&
220221
didSelfClose) ||
221-
node.type === 'Slot' ||
222222
node.type === 'Window' ||
223223
selfClosingTags.indexOf(node.name) !== -1 ||
224224
isDoctypeTag);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<slot />
2+
<slot></slot>

test/printer/samples/self-closing-tags.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
<MyComponent />
88

9+
<!-- TODO: self-closing slot shouldn't be allowed in the next major version -->
10+
<slot />
11+
<slot></slot>
12+
913
<img />
1014

1115
<input />

0 commit comments

Comments
 (0)