Skip to content

Commit 89b2d77

Browse files
Fix a Hash test regression in IE.
1 parent 849bcee commit 89b2d77

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/lang/hash.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,21 @@ var Hash = Class.create(Enumerable, (function() {
333333
function toQueryString() {
334334
return this.inject([], function(results, pair) {
335335
var key = encodeURIComponent(pair.key), values = pair.value;
336-
336+
337337
if (values && typeof values == 'object') {
338-
if (Object.isArray(values))
339-
return results.concat(values.map(toQueryPair.curry(key)));
338+
if (Object.isArray(values)) {
339+
// We used to use `Array#map` here to get the query pair for each
340+
// item in the array, but that caused test regressions once we
341+
// added the sparse array behavior for array iterator methods.
342+
// Changed to an ordinary `for` loop so that we can handle
343+
// `undefined` values ourselves rather than have them skipped.
344+
var queryValues = [];
345+
for (var i = 0, len = values.length, value; i < len; i++) {
346+
value = values[i];
347+
queryValues.push(toQueryPair(key, value));
348+
}
349+
return results.concat(queryValues);
350+
}
340351
} else results.push(toQueryPair(key, values));
341352
return results;
342353
}).join('&');

0 commit comments

Comments
 (0)