diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f4460cde48e..2166ca4c9c96 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
index f1c57ed09415..28b3c938f9d3 100644
--- a/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
+++ b/src/compiler/compile/render_dom/wrappers/InlineComponent/index.ts
@@ -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])};
}
`;
diff --git a/test/runtime/samples/deconflict-contextual-bind/Widget.svelte b/test/runtime/samples/deconflict-contextual-bind/Widget.svelte
new file mode 100644
index 000000000000..3aaa59b74757
--- /dev/null
+++ b/test/runtime/samples/deconflict-contextual-bind/Widget.svelte
@@ -0,0 +1,3 @@
+
diff --git a/test/runtime/samples/deconflict-contextual-bind/_config.js b/test/runtime/samples/deconflict-contextual-bind/_config.js
new file mode 100644
index 000000000000..7602cde02323
--- /dev/null
+++ b/test/runtime/samples/deconflict-contextual-bind/_config.js
@@ -0,0 +1,3 @@
+export default {
+ preserveIdentifiers: true
+};
diff --git a/test/runtime/samples/deconflict-contextual-bind/main.svelte b/test/runtime/samples/deconflict-contextual-bind/main.svelte
new file mode 100644
index 000000000000..fe91deca17f1
--- /dev/null
+++ b/test/runtime/samples/deconflict-contextual-bind/main.svelte
@@ -0,0 +1,8 @@
+
+
+{#each values as value}
+
+{/each}