Skip to content

Commit 6eab0fd

Browse files
committed
fix: avoid chromium issue with dispatching blur on element removal
1 parent 793a8de commit 6eab0fd

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.changeset/seven-dancers-brush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: avoid chromium issue with dispatching blur on element removal

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
"type": "module",
77
"license": "MIT",
88
"packageManager": "[email protected]",
9-
"engines": {
10-
"pnpm": "^9.0.0"
11-
},
9+
1210
"repository": {
1311
"type": "git",
1412
"url": "git+https://github.com/sveltejs/svelte.git"

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,20 @@ export function destroy_effect(effect, remove_dom = true) {
375375
/** @type {TemplateNode | null} */
376376
var node = effect.nodes_start;
377377
var end = effect.nodes_end;
378+
var previous_reaction = active_reaction;
378379

380+
// Really we only need to do this in Chromium because of https://chromestatus.com/feature/5128696823545856,
381+
// as removal of the DOM can cause sync `blur` events to fire, which can cause logic to run inside
382+
// the current `active_reaction`, which isn't what we want at all
383+
set_active_reaction(null)
379384
while (node !== null) {
380385
/** @type {TemplateNode | null} */
381386
var next = node === end ? null : /** @type {TemplateNode} */ (get_next_sibling(node));
382387

383388
node.remove();
384389
node = next;
385390
}
391+
set_active_reaction(previous_reaction)
386392

387393
removed = true;
388394
}

0 commit comments

Comments
 (0)