-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
svelte:component
spread props change not picked up (#9006)
- Loading branch information
Showing
6 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: `svelte:component` spread props change not picked up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp1.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let value; | ||
</script> | ||
|
||
<p>value(1) = {value}</p> |
5 changes: 5 additions & 0 deletions
5
packages/svelte/test/runtime/samples/dynamic-component-spread-props/Comp2.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let value; | ||
</script> | ||
|
||
<p>value(2) = {value}</p> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/test/runtime/samples/dynamic-component-spread-props/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export default { | ||
html: ` | ||
<p>value(1) = 1</p> | ||
<button>Toggle Component</button> | ||
`, | ||
|
||
async test({ assert, window, target }) { | ||
const button = target.querySelector('button'); | ||
await button.dispatchEvent(new window.Event('click')); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<p>value(2) = 2</p> | ||
<button>Toggle Component</button> | ||
` | ||
); | ||
await button.dispatchEvent(new window.Event('click')); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<p>value(1) = 1</p> | ||
<button>Toggle Component</button> | ||
` | ||
); | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/svelte/test/runtime/samples/dynamic-component-spread-props/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import Comp1 from './Comp1.svelte'; | ||
import Comp2 from './Comp2.svelte'; | ||
let view = Comp1; | ||
$: props = view === Comp1 ? { value: 1 } : { value: 2 }; | ||
</script> | ||
|
||
<svelte:component this={view} {...props} /> | ||
|
||
<button on:click={(e) => (view = view === Comp1 ? Comp2 : Comp1)}>Toggle Component</button> |