mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-29 17:44:42 +00:00
removed references to context when disposing (#4846)
* removed references to context * improved test * try fix error
This commit is contained in:
parent
17386fc240
commit
682eac4545
4 changed files with 14 additions and 2 deletions
|
|
@ -1555,7 +1555,10 @@
|
|||
this.removeListeners();
|
||||
wrapper.removeChild(this.upperCanvasEl);
|
||||
wrapper.removeChild(this.lowerCanvasEl);
|
||||
delete this.upperCanvasEl;
|
||||
this.upperCanvasEl = null;
|
||||
this.cacheCanvasEl = null;
|
||||
this.contextCache = null;
|
||||
this.contextTop = null;
|
||||
if (wrapper.parentNode) {
|
||||
wrapper.parentNode.replaceChild(this.lowerCanvasEl, this.wrapperEl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1662,6 +1662,11 @@
|
|||
* @chainable
|
||||
*/
|
||||
dispose: function () {
|
||||
// cancel eventually ongoing renders
|
||||
if (this.isRendering) {
|
||||
fabric.util.cancelAnimFrame(this.isRendering);
|
||||
this.isRendering = 0;
|
||||
}
|
||||
this.forEachObject(function(object) {
|
||||
object.dispose && object.dispose();
|
||||
});
|
||||
|
|
@ -1670,7 +1675,7 @@
|
|||
this.overlayImage = null;
|
||||
this._iTextInstances = null;
|
||||
this.lowerCanvasEl = null;
|
||||
this.cacheCanvasEl = null;
|
||||
this.contextContainer = null;
|
||||
return this;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1751,6 +1751,9 @@
|
|||
}
|
||||
assert.equal(canvas.wrapperEl, null, 'wrapperEl should be deleted');
|
||||
assert.equal(canvas.upperCanvasEl, null, 'upperCanvas should be deleted');
|
||||
assert.equal(canvas.cacheCanvasEl, null, 'cacheCanvasEl should be deleted');
|
||||
assert.equal(canvas.contextTop, null, 'contextTop should be deleted');
|
||||
assert.equal(canvas.contextCache, null, 'contextCache should be deleted');
|
||||
});
|
||||
|
||||
// QUnit.test('dispose', function(assert) {
|
||||
|
|
|
|||
|
|
@ -1428,6 +1428,7 @@
|
|||
canvas2.dispose();
|
||||
assert.equal(canvas2.getObjects().length, 0, 'dispose should clear canvas');
|
||||
assert.equal(canvas2.lowerCanvasEl, null, 'dispose should clear lowerCanvasEl');
|
||||
assert.equal(canvas2.contextContainer, null, 'dispose should clear contextContainer');
|
||||
});
|
||||
|
||||
QUnit.test('clone', function(assert) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue