mirror of https://github.com/sveltejs/svelte
fix: wrap `abort` in `without_reactive_context` (#16570)
* fix: wrap `abort` in `without_reactive_context` * only call without_reactive_context when the controller exists --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/16587/head
parent
97f263c3d4
commit
548ad7b7eb
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: wrap `abort` in `without_reactive_context`
|
@ -0,0 +1,12 @@
|
|||||||
|
import { ok, test } from '../../test';
|
||||||
|
import { flushSync } from 'svelte';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target, errors }) {
|
||||||
|
const btn = target.querySelector('button');
|
||||||
|
flushSync(() => {
|
||||||
|
btn?.click();
|
||||||
|
});
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,24 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { getAbortSignal } from "svelte";
|
||||||
|
|
||||||
|
let aborted = $state(0);
|
||||||
|
|
||||||
|
let count = $state(0);
|
||||||
|
|
||||||
|
let der = $derived.by(()=>{
|
||||||
|
const signal = getAbortSignal();
|
||||||
|
|
||||||
|
signal.addEventListener("abort", () => {
|
||||||
|
try{
|
||||||
|
aborted++;
|
||||||
|
}catch(e){
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return count;
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{der}
|
||||||
|
|
||||||
|
<button onclick={() => count++}></button>
|
Loading…
Reference in new issue