Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code generation when $$props is present #3069

Merged
merged 2 commits into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/compile/render-dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function dom(
${$$props} => {
${uses_props && component.invalidate('$$props', `$$props = @assign(@assign({}, $$props), $$new_props)`)}
${writable_props.map(prop =>
`if ('${prop.export_name}' in $$props) ${component.invalidate(prop.name, `${prop.name} = $$props.${prop.export_name}`)};`
`if ('${prop.export_name}' in ${$$props}) ${component.invalidate(prop.name, `${prop.name} = ${$$props}.${prop.export_name}`)};`
)}
${component.slots.size > 0 &&
`if ('$$scope' in ${$$props}) ${component.invalidate('$$scope', `$$scope = ${$$props}.$$scope`)};`}
Expand Down
6 changes: 6 additions & 0 deletions test/runtime/samples/binding-using-props/TextInput.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
export let actualValue;
let x = $$props;
</script>

<input bind:value={actualValue}>
14 changes: 14 additions & 0 deletions test/runtime/samples/binding-using-props/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
async test({ assert, target, window }) {
const input = target.querySelector('input');

const event = new window.Event('input');
input.value = 'changed';
await input.dispatchEvent(event);

assert.htmlEqual(target.innerHTML, `
<input>
<p>changed</p>
`);
}
};
7 changes: 7 additions & 0 deletions test/runtime/samples/binding-using-props/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import Input from './TextInput.svelte';
export let actualValue = '';
</script>

<Input bind:actualValue />
<p>{actualValue}</p>