Skip to content

Commit 0d97bd3

Browse files
authored
refactor: prefix DataProviderController's private methods with # (#9982)
1 parent db9b3d3 commit 0d97bd3

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

packages/component-base/src/data-provider-controller/cache.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@ export class Cache {
4848
* @type {Record<number, Cache>}
4949
* @private
5050
*/
51-
__subCacheByIndex = {};
51+
#subCacheByIndex = {};
5252

5353
/**
5454
* The number of items.
5555
*
5656
* @type {number}
5757
* @private
5858
*/
59-
__size = 0;
59+
#size = 0;
6060

6161
/**
6262
* The total number of items, including items from expanded sub-caches.
6363
*
6464
* @type {number}
6565
* @private
6666
*/
67-
__flatSize = 0;
67+
#flatSize = 0;
6868

6969
/**
7070
* @param {Cache['context']} context
@@ -79,7 +79,7 @@ export class Cache {
7979
this.size = size;
8080
this.parentCache = parentCache;
8181
this.parentCacheIndex = parentCacheIndex;
82-
this.__flatSize = size || 0;
82+
this.#flatSize = size || 0;
8383
}
8484

8585
/**
@@ -98,7 +98,7 @@ export class Cache {
9898
* @return {Cache[]}
9999
*/
100100
get subCaches() {
101-
return Object.values(this.__subCacheByIndex);
101+
return Object.values(this.#subCacheByIndex);
102102
}
103103

104104
/**
@@ -120,7 +120,7 @@ export class Cache {
120120
* @return {number}
121121
*/
122122
get flatSize() {
123-
return this.__flatSize;
123+
return this.#flatSize;
124124
}
125125

126126
/**
@@ -129,7 +129,7 @@ export class Cache {
129129
* @return {number}
130130
*/
131131
get size() {
132-
return this.__size;
132+
return this.#size;
133133
}
134134

135135
/**
@@ -138,12 +138,12 @@ export class Cache {
138138
* @param {number} size
139139
*/
140140
set size(size) {
141-
const oldSize = this.__size;
141+
const oldSize = this.#size;
142142
if (oldSize === size) {
143143
return;
144144
}
145145

146-
this.__size = size;
146+
this.#size = size;
147147

148148
if (this.context.placeholder !== undefined) {
149149
this.items.length = size || 0;
@@ -164,7 +164,7 @@ export class Cache {
164164
* Recalculates the flattened size for the cache and its descendant caches recursively.
165165
*/
166166
recalculateFlatSize() {
167-
this.__flatSize =
167+
this.#flatSize =
168168
!this.parentItem || this.context.isExpanded(this.parentItem)
169169
? this.size +
170170
this.subCaches.reduce((total, subCache) => {
@@ -199,7 +199,7 @@ export class Cache {
199199
* @return {Cache | undefined}
200200
*/
201201
getSubCache(index) {
202-
return this.__subCacheByIndex[index];
202+
return this.#subCacheByIndex[index];
203203
}
204204

205205
/**
@@ -209,14 +209,14 @@ export class Cache {
209209
* @param {number} index
210210
*/
211211
removeSubCache(index) {
212-
delete this.__subCacheByIndex[index];
212+
delete this.#subCacheByIndex[index];
213213
}
214214

215215
/**
216216
* Removes all sub-caches.
217217
*/
218218
removeSubCaches() {
219-
this.__subCacheByIndex = {};
219+
this.#subCacheByIndex = {};
220220
}
221221

222222
/**
@@ -228,7 +228,7 @@ export class Cache {
228228
*/
229229
createSubCache(index) {
230230
const subCache = new Cache(this.context, this.pageSize, 0, this, index);
231-
this.__subCacheByIndex[index] = subCache;
231+
this.#subCacheByIndex[index] = subCache;
232232
return subCache;
233233
}
234234

packages/component-base/src/data-provider-controller/data-provider-controller.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class DataProviderController extends EventTarget {
8585
this.isPlaceholder = isPlaceholder;
8686
this.dataProvider = dataProvider;
8787
this.dataProviderParams = dataProviderParams;
88-
this.rootCache = this.__createRootCache(size);
88+
this.rootCache = this.#createRootCache(size);
8989
}
9090

9191
/**
@@ -96,7 +96,7 @@ export class DataProviderController extends EventTarget {
9696
}
9797

9898
/** @private */
99-
get __cacheContext() {
99+
get #cacheContext() {
100100
return {
101101
isExpanded: this.isExpanded,
102102
placeholder: this.placeholder,
@@ -143,7 +143,7 @@ export class DataProviderController extends EventTarget {
143143
* Clears the cache.
144144
*/
145145
clearCache() {
146-
this.rootCache = this.__createRootCache(this.rootCache.size);
146+
this.rootCache = this.#createRootCache(this.rootCache.size);
147147
}
148148

149149
/**
@@ -198,8 +198,8 @@ export class DataProviderController extends EventTarget {
198198
ensureFlatIndexLoaded(flatIndex) {
199199
const { cache, page, item } = this.getFlatIndexContext(flatIndex);
200200

201-
if (!this.__isItemLoaded(item)) {
202-
this.__loadCachePage(cache, page);
201+
if (!this.#isItemLoaded(item)) {
202+
this.#loadCachePage(cache, page);
203203
}
204204
}
205205

@@ -213,26 +213,26 @@ export class DataProviderController extends EventTarget {
213213
ensureFlatIndexHierarchy(flatIndex) {
214214
const { cache, item, index } = this.getFlatIndexContext(flatIndex);
215215

216-
if (this.__isItemLoaded(item) && this.isExpanded(item) && !cache.getSubCache(index)) {
216+
if (this.#isItemLoaded(item) && this.isExpanded(item) && !cache.getSubCache(index)) {
217217
const subCache = cache.createSubCache(index);
218-
this.__loadCachePage(subCache, 0);
218+
this.#loadCachePage(subCache, 0);
219219
}
220220
}
221221

222222
/**
223223
* Loads the first page into the root cache.
224224
*/
225225
loadFirstPage() {
226-
this.__loadCachePage(this.rootCache, 0);
226+
this.#loadCachePage(this.rootCache, 0);
227227
}
228228

229229
/** @private */
230-
__createRootCache(size) {
231-
return new Cache(this.__cacheContext, this.pageSize, size);
230+
#createRootCache(size) {
231+
return new Cache(this.#cacheContext, this.pageSize, size);
232232
}
233233

234234
/** @private */
235-
__loadCachePage(cache, page) {
235+
#loadCachePage(cache, page) {
236236
if (!this.dataProvider || cache.pendingRequests[page]) {
237237
return;
238238
}
@@ -277,7 +277,7 @@ export class DataProviderController extends EventTarget {
277277
}
278278

279279
/** @private */
280-
__isItemLoaded(item) {
280+
#isItemLoaded(item) {
281281
if (this.isPlaceholder) {
282282
return !this.isPlaceholder(item);
283283
} else if (this.placeholder) {

0 commit comments

Comments
 (0)