Have Raster constructor set Raster#_size to [0, 0] if it was not set.

This commit is contained in:
Jonathan Puckey 2013-03-17 17:04:56 +01:00
parent 5777c7a772
commit 0d3f746c10
2 changed files with 8 additions and 1 deletions

View file

@ -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

View file

@ -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];