Skip to content

Commit a6d4644

Browse files
committed
move flushing_sync check inside Batch.ensure
1 parent f92dfc1 commit a6d4644

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ let last_scheduled_effect = null;
7070

7171
let is_flushing = false;
7272

73-
export let flushing_sync = false;
73+
let flushing_sync = false;
7474

7575
export class Batch {
7676
/**
@@ -407,12 +407,12 @@ export class Batch {
407407
return (this.#deferred ??= deferred()).promise;
408408
}
409409

410-
static ensure(autoflush = true) {
410+
static ensure() {
411411
if (current_batch === null) {
412412
const batch = (current_batch = new Batch());
413413
batches.add(current_batch);
414414

415-
if (autoflush) {
415+
if (!flushing_sync) {
416416
Batch.enqueue(() => {
417417
if (current_batch !== batch) {
418418
// a flushSync happened in the meantime
@@ -455,7 +455,7 @@ export function flushSync(fn) {
455455
try {
456456
var result;
457457

458-
const batch = Batch.ensure(false);
458+
const batch = Batch.ensure();
459459

460460
if (fn) {
461461
batch.flush_effects();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as e from '../errors.js';
3333
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
3434
import { get_stack, tag_proxy } from '../dev/tracing.js';
3535
import { component_context, is_runes } from '../context.js';
36-
import { Batch, flushing_sync, schedule_effect } from './batch.js';
36+
import { Batch, schedule_effect } from './batch.js';
3737
import { proxy } from '../proxy.js';
3838
import { execute_derived } from './deriveds.js';
3939

@@ -179,7 +179,7 @@ export function internal_set(source, value) {
179179

180180
source.v = value;
181181

182-
const batch = Batch.ensure(!flushing_sync);
182+
var batch = Batch.ensure();
183183
batch.capture(source, old_value);
184184

185185
if (DEV) {

0 commit comments

Comments
 (0)