Generalise all read() functions in Base.read(), fix an issue in by making sure arguments passed to initialie are never larger than length, and have Color's initialize create an RGBColor, to still be able to use Color.read().

This commit is contained in:
Jürg Lehni 2011-03-04 13:19:07 +00:00
parent 3837ca1f14
commit c6d79f964c
7 changed files with 22 additions and 86 deletions
src/basic

View file

@ -282,20 +282,5 @@ var Rectangle = Base.extend({
+ ', width: ' + this.width
+ ', height: ' + this.height
+ ' }';
},
statics: {
read: function(args, index, length) {
var index = index || 0, length = length || args.length - index;
if (length == 1 && args[index] instanceof Rectangle) {
return args[index];
} else if (length != 0) {
var rect = new Rectangle(Rectangle.dont);
rect.initialize.apply(rect, index > 0
? Array.prototype.slice.call(args, index) : args);
return rect;
}
return null;
}
}
});