File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -205,33 +205,32 @@ function mirrorContextOperations(ctx, destCtx) {
205205}
206206
207207class CachedCanvases {
208+ #cache = new Map ( ) ;
209+
208210 constructor ( canvasFactory ) {
209211 this . canvasFactory = canvasFactory ;
210- this . cache = Object . create ( null ) ;
211212 }
212213
213214 getCanvas ( id , width , height ) {
214- let canvasEntry ;
215- if ( this . cache [ id ] !== undefined ) {
216- canvasEntry = this . cache [ id ] ;
215+ let canvasEntry = this . #cache. get ( id ) ;
216+ if ( canvasEntry ) {
217217 this . canvasFactory . reset ( canvasEntry , width , height ) ;
218218 } else {
219219 canvasEntry = this . canvasFactory . create ( width , height ) ;
220- this . cache [ id ] = canvasEntry ;
220+ this . # cache. set ( id , canvasEntry ) ;
221221 }
222222 return canvasEntry ;
223223 }
224224
225225 delete ( id ) {
226- delete this . cache [ id ] ;
226+ this . # cache. delete ( id ) ;
227227 }
228228
229229 clear ( ) {
230- for ( const id in this . cache ) {
231- const canvasEntry = this . cache [ id ] ;
230+ for ( const canvasEntry of this . #cache. values ( ) ) {
232231 this . canvasFactory . destroy ( canvasEntry ) ;
233- delete this . cache [ id ] ;
234232 }
233+ this . #cache. clear ( ) ;
235234 }
236235}
237236
You can’t perform that action at this time.
0 commit comments