Skip to content

fix $$props reactivity in fallback of a slot #5375

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

Merged
merged 2 commits into from
Sep 10, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Fix using `<svelte:component>` in `{:catch}` ([#5259](https://github.com/sveltejs/svelte/issues/5259))
* Fix setting one-way bound `<input>` `value` to `undefined` when it has spread attributes ([#5270](https://github.com/sveltejs/svelte/issues/5270))
* Fix deep two-way bindings inside an `{#each}` involving a store ([#5286](https://github.com/sveltejs/svelte/issues/5286))
* Fix reactivity of `$$props` in slot fallback content ([#5367](https://github.com/sveltejs/svelte/issues/5367))

## 3.24.1

Expand Down
2 changes: 2 additions & 0 deletions src/compiler/compile/render_dom/wrappers/shared/is_dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Var } from '../../../../interfaces';
import { is_reserved_keyword } from '../../../utils/reserved_keywords';

export default function is_dynamic(variable: Var) {
if (variable) {
if (variable.mutated || variable.reassigned) return true; // dynamic internal state
if (!variable.module && variable.writable && variable.export_name) return true; // writable props
if (is_reserved_keyword(variable.name)) return true;
}

return false;
Expand Down
1 change: 1 addition & 0 deletions test/runtime/samples/component-slot-fallback-6/Foo.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<slot />
9 changes: 9 additions & 0 deletions test/runtime/samples/component-slot-fallback-6/Inner.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
import Foo from './Foo.svelte';
</script>

<Foo>
<slot>
{JSON.stringify($$props)}
</slot>
</Foo>
18 changes: 18 additions & 0 deletions test/runtime/samples/component-slot-fallback-6/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// $$props reactivity in slot fallback
export default {
html: `
<input>
{"value":""}
`,

async test({ assert, target, window }) {
const input = target.querySelector("input");
input.value = "abc";
await input.dispatchEvent(new window.Event('input'));

assert.htmlEqual(target.innerHTML, `
<input>
{"value":"abc"}
`);
}
};
8 changes: 8 additions & 0 deletions test/runtime/samples/component-slot-fallback-6/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script>
import Inner from "./Inner.svelte";
let value = '';
</script>

<input bind:value />

<Inner {value} />