mirror of https://github.com/sveltejs/svelte
#16977 forgot one detail: While an element is outroing, the block of e.g. an if block can be triggered again, resolving to the same condition. In that case we have an in-between state where the element is still onscreen but already outroing. We have to detect this to not eagerly destroy the corresponding effect when we arrive at the outro/destroy logic. Fixes #16982pull/17186/head
parent
3b4b0adcd5
commit
d5377e8cf5
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: don't cancel transition of already outroing elements
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
import { flushSync } from '../../../../src/index-client.js';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, raf, target }) {
|
||||||
|
const [x, y] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
// Set second part of condition to false first...
|
||||||
|
y.click();
|
||||||
|
flushSync();
|
||||||
|
raf.tick(50);
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
'<button>toggle x</button> <button>toggle y</button> <p foo="0.5">hello</p>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// ...so that when both are toggled the block condition runs again
|
||||||
|
x.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
'<button>toggle x</button> <button>toggle y</button> <p foo="0.5">hello</p>'
|
||||||
|
);
|
||||||
|
|
||||||
|
raf.tick(100);
|
||||||
|
assert.htmlEqual(target.innerHTML, '<button>toggle x</button> <button>toggle y</button>');
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<script>
|
||||||
|
function foo(node) {
|
||||||
|
return {
|
||||||
|
duration: 100,
|
||||||
|
tick: (t, u) => {
|
||||||
|
node.setAttribute('foo', t)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let x = $state(true);
|
||||||
|
let y = $state(true);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => {
|
||||||
|
x = !x;
|
||||||
|
}}>toggle x</button>
|
||||||
|
<button onclick={() => {
|
||||||
|
y = !y;
|
||||||
|
}}>toggle y</button>
|
||||||
|
|
||||||
|
{#if x && y}
|
||||||
|
<p transition:foo>hello</p>
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue