mirror of https://github.com/sveltejs/svelte
fix: `svelte:component` spread props change not picked up (#9006)
fix #9003, amend #8946 (comment)pull/9008/head
parent
3dccf711f8
commit
a2b6401c43
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: `svelte:component` spread props change not picked up
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let value;
|
||||
</script>
|
||||
|
||||
<p>value(1) = {value}</p>
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let value;
|
||||
</script>
|
||||
|
||||
<p>value(2) = {value}</p>
|
@ -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>
|
||||
`
|
||||
);
|
||||
}
|
||||
};
|
@ -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>
|
Loading…
Reference in new issue