From ac48714ada88c26fc98a7871cc0e9a3aaaeaa3c3 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Mon, 14 Jan 2008 01:22:37 +0000 Subject: [PATCH] prototype: Make Object.inspect more robust. --- CHANGELOG | 2 ++ src/base.js | 2 +- test/unit/base.html | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 3329d7f..079a069 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Make Object.inspect more robust. [Tobie Langel] + * Add a description to :test and :dist rake tasks. [Christoph Sturm] * Fix Selector.matchElements to allow for coma-separated selectors in Element#up/next/previous and Event#findElement. [Samuel Lebeau, Tobie Langel] diff --git a/src/base.js b/src/base.js index 6629914..9884aaf 100644 --- a/src/base.js +++ b/src/base.js @@ -71,7 +71,7 @@ Object.extend(Object, { try { if (Object.isUndefined(object)) return 'undefined'; if (object === null) return 'null'; - return object.inspect ? object.inspect() : object.toString(); + return object.inspect ? object.inspect() : String(object); } catch (e) { if (e instanceof RangeError) return '...'; throw e; diff --git a/test/unit/base.html b/test/unit/base.html index 07e9632..9828428 100644 --- a/test/unit/base.html +++ b/test/unit/base.html @@ -266,6 +266,7 @@ assertEqual('null', Object.inspect(null)); assertEqual("'foo\\\\b\\\'ar'", Object.inspect('foo\\b\'ar')); assertEqual('[]', Object.inspect([])); + assertNothingRaised(function() { Object.inspect(window.Node) }); }}, testObjectToJSON: function() { with(this) {