fix binding to module-level variables (#4352)

pull/4376/head
Conduitry 5 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 ## 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)) * 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 ## 3.18.1

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