Skip to content

Commit 51e2626

Browse files
authored
fix $$props reactivity in fallback of a slot (#5375)
1 parent b1c67a1 commit 51e2626

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Fix using `<svelte:component>` in `{:catch}` ([#5259](https://github.com/sveltejs/svelte/issues/5259))
1212
* Fix setting one-way bound `<input>` `value` to `undefined` when it has spread attributes ([#5270](https://github.com/sveltejs/svelte/issues/5270))
1313
* Fix deep two-way bindings inside an `{#each}` involving a store ([#5286](https://github.com/sveltejs/svelte/issues/5286))
14+
* Fix reactivity of `$$props` in slot fallback content ([#5367](https://github.com/sveltejs/svelte/issues/5367))
1415

1516
## 3.24.1
1617

src/compiler/compile/render_dom/wrappers/shared/is_dynamic.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { Var } from '../../../../interfaces';
2+
import { is_reserved_keyword } from '../../../utils/reserved_keywords';
23

34
export default function is_dynamic(variable: Var) {
45
if (variable) {
56
if (variable.mutated || variable.reassigned) return true; // dynamic internal state
67
if (!variable.module && variable.writable && variable.export_name) return true; // writable props
8+
if (is_reserved_keyword(variable.name)) return true;
79
}
810

911
return false;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<slot />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script>
2+
import Foo from './Foo.svelte';
3+
</script>
4+
5+
<Foo>
6+
<slot>
7+
{JSON.stringify($$props)}
8+
</slot>
9+
</Foo>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// $$props reactivity in slot fallback
2+
export default {
3+
html: `
4+
<input>
5+
{"value":""}
6+
`,
7+
8+
async test({ assert, target, window }) {
9+
const input = target.querySelector("input");
10+
input.value = "abc";
11+
await input.dispatchEvent(new window.Event('input'));
12+
13+
assert.htmlEqual(target.innerHTML, `
14+
<input>
15+
{"value":"abc"}
16+
`);
17+
}
18+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script>
2+
import Inner from "./Inner.svelte";
3+
let value = '';
4+
</script>
5+
6+
<input bind:value />
7+
8+
<Inner {value} />

0 commit comments

Comments
 (0)