Make sure rectangle dimensions are not undefined when creatig from a Point or Size.

This commit is contained in:
Jürg Lehni 2011-03-05 21:06:23 +00:00
parent 5392268b83
commit 4dbba5f806

View file

@ -4,10 +4,11 @@ var Rectangle = this.Rectangle = Base.extend({
initialize: function() {
if (arguments.length == 1) {
var rect = arguments[0];
this.x = rect.x;
this.y = rect.y;
this.width = rect.width;
this.height = rect.height;
// Use 0 as defaults, in case we're reading from a Point or Size
this.x = rect.x || 0;
this.y = rect.y || 0;
this.width = rect.width || 0;
this.height = rect.height || 0;
} else if (arguments.length == 2) {
if (arguments[1].x !== undefined) {
// new Rectangle(point1, point2)