Skip to content

Commit a13b6dd

Browse files
committed
Merge branch 'main' into teardown-props
2 parents a0fa599 + 3fc2007 commit a13b6dd

File tree

16 files changed

+272
-119
lines changed

16 files changed

+272
-119
lines changed

.changeset/shy-falcons-occur.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: run effect roots in tree order

documentation/docs/02-runes/01-what-are-runes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: What are runes?
33
---
44

5-
> [!NOTE] **rune** /ro͞on/ _noun_
5+
> [!NOTE] **rune** /ruːn/ _noun_
66
>
77
> A letter or mark used as a mystical or magic symbol.
88

documentation/docs/03-template-syntax/01-basic-markup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ You can use HTML comments inside components.
185185
Comments beginning with `svelte-ignore` disable warnings for the next block of markup. Usually, these are accessibility warnings; make sure that you're disabling them for a good reason.
186186

187187
```svelte
188-
<!-- svelte-ignore a11y-autofocus -->
188+
<!-- svelte-ignore a11y_autofocus -->
189189
<input bind:value={name} autofocus />
190190
```
191191

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"prettier-plugin-svelte": "^3.1.2",
4343
"svelte": "workspace:^",
4444
"typescript": "^5.5.4",
45-
"typescript-eslint": "^8.2.0",
45+
"typescript-eslint": "^8.24.0",
4646
"v8-natives": "^1.2.5",
4747
"vitest": "^2.1.9"
4848
}

packages/svelte/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# svelte
22

3+
## 5.22.2
4+
5+
### Patch Changes
6+
7+
- fix: correctly set `is_updating` before flushing root effects ([#15442](https://github.com/sveltejs/svelte/pull/15442))
8+
39
## 5.22.1
410

511
### Patch Changes

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.22.1",
5+
"version": "5.22.2",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,12 @@ function push_effect(effect, parent_effect) {
8282
* @returns {Effect}
8383
*/
8484
function create_effect(type, fn, sync, push = true) {
85-
var is_root = (type & ROOT_EFFECT) !== 0;
86-
var parent_effect = active_effect;
85+
var parent = active_effect;
8786

8887
if (DEV) {
8988
// Ensure the parent is never an inspect effect
90-
while (parent_effect !== null && (parent_effect.f & INSPECT_EFFECT) !== 0) {
91-
parent_effect = parent_effect.parent;
89+
while (parent !== null && (parent.f & INSPECT_EFFECT) !== 0) {
90+
parent = parent.parent;
9291
}
9392
}
9493

@@ -103,7 +102,7 @@ function create_effect(type, fn, sync, push = true) {
103102
fn,
104103
last: null,
105104
next: null,
106-
parent: is_root ? null : parent_effect,
105+
parent,
107106
prev: null,
108107
teardown: null,
109108
transitions: null,
@@ -136,9 +135,9 @@ function create_effect(type, fn, sync, push = true) {
136135
effect.teardown === null &&
137136
(effect.f & (EFFECT_HAS_DERIVED | BOUNDARY_EFFECT)) === 0;
138137

139-
if (!inert && !is_root && push) {
140-
if (parent_effect !== null) {
141-
push_effect(effect, parent_effect);
138+
if (!inert && push) {
139+
if (parent !== null) {
140+
push_effect(effect, parent);
142141
}
143142

144143
// if we're in a derived, add the effect there too
@@ -391,7 +390,14 @@ export function destroy_effect_children(signal, remove_dom = false) {
391390

392391
while (effect !== null) {
393392
var next = effect.next;
394-
destroy_effect(effect, remove_dom);
393+
394+
if ((effect.f & ROOT_EFFECT) !== 0) {
395+
// this is now an independent root
396+
effect.parent = null;
397+
} else {
398+
destroy_effect(effect, remove_dom);
399+
}
400+
395401
effect = next;
396402
}
397403
}

packages/svelte/src/internal/client/runtime.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,11 @@ function infinite_loop_guard() {
655655
}
656656

657657
function flush_queued_root_effects() {
658+
var was_updating_effect = is_updating_effect;
659+
658660
try {
659661
var flush_count = 0;
662+
is_updating_effect = true;
660663

661664
while (queued_root_effects.length > 0) {
662665
if (flush_count++ > 1000) {
@@ -669,18 +672,13 @@ function flush_queued_root_effects() {
669672
queued_root_effects = [];
670673

671674
for (var i = 0; i < length; i++) {
672-
var root = root_effects[i];
673-
674-
if ((root.f & CLEAN) === 0) {
675-
root.f ^= CLEAN;
676-
}
677-
678-
var collected_effects = process_effects(root);
675+
var collected_effects = process_effects(root_effects[i]);
679676
flush_queued_effects(collected_effects);
680677
}
681678
}
682679
} finally {
683680
is_flushing = false;
681+
is_updating_effect = was_updating_effect;
684682

685683
last_scheduled_effect = null;
686684
if (DEV) {
@@ -766,11 +764,12 @@ function process_effects(root) {
766764
/** @type {Effect[]} */
767765
var effects = [];
768766

769-
var effect = root.first;
767+
/** @type {Effect | null} */
768+
var effect = root;
770769

771770
while (effect !== null) {
772771
var flags = effect.f;
773-
var is_branch = (flags & BRANCH_EFFECT) !== 0;
772+
var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
774773
var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
775774

776775
if (!is_skippable_branch && (flags & INERT) === 0) {
@@ -795,6 +794,7 @@ function process_effects(root) {
795794
}
796795
}
797796

797+
/** @type {Effect | null} */
798798
var child = effect.first;
799799

800800
if (child !== null) {

packages/svelte/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* The current version, as set in package.json.
55
* @type {string}
66
*/
7-
export const VERSION = '5.22.1';
7+
export const VERSION = '5.22.2';
88
export const PUBLIC_VERSION = '5';
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
async test({ assert, target, logs }) {
6+
const [b1, b2] = target.querySelectorAll('button');
7+
8+
flushSync(() => b1.click());
9+
assert.deepEqual(logs, [0, 1]);
10+
11+
flushSync(() => b1.click());
12+
assert.deepEqual(logs, [0, 1, 2]);
13+
14+
flushSync(() => b2.click());
15+
assert.deepEqual(logs, [0, 1, 2]);
16+
}
17+
});

0 commit comments

Comments
 (0)