prototype: Ensure that an Ajax.Request's parameters option can be a Hash. Closes #10172.

This commit is contained in:
Sam Stephenson 2007-11-29 00:24:54 +00:00
parent c85285496b
commit 769ae42fcc
3 changed files with 23 additions and 1 deletions

View File

@ -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]

View File

@ -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();
}
});

View File

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