diff --git a/CHANGELOG b/CHANGELOG index 3ed6d02..1970358 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Avoid the try..catch block in Ajax.Response#_getResponseJSON unless required. [Tobie Langel] + * Add more tests to Element.update. Closes #9327. [Tobie Langel] * Make the Ajax.Response#headerJSON property correctly decode unicode characters. Closes #9285. [Marius Feraru, Tobie Langel] diff --git a/src/ajax.js b/src/ajax.js index bea5d9a..7f5c701 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -287,11 +287,11 @@ Ajax.Response = Class.create({ _getResponseJSON: function() { var options = this.request.options; + if (!options.evalJSON || (options.evalJSON != 'force' && + !(this.getHeader('Content-type') || '').include('application/json'))) + return null; try { - if (options.evalJSON == 'force' || (options.evalJSON && - (this.getHeader('Content-type') || '').include('application/json'))) - return this.transport.responseText.evalJSON(options.sanitizeJSON); - return null; + return this.transport.responseText.evalJSON(options.sanitizeJSON); } catch (e) { this.request.dispatchException(e); }