mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
Description methods in CPArray and CPDictionary will display JavaScript object attributes instead of displaying [Object object]
Don't you hate when your logs of arrays and dictionaries display [Object object] when you have JavaScript objects in them. Now with this patch all JavaScript objects will be display with all attributes in a nice good looking way. Log CGRect, CGPoint and other JavaScript objects withour any hassle anymore. For example: console.log([myRect]);
This commit is contained in:
@@ -807,7 +807,18 @@ var concat = Array.prototype.concat,
|
||||
description += '\n';
|
||||
|
||||
var object = [self objectAtIndex:index],
|
||||
objectDescription = object && object.isa ? [object description] : String(object);
|
||||
desc = object;
|
||||
if (object && typeof(object) === "object" && !object.isa)
|
||||
{
|
||||
desc = "JSObject\n{\n";
|
||||
for (var property in object)
|
||||
{
|
||||
if (object.hasOwnProperty(property))
|
||||
desc += " " + property + ":" + object[property] + "\n";
|
||||
}
|
||||
desc += "}";
|
||||
}
|
||||
var objectDescription = object && object.isa ? [object description] : String(desc);
|
||||
|
||||
description += "\t" + objectDescription.split('\n').join("\n\t");
|
||||
|
||||
|
||||
@@ -142,9 +142,21 @@ CFDictionary.prototype.toString = function()
|
||||
|
||||
for (; index < count; ++index)
|
||||
{
|
||||
var key = keys[index];
|
||||
var key = keys[index],
|
||||
value = this.valueForKey(key),
|
||||
description = value;
|
||||
if (value && typeof(value) === "object" && !value.isa)
|
||||
{
|
||||
description = "JSObject\n{\n";
|
||||
for (var property in value)
|
||||
{
|
||||
if (value.hasOwnProperty(property))
|
||||
description += " " + property + ":" + value[property] + "\n";
|
||||
}
|
||||
description += "}";
|
||||
}
|
||||
|
||||
string += "\t" + key + " = \"" + String(this.valueForKey(key)).split('\n').join("\n\t") + "\"\n";
|
||||
string += "\t" + key + " = \"" + String(description).split('\n').join("\n\t") + "\"\n";
|
||||
}
|
||||
|
||||
return string + "}";
|
||||
|
||||
Reference in New Issue
Block a user