deconflict `value` parameter in contextual bindings (#4452)

pull/4453/head
Conduitry 5 years ago committed by GitHub
parent 138213ca3c
commit 3bfa0e5cd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@
## Unreleased
* Deconflict `value` parameter name used in contextual bindings ([#4445](https://github.com/sveltejs/svelte/issues/4445))
* Fix dev mode validation of `{#each}` blocks using strings ([#4450](https://github.com/sveltejs/svelte/issues/4450))
## 3.19.0

@ -332,8 +332,7 @@ export default class InlineComponentWrapper extends Wrapper {
contextual_dependencies.push(object.name, property.name);
}
const value = block.get_unique_name('value');
const params: any[] = [value];
const params = [x`#value`];
if (contextual_dependencies.length > 0) {
const args = [];
@ -349,23 +348,23 @@ export default class InlineComponentWrapper extends Wrapper {
block.chunks.init.push(b`
function ${id}(${value}) {
${callee}.call(null, ${value}, ${args});
function ${id}(#value) {
${callee}.call(null, #value, ${args});
}
`);
block.maintain_context = true; // TODO put this somewhere more logical
} else {
block.chunks.init.push(b`
function ${id}(${value}) {
${callee}.call(null, ${value});
function ${id}(#value) {
${callee}.call(null, #value);
}
`);
}
const body = b`
function ${id}(${params}) {
${lhs} = ${value};
${lhs} = #value;
${renderer.invalidate(dependencies[0])};
}
`;

@ -0,0 +1,3 @@
<script>
export let prop;
</script>

@ -0,0 +1,3 @@
export default {
preserveIdentifiers: true
};

@ -0,0 +1,8 @@
<script>
import Widget from './Widget.svelte';
const values = ['foo', 'bar'];
</script>
{#each values as value}
<Widget bind:value/>
{/each}
Loading…
Cancel
Save