fix: correctly transform `pre` with no content (#14973)

Closes #14971
main
Paolo Ricciuti 1 day ago committed by GitHub
parent 41fb51349e
commit 9b6e65fbeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly transform `pre` with no content

@ -272,7 +272,7 @@ export function clean_nodes(
var first = trimmed[0]; var first = trimmed[0];
// initial newline inside a `<pre>` is disregarded, if not followed by another newline // initial newline inside a `<pre>` is disregarded, if not followed by another newline
if (parent.type === 'RegularElement' && parent.name === 'pre' && first.type === 'Text') { if (parent.type === 'RegularElement' && parent.name === 'pre' && first?.type === 'Text') {
const text = first.data.replace(regex_starts_with_newline, ''); const text = first.data.replace(regex_starts_with_newline, '');
if (text !== first.data) { if (text !== first.data) {
const tmp = text.replace(regex_starts_with_newline, ''); const tmp = text.replace(regex_starts_with_newline, '');

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `<pre></pre>`
});
Loading…
Cancel
Save