fix: improve whitespace handling (#9912)

revert
pull/9914/head
Dominic Gannaway 1 year ago committed by GitHub
parent f2d111264c
commit 3a4a09102c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: improve whitespace handling

@ -177,8 +177,9 @@ export function clean_nodes(
node.data = node.data.replace(regex_whitespaces_strict, ' ');
node.raw = node.raw.replace(regex_whitespaces_strict, ' ');
if (
(last_text === null || !regex_ends_with_whitespaces.test(last_text.data)) &&
(!can_remove_entirely || node.data !== ' ')
(last_text === null && !can_remove_entirely) ||
node.data !== ' ' ||
node.data.charCodeAt(0) === 160 // non-breaking space
) {
trimmed.push(node);
}

@ -0,0 +1,8 @@
import { test } from '../../test';
export default test({
compileOptions: {
dev: true // Render in dev mode to check that the validation error is not thrown
},
html: `A\nB\nC\nD`
});

@ -0,0 +1,5 @@
A
{#snippet snip()}C{/snippet}
B
{@render snip()}
D
Loading…
Cancel
Save