mirror of https://github.com/sveltejs/svelte
fix: call `<svelte:component>` update to `this` only when it's dirty (#4192)
Closes #4129 --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/8342/head
parent
311193f1d7
commit
fbaf3cfc12
@ -0,0 +1,24 @@
|
||||
const calls = [];
|
||||
export default {
|
||||
props: {
|
||||
calls
|
||||
},
|
||||
|
||||
before_test() {
|
||||
calls.length = 0;
|
||||
},
|
||||
|
||||
async test({ assert, component, target, window }) {
|
||||
const buttons = target.querySelector('button');
|
||||
|
||||
assert.deepEqual(calls.length, 1);
|
||||
|
||||
const event = new window.MouseEvent('click');
|
||||
await buttons.dispatchEvent(event);
|
||||
|
||||
assert.deepEqual(calls.length, 1);
|
||||
|
||||
component.current_path = 'bar';
|
||||
assert.deepEqual(calls.length, 2);
|
||||
}
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
export let current_path = 'foo';
|
||||
export let calls;
|
||||
let i = 0;
|
||||
function getComponent(path) {
|
||||
calls.push(path);
|
||||
return null;
|
||||
}
|
||||
function onClick() {
|
||||
i = i + 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:component this={getComponent(current_path)} />
|
||||
<button on:click={onClick}>click me</button>
|
||||
{i}
|
Loading…
Reference in new issue