mirror of https://github.com/sveltejs/svelte
fix: ensure `bind:this` happens before transitions and animations (#12497)
* fix: ensure `bind:this` happens before transitions and animations * testpull/12504/head
parent
919e7adaa8
commit
dd9ade7736
@ -0,0 +1,13 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(target.innerHTML, `<button>toggle</button> <nav>hello</nav>`);
|
||||
}
|
||||
});
|
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
function fly(node, params) {
|
||||
return {};
|
||||
}
|
||||
|
||||
let show = $state(false);
|
||||
let sidebar = $state();
|
||||
</script>
|
||||
|
||||
<button onclick={() => (show = !show)}>toggle</button>
|
||||
|
||||
{#if show}
|
||||
<!-- bind:this should be applied before any of the directives -->
|
||||
<nav transition:fly={{ x: sidebar.offsetWidth }} bind:this={sidebar}>hello</nav>
|
||||
{/if}
|
Loading…
Reference in new issue