Skip to content

Commit f30fd26

Browse files
committed
privatise
1 parent 4a56c2a commit f30fd26

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ function update_pending() {
2323
let uid = 1;
2424

2525
export class Batch {
26-
id = uid++;
26+
#id = uid++;
2727

2828
/** @type {Map<Source, any>} */
29-
previous = new Map();
29+
#previous = new Map();
3030

3131
/** @type {Map<Source, any>} */
32-
current = new Map();
32+
#current = new Map();
3333

3434
/** @type {Set<Effect>} */
3535
skipped_effects = new Set();
3636

3737
/** @type {Set<() => void>} */
3838
#callbacks = new Set();
3939

40-
pending = 0;
40+
#pending = 0;
4141

4242
apply() {
4343
// common case: no overlapping batches, nothing to revert
4444
if (batches.size === 1) return noop;
4545

4646
var current_values = new Map();
4747

48-
for (const [source, current] of this.current) {
48+
for (const [source, current] of this.#current) {
4949
// TODO this shouldn't be necessary, but tests fail otherwise,
5050
// presumably because we need a try-finally somewhere, and the
5151
// source wasn't correctly reverted after the previous batch
@@ -55,8 +55,8 @@ export class Batch {
5555
for (const batch of batches) {
5656
if (batch === this) continue;
5757

58-
for (const [source, previous] of batch.previous) {
59-
if (!this.previous.has(source)) {
58+
for (const [source, previous] of batch.#previous) {
59+
if (!this.#previous.has(source)) {
6060
// mark_reactions(source, DIRTY);
6161
current_values.set(source, source.v);
6262
source.v = previous;
@@ -76,27 +76,27 @@ export class Batch {
7676
* @param {any} value
7777
*/
7878
capture(source, value) {
79-
if (!this.previous.has(source)) {
80-
this.previous.set(source, value);
79+
if (!this.#previous.has(source)) {
80+
this.#previous.set(source, value);
8181
}
8282

83-
this.current.set(source, source.v);
83+
this.#current.set(source, source.v);
8484
}
8585

8686
remove() {
8787
batches.delete(this);
8888

8989
for (var batch of batches) {
90-
if (batch.id < this.id) {
90+
if (batch.#id < this.#id) {
9191
// other batch is older than this
92-
for (var source of this.previous.keys()) {
93-
batch.previous.delete(source);
92+
for (var source of this.#previous.keys()) {
93+
batch.#previous.delete(source);
9494
}
9595
} else {
9696
// other batch is newer than this
97-
for (var source of batch.previous.keys()) {
98-
if (this.previous.has(source)) {
99-
batch.previous.set(source, source.v);
97+
for (var source of batch.#previous.keys()) {
98+
if (this.#previous.has(source)) {
99+
batch.#previous.set(source, source.v);
100100
}
101101
}
102102
}
@@ -114,15 +114,15 @@ export class Batch {
114114
}
115115

116116
increment() {
117-
this.pending += 1;
117+
this.#pending += 1;
118118
}
119119

120120
decrement() {
121-
this.pending -= 1;
121+
this.#pending -= 1;
122122
}
123123

124124
settled() {
125-
return this.pending === 0;
125+
return this.#pending === 0;
126126
}
127127

128128
/** @param {() => void} fn */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ function flush_queued_root_effects() {
720720
process_effects(root, async_effects, render_effects, effects);
721721
}
722722

723-
if (async_effects.length === 0 && batch.pending === 0) {
723+
if (async_effects.length === 0 && batch.settled()) {
724724
batch.commit();
725725
flush_queued_effects(render_effects);
726726
flush_queued_effects(effects);
@@ -798,7 +798,7 @@ export function schedule_effect(signal) {
798798

799799
flush_queued_root_effects();
800800

801-
if (current_batch?.pending === 0) {
801+
if (current_batch?.settled()) {
802802
current_batch.remove();
803803
}
804804

@@ -920,7 +920,7 @@ export function flushSync(fn) {
920920
flush_tasks();
921921
}
922922

923-
if (current_batch?.pending === 0) {
923+
if (current_batch?.settled()) {
924924
current_batch.remove();
925925
}
926926

0 commit comments

Comments
 (0)