mirror of https://github.com/sveltejs/svelte
parent
86eb09b76e
commit
6150c4dc49
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: run render effects created during traversal alongside existing render effects, in tree order
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['client', 'hydrate'],
|
||||||
|
|
||||||
|
test({ assert, target, logs }) {
|
||||||
|
const input = /** @type {HTMLInputElement} */ (target.querySelector('input'));
|
||||||
|
|
||||||
|
assert.deepEqual(logs, ['a', 'hello', 'c', 'hello']);
|
||||||
|
logs.length = 0;
|
||||||
|
|
||||||
|
input.value = 'hello!';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
flushSync();
|
||||||
|
assert.deepEqual(logs, ['a', 'hello!', 'c', 'hello!']);
|
||||||
|
logs.length = 0;
|
||||||
|
|
||||||
|
input.value = 'hello!!';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
flushSync();
|
||||||
|
assert.deepEqual(logs, ['a', 'hello!!', 'b', 'hello!!', 'c', 'hello!!']);
|
||||||
|
logs.length = 0;
|
||||||
|
|
||||||
|
input.value = 'hello!!!';
|
||||||
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
flushSync();
|
||||||
|
assert.deepEqual(logs, ['a', 'hello!!!', 'b', 'hello!!!', 'c', 'hello!!!']);
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `<input /><p>hello!!!</p><p>hello!!!</p><p>hello!!!</p>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
<script>
|
||||||
|
let message = $state('hello');
|
||||||
|
|
||||||
|
function log(value, label) {
|
||||||
|
console.log(label, value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input bind:value={message} />
|
||||||
|
|
||||||
|
{#if true}
|
||||||
|
<p>{log(message, 'a')}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if message.length > 6}
|
||||||
|
<p>{log(message, 'b')}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if true}
|
||||||
|
<p>{log(message, 'c')}</p>
|
||||||
|
{/if}
|
||||||
Loading…
Reference in new issue