Skip to content
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

Using $bindable with offsetWidth produces error after svelte 144 #12028

Closed
minht11 opened this issue Jun 13, 2024 · 0 comments · Fixed by #12091
Closed

Using $bindable with offsetWidth produces error after svelte 144 #12028

minht11 opened this issue Jun 13, 2024 · 0 comments · Fixed by #12091
Labels
Milestone

Comments

@minht11
Copy link

minht11 commented Jun 13, 2024

Describe the bug

After upgrading from svelte 144 to latest 154 I am experiencing error, which is bit involved to reproduce. It only occurs with specific code.

<script>
	let { offsetWidth = $bindable(0) } = $props()

	const queryList = window.matchMedia('(max-width: 767px)')

	let isMatched = $state(queryList.matches)

	queryList.addEventListener('change', (event) => {
		isMatched = event.matches
	})
</script>

{#if isMatched}
	<div bind:offsetWidth>Element</div>
{/if}

Run code above, resize page, observe error.
image

Likely related to #11934 because of same error but looking into LayerCake code did not find bindable so not sure.

Reproduction

Reproduction

Logs

No response

System Info

Svelte 5.0.0-next.154

Severity

blocking an upgrade

@dummdidumm dummdidumm added this to the 5.0 milestone Jun 13, 2024
@dummdidumm dummdidumm added the bug label Jun 13, 2024
dummdidumm added a commit that referenced this issue Jun 19, 2024
The `update` function could cause a read, which would end up being tracked in the effect, and said effect would then run multiple times when it should only run once

fixes #11934
fixes #12028
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