Skip to content

Svelte 5: Regular scripts no longer execute #9484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brunnerh opened this issue Nov 16, 2023 · 0 comments · Fixed by #10416
Closed

Svelte 5: Regular scripts no longer execute #9484

brunnerh opened this issue Nov 16, 2023 · 0 comments · Fixed by #10416
Labels
Milestone

Comments

@brunnerh
Copy link
Member

brunnerh commented Nov 16, 2023

Describe the bug

Scripts that are not the component top-level script do not seem to execute.
Apparently the way that <script> gets inserted into the document matters for execution, maybe that needs a special case.

Reproduction

<div>
	<!-- NOT a Svelte script -->
	<script>
		function logMessage(text) {
			console.log(text);
		}
		console.log('logMessage is', typeof logMessage);
	</script>
</div>

<button onclick={() => eval("logMessage('Hello')")}>
	Log "Hello"
</button>

v4
v5

Thought that maybe isolating the <script> so it would be inserted separately using {#if true} instead of a div would maybe help, but it did not.

Logs

No response

System Info

REPL

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants