Fix Base.read() to correctly read existing objects even when length > 1.

This commit is contained in:
Jürg Lehni 2011-03-08 17:08:30 +00:00
parent 74167ff28d
commit ea9a1d2c47

View file

@ -54,12 +54,10 @@ Base.inject({
read: function(args, index, length) {
var index = index || 0, length = length || args.length - index;
if (length <= 1) {
var arg = args[index];
// Return null when nothing was provided
if (arg instanceof this || arg == null)
return arg;
}
var arg = args[index];
// Return null when nothing was provided
if (arg instanceof this || arg == null && length <= 1)
return arg;
var obj = new this(this.dont);
obj = obj.initialize.apply(obj, index > 0 || length < args.length
? Array.prototype.slice.call(args, index, index + length)