From 539169b61e058e8f0409cd02c354571d136cbc32 Mon Sep 17 00:00:00 2001 From: Jeremiasz Major Date: Fri, 12 Apr 2024 16:32:13 +0200 Subject: [PATCH] fix: do not force slots to be self-closed (#435) Related to sveltejs/kit#12102 --- src/print/index.ts | 2 +- test/printer/samples/self-closing-tags-lenient.html | 2 ++ test/printer/samples/self-closing-tags.html | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/printer/samples/self-closing-tags-lenient.html diff --git a/src/print/index.ts b/src/print/index.ts index f525b396..44ad01f1 100644 --- a/src/print/index.ts +++ b/src/print/index.ts @@ -215,10 +215,10 @@ export function print(path: FastPath, options: ParserOptions, print: PrintFn): D ((((node.type === 'Element' && !options.svelteStrictMode) || node.type === 'Head' || node.type === 'InlineComponent' || + node.type === 'Slot' || node.type === 'SlotTemplate' || node.type === 'Title') && didSelfClose) || - node.type === 'Slot' || node.type === 'Window' || selfClosingTags.indexOf(node.name) !== -1 || isDoctypeTag); diff --git a/test/printer/samples/self-closing-tags-lenient.html b/test/printer/samples/self-closing-tags-lenient.html new file mode 100644 index 00000000..23ef5f14 --- /dev/null +++ b/test/printer/samples/self-closing-tags-lenient.html @@ -0,0 +1,2 @@ + + diff --git a/test/printer/samples/self-closing-tags.html b/test/printer/samples/self-closing-tags.html index 662774ba..c9c7c0f4 100644 --- a/test/printer/samples/self-closing-tags.html +++ b/test/printer/samples/self-closing-tags.html @@ -6,6 +6,10 @@ + + + +