diff --git a/CHANGELOG b/CHANGELOG index cb7fe5e..a88b262 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +*SVN* + +* Ensure that an Ajax.Request's parameters option can be a Hash. Closes #10172. [kangax, sam] + * Ensure no comment nodes are returned in Selector queries (IE improperly returns comment nodes on getElementsByTagName("*")). Change Element#descendants to use Element#getElementsBySelector in order to avoid this issue. Closes #10220. [Jeff Gobel, Andrew Dupont] * Re-enable the XPath approach in Selector for Safari 3. Falls back to the non-XPath version when it sees a problematic token. [Andrew Dupont] diff --git a/src/ajax.js b/src/ajax.js index 0ecec59..dc1aa99 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -58,8 +58,11 @@ Ajax.Base = Class.create({ Object.extend(this.options, options || { }); this.options.method = this.options.method.toLowerCase(); + if (Object.isString(this.options.parameters)) this.options.parameters = this.options.parameters.toQueryParams(); + else if (Object.isHash(this.options.parameters)) + this.options.parameters = this.options.parameters.toObject(); } }); diff --git a/test/unit/ajax.html b/test/unit/ajax.html index 0de88a0..7cf836f 100644 --- a/test/unit/ajax.html +++ b/test/unit/ajax.html @@ -389,7 +389,22 @@ parameters: { 'X-TEST': 'some value' }, onComplete: function(transport) { assertEqual('some value', transport.getHeader('X-Test')); - assertNull(null, transport.getHeader('X-Inexistant')); + assertNull(transport.getHeader('X-Inexistant')); + } + })); + } else { + info(message); + } + }}, + + testParametersCanBeHash: function() {with(this) { + if (isRunningFromRake) { + new Ajax.Request("/response", extendDefault({ + parameters: $H({ "one": "two", "three": "four" }), + onComplete: function(transport) { + assertEqual("two", transport.getHeader("one")); + assertEqual("four", transport.getHeader("three")); + assertNull(transport.getHeader("toObject")); } })); } else {