[fix] correctly track dependencies of let: bindings (#7448)

Fixes #7440
pull/7452/head
Tan Li Hau 2 years ago committed by GitHub
parent 39d2dfcbcd
commit 4aff59b080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,6 +6,7 @@
* Fix `{@const}` tag not working inside Component when there's no `let:` [#7189](https://github.com/sveltejs/svelte/issues/7189)
* Ignore comments in `{#each}` blocks when containing elements with `animate:` ([#3999](https://github.com/sveltejs/svelte/issues/3999))
* Add a third parameter to the returned function of `createEventDispatcher` that allows passing an object of `{ cancelable: true }` to create a cancelable custom event. The returned function when called will also return a boolean depending on whether the event is cancelled ([#7064](https://github.com/sveltejs/svelte/pull/7064))
* Fix value of `let:` bindings not updating in certain cases ([#7440](https://github.com/sveltejs/svelte/issues/7440))
## 3.47.0

@ -90,7 +90,7 @@ export default class Expression {
}
if (template_scope.is_let(name)) {
if (!function_expression) { // TODO should this be `!lazy` ?
if (!lazy) {
contextual_dependencies.add(name);
dependencies.add(name);
}

@ -0,0 +1,5 @@
<script>
export let prop
</script>
<slot value={prop} />

@ -0,0 +1,25 @@
let logs;
function log(value) {
logs.push(value);
}
export default {
props: {
prop: 'a',
log
},
html: '<button></button>',
before_test() {
logs = [];
},
async test({ assert, component, target, window }) {
const button = target.querySelector('button');
await button.dispatchEvent(new window.MouseEvent('click'));
assert.deepEqual(logs, ['a']);
component.prop = 'b';
await button.dispatchEvent(new window.MouseEvent('click'));
assert.deepEqual(logs, ['a', 'b']);
}
};

@ -0,0 +1,11 @@
<script>
import Outer from './Outer.svelte'
import Inner from './Inner.svelte'
export let prop
export let log;
</script>
<Outer {prop} let:value>
<Inner><button on:click={() => { log(value); }} /></Inner>
</Outer>
Loading…
Cancel
Save