From f870fba94ff95041e177f8def32e40a4f1e65b31 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Mon, 22 Oct 2007 12:04:06 +0000 Subject: [PATCH] prototype: Avoid the try..catch block in Ajax.Response#_getResponseJSON unless required. --- CHANGELOG | 2 ++ src/ajax.js | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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); }