diff --git a/src/item/Raster.js b/src/item/Raster.js index b9f19221..c1433927 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -88,6 +88,8 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ this.setImage(object); } } + if (!this._size) + this._size = new Size(); }, clone: function() { @@ -114,7 +116,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ setSize: function() { var size = Size.read(arguments); - if (!this._size || !this._size.equals(size)) { + if (!this._size.equals(size)) { // Get reference to image before changing canvas var element = this.getElement(); // Setting canvas internally sets _size diff --git a/test/tests/Raster.js b/test/tests/Raster.js index 1ece61da..6d540d49 100644 --- a/test/tests/Raster.js +++ b/test/tests/Raster.js @@ -12,6 +12,11 @@ module('Raster'); +test('Create a raster without a source and check its size', function() { + var raster = new Raster(); + equals(raster.size.toString(), new Size(0, 0).toString(), true); +}); + test('Create a raster without a source and set its size', function() { var raster = new Raster(); raster.size = [640, 480];