fix: permit whitespace within template scripts ()

pull/10589/head
Dominic Gannaway 1 year ago committed by GitHub
parent a2fbef2050
commit ec52c75cc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: permit whitespace within template scripts

@ -2081,7 +2081,7 @@ export const template_visitors = {
node.fragment.nodes,
context.path,
child_metadata.namespace,
state.preserve_whitespace,
node.name === 'script' || state.preserve_whitespace,
state.options.preserveComments
);

@ -0,0 +1,8 @@
import { test } from '../../test';
export default test({
test({ assert, component, window }) {
document.dispatchEvent(new Event('DOMContentLoaded'));
assert.equal(window.document.querySelector('button')?.textContent, 'Hello world');
}
});

@ -0,0 +1,10 @@
<svelte:head>
<script>
// A comment
const val = 'Hello world';
document.addEventListener('DOMContentLoaded', () => {
document.querySelector('button').textContent = val;
});
</script>
</svelte:head>
<button />
Loading…
Cancel
Save