mirror of https://github.com/sveltejs/svelte
fix: synchronise element bindings (#10512)
fixes #10511 We used the animation frame dance previously where the `$effect` timing was slightly different and did not wait on its children before rerunning. With that changed now everything false into place nicely. --------- Co-authored-by: Rich Harris <rich.harris@vercel.com> Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/10605/head
parent
a2164ff9f4
commit
6afaf75a37
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: tweak initial `bind:clientWidth/clientHeight/offsetWidth/offsetHeight` update timing
|
@ -0,0 +1,13 @@
|
||||
import { test } from '../../assert';
|
||||
import { log } from './log.js';
|
||||
|
||||
export default test({
|
||||
async test({ assert }) {
|
||||
await new Promise((fulfil) => setTimeout(fulfil, 0));
|
||||
|
||||
assert.deepEqual(log, [
|
||||
[false, 0, 0],
|
||||
[true, 100, 100]
|
||||
]);
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
/** @type {any[]} */
|
||||
export const log = [];
|
@ -0,0 +1,23 @@
|
||||
<script>
|
||||
import { log } from './log.js';
|
||||
|
||||
let w = 0;
|
||||
let h = 0;
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
let div;
|
||||
|
||||
$: {
|
||||
log.push([!!div, w, h]);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div bind:this={div} bind:clientWidth={w} bind:clientHeight={h} class="box"></div>
|
||||
|
||||
<style>
|
||||
.box {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background: #ff3e00;
|
||||
}
|
||||
</style>
|
Loading…
Reference in new issue