mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-16 22:10:32 +00:00
added a simple test (#4647)
This commit is contained in:
parent
43ebcd8278
commit
4f446020ba
2 changed files with 21 additions and 3 deletions
|
|
@ -1429,7 +1429,11 @@
|
|||
el.width = boundingRect.width;
|
||||
el.height = boundingRect.height;
|
||||
fabric.util.wrapElement(el, 'div');
|
||||
var canvas = new fabric.StaticCanvas(el, { enableRetinaScaling: options.enableRetinaScaling });
|
||||
var canvas = new fabric.StaticCanvas(el, {
|
||||
enableRetinaScaling: options.enableRetinaScaling,
|
||||
renderOnAddRemove: false,
|
||||
skipOffscreen: false,
|
||||
});
|
||||
// to avoid common confusion https://github.com/kangax/fabric.js/issues/806
|
||||
if (options.format === 'jpg') {
|
||||
options.format = 'jpeg';
|
||||
|
|
@ -1449,10 +1453,12 @@
|
|||
var originalCanvas = this.canvas;
|
||||
canvas.add(this);
|
||||
var data = canvas.toDataURL(options);
|
||||
|
||||
this.set(origParams).setCoords();
|
||||
this.canvas = originalCanvas;
|
||||
|
||||
// canvas.dispose will call image.dispose that will nullify the elements
|
||||
// since this canvas is a simple element for the process, we remove references
|
||||
// to objects in this way in order to avoid object trashing.
|
||||
canvas._objects = [];
|
||||
canvas.dispose();
|
||||
canvas = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -567,4 +567,16 @@
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('consecutive dataURLs give same result.', function(assert) {
|
||||
var done = assert.async();
|
||||
createImageObject(function(image) {
|
||||
var data1 = image.toDataURL();
|
||||
var data2 = image.toDataURL();
|
||||
var data3 = image.toDataURL();
|
||||
assert.equal(data1, data2, 'dataurl does not change 1');
|
||||
assert.equal(data1, data3, 'dataurl does not change 2');
|
||||
done();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue