-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adjust render effect ordering (#10783)
We can simplify pre effects by not doing the flush logic at all now. Instead we can move the flushing logic to the only place its needed – for beforeUpdate
- Loading branch information
Showing
8 changed files
with
63 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"svelte": patch | ||
--- | ||
|
||
fix: adjust render effect ordering |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/svelte/tests/runtime-runes/samples/lifecycle-render-order-for-children-5/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { test } from '../../test'; | ||
import { log } from './log.js'; | ||
|
||
export default test({ | ||
get props() { | ||
return { n: 0 }; | ||
}, | ||
|
||
before_test() { | ||
log.length = 0; | ||
}, | ||
|
||
async test({ assert, component }) { | ||
assert.deepEqual(log, ['$effect.pre 0', 'another $effect.pre 1', 'render n0', 'render i1']); | ||
|
||
log.length = 0; | ||
component.n += 1; | ||
|
||
assert.deepEqual(log, ['$effect.pre 1', 'another $effect.pre 2', 'render n1', 'render i2']); | ||
} | ||
}); |
2 changes: 2 additions & 0 deletions
2
packages/svelte/tests/runtime-runes/samples/lifecycle-render-order-for-children-5/log.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @type {any[]} */ | ||
export const log = []; |
19 changes: 19 additions & 0 deletions
19
...ages/svelte/tests/runtime-runes/samples/lifecycle-render-order-for-children-5/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
import { untrack } from 'svelte'; | ||
import { log } from './log.js'; | ||
let { n = 0 } = $props(); | ||
let i = $state(0); | ||
function logRender(i) { | ||
log.push(`render ${i}`); | ||
} | ||
$effect.pre(() => { | ||
log.push(`$effect.pre ${n}`); | ||
untrack(() => i++) | ||
}); | ||
$effect.pre(() => { | ||
log.push('another $effect.pre '+ i); | ||
}) | ||
</script> | ||
|
||
<p>{logRender(`n${n}`)}</p> | ||
<p>{logRender(`i${i}`)}</p> |