File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -374,8 +374,6 @@ p5.Graphics = class extends p5.Element {
374
374
* function doubleClicked() {
375
375
* // Remove the p5.Graphics object from the web page.
376
376
* pg.remove();
377
- *
378
- * // Delete the p5.Graphics object from CPU memory.
379
377
* pg = undefined;
380
378
* }
381
379
* </code>
@@ -392,6 +390,10 @@ p5.Graphics = class extends p5.Element {
392
390
for ( const elt_ev in this . _events ) {
393
391
this . elt . removeEventListener ( elt_ev , this . _events [ elt_ev ] ) ;
394
392
}
393
+
394
+ this . _renderer = undefined ;
395
+ this . canvas = undefined ;
396
+ this . elt = undefined ;
395
397
}
396
398
397
399
Original file line number Diff line number Diff line change @@ -184,4 +184,14 @@ suite('Graphics', function() {
184
184
assert ( graph . height , 100 ) ;
185
185
} ) ;
186
186
} ) ;
187
+
188
+ suite ( 'p5.Graphics.remove()' , function ( ) {
189
+ test ( 'it sets properties to undefined after removal' , function ( ) {
190
+ var graph = myp5 . createGraphics ( 10 , 17 ) ;
191
+ graph . remove ( ) ;
192
+ assert . isUndefined ( graph . canvas ) ;
193
+ assert . isUndefined ( graph . _renderer ) ;
194
+ assert . isUndefined ( graph . elt ) ;
195
+ } ) ;
196
+ } ) ;
187
197
} ) ;
You can’t perform that action at this time.
0 commit comments