-
-
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: restore active reaction if then block throws (#14191)
- Loading branch information
1 parent
34f1475
commit 3006fc7
Showing
4 changed files
with
75 additions
and
31 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: restore active reaction if then block throws |
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
16 changes: 16 additions & 0 deletions
16
packages/svelte/tests/runtime-runes/samples/await-render-error-restore-reaction/_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,16 @@ | ||
import { ok, test } from '../../test'; | ||
import { flushSync } from 'svelte'; | ||
|
||
export default test({ | ||
compileOptions: { | ||
dev: true | ||
}, | ||
async test({ target, errors, assert, window }) { | ||
const btn = target.querySelector('button'); | ||
ok(btn); | ||
flushSync(() => { | ||
btn.click(); | ||
}); | ||
assert.deepEqual(errors, []); | ||
} | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/svelte/tests/runtime-runes/samples/await-render-error-restore-reaction/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,21 @@ | ||
<script> | ||
let count = $state(0); | ||
function listen(node){ | ||
function handler(){ | ||
count++; | ||
} | ||
node.addEventListener("click", handler); | ||
return { | ||
destroy(){ | ||
node.removeEventListener("click", handler); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<button use:listen></button> | ||
|
||
{#await Promise.resolve() then} | ||
{err.or} | ||
{/await} |