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) {