mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-09 22:34:43 +00:00
do not set background or overlay image if the load fails. (#3003)
This commit is contained in:
parent
1843581488
commit
dd3e6a81e2
2 changed files with 13 additions and 1 deletions
|
|
@ -398,7 +398,7 @@
|
|||
__setBgOverlayImage: function(property, image, callback, options) {
|
||||
if (typeof image === 'string') {
|
||||
fabric.util.loadImage(image, function(img) {
|
||||
this[property] = new fabric.Image(img, options);
|
||||
img && (this[property] = new fabric.Image(img, options));
|
||||
callback && callback(img);
|
||||
}, this, options && options.crossOrigin);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1217,6 +1217,18 @@
|
|||
});
|
||||
});
|
||||
|
||||
//how to test with an exception?
|
||||
/*asyncTest('options in setBackgroundImage from invalid URL', function() {
|
||||
canvas.backgroundImage = null;
|
||||
canvas.setBackgroundImage(IMG_SRC + '_not_exist', function() {
|
||||
equal(canvas.backgroundImage, null);
|
||||
start();
|
||||
}, {
|
||||
left: 50,
|
||||
originX: 'right'
|
||||
});
|
||||
});*/
|
||||
|
||||
asyncTest('options in setBackgroundImage from image instance', function() {
|
||||
createImageObject(function(imageInstance) {
|
||||
canvas.setBackgroundImage(imageInstance, function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue