fix: correctly transform `pre` with no content

pull/14973/head
paoloricciuti 2 years ago
parent 41fb51349e
commit 7777880028

@ -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];
// 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, '');
if (text !== first.data) {
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