diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index bc13014a29..1fae0aedcc 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -327,13 +327,14 @@ export default class InlineComponentWrapper extends Wrapper { contextual_dependencies.push(object, property); } - const args = ['value']; + const value = block.get_unique_name('value'); + const args = [value]; if (contextual_dependencies.length > 0) { args.push(`{ ${contextual_dependencies.join(', ')} }`); block.builders.init.add_block(deindent` - function ${name}(value) { - if (ctx.${name}.call(null, value, ctx)) { + function ${name}(${value}) { + if (ctx.${name}.call(null, ${value}, ctx)) { ${updating} = true; } } @@ -342,8 +343,8 @@ export default class InlineComponentWrapper extends Wrapper { block.maintain_context = true; // TODO put this somewhere more logical } else { block.builders.init.add_block(deindent` - function ${name}(value) { - if (ctx.${name}.call(null, value)) { + function ${name}(${value}) { + if (ctx.${name}.call(null, ${value})) { ${updating} = true; } } @@ -352,7 +353,7 @@ export default class InlineComponentWrapper extends Wrapper { const body = deindent` function ${name}(${args.join(', ')}) { - ${lhs} = value; + ${lhs} = ${value}; return ${component.invalidate(dependencies[0])} } `; diff --git a/test/runtime/samples/deconflict-value/Widget.svelte b/test/runtime/samples/deconflict-value/Widget.svelte new file mode 100644 index 0000000000..909dc03c89 --- /dev/null +++ b/test/runtime/samples/deconflict-value/Widget.svelte @@ -0,0 +1,3 @@ + diff --git a/test/runtime/samples/deconflict-value/_config.js b/test/runtime/samples/deconflict-value/_config.js new file mode 100644 index 0000000000..ac21772c8c --- /dev/null +++ b/test/runtime/samples/deconflict-value/_config.js @@ -0,0 +1,6 @@ +export default { + html: ` +

Reactive: foo

+

Value: foo

+ ` +}; diff --git a/test/runtime/samples/deconflict-value/main.svelte b/test/runtime/samples/deconflict-value/main.svelte new file mode 100644 index 0000000000..07b7c2e1f0 --- /dev/null +++ b/test/runtime/samples/deconflict-value/main.svelte @@ -0,0 +1,9 @@ + + + +

Reactive: {reactive}

+

Value: {value}