fix binding to module-level variables (#4352)

pull/4376/head
Conduitry 4 years ago committed by GitHub
parent 83d461f537
commit 3cbe38cbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@
## Unreleased
* Fix binding to module-level variables ([#4086](https://github.com/sveltejs/svelte/issues/4086))
* Disallow attribute/prop names from matching two-way-bound names or `{shorthand}` attribute/prop names ([#4325](https://github.com/sveltejs/svelte/issues/4325))
## 3.18.1

@ -161,11 +161,14 @@ export default class Renderer {
}
if (
variable &&
!variable.referenced &&
!variable.is_reactive_dependency &&
!variable.export_name &&
!name.startsWith('$$')
variable && (
variable.module || (
!variable.referenced &&
!variable.is_reactive_dependency &&
!variable.export_name &&
!name.startsWith('$$')
)
)
) {
return value || name;
}

@ -0,0 +1,4 @@
export default {
skip_if_ssr: true,
html: '<div>object</div>'
};

@ -0,0 +1,11 @@
<script context='module'>
let foo;
</script>
<script>
import { onMount } from 'svelte';
let bar;
onMount(() => bar = foo);
</script>
<div bind:this={foo}>{typeof bar}</div>
Loading…
Cancel
Save