Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/forbesmyester/zepto into …

…forbesmyester-master
  • Loading branch information...
madrobby committed Nov 24, 2013
2 parents 6c260e7 + 15dcdf9 commit 03dca28e143e7c2bdcc6a374a18f42077e30f3ee
Showing with 16 additions and 3 deletions.
  1. +6 −2 src/ajax.js
  2. +10 −1 test/ajax.html
@@ -298,10 +298,14 @@
var escape = encodeURIComponent

function serialize(params, obj, traditional, scope){
var type, array = $.isArray(obj)
var type, array = $.isArray(obj), arrayIndex = 0;
$.each(obj, function(key, value) {
type = $.type(value)
if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'
if (scope) {
if (traditional) key = scope
else key = scope + '[' + (array ? type == 'object' ? arrayIndex : '' : key) + ']' // if current is an object, use a key, if current is array and value is an object use a numeric index, if current is array and value is non-object use no index...
}
arrayIndex++
// handle data in serializeArray() format
if (!scope && array) params.add(value.name, value.value)
// recurse into nested objects
@@ -1161,7 +1161,16 @@ <h1>Zepto Ajax unit tests</h1>
}
var result = $.param(data)
result = decodeURIComponent(result)
t.assertEqual("a[]=b&a[]=c&a[][d]=e&a[][f][]=g&a[][f][]=h", result)
t.assertEqual("a[]=b&a[]=c&a[2][d]=e&a[2][f][]=g&a[2][f][]=h", result)
},
testParamComplexIssue850: function(t) {
var data = {
$push: { _:[ { name: 'bob', members:['aaa'] } ] }
}
var result = $.param(data)
result = decodeURIComponent(result)
t.assertEqual("$push[_][0][name]=bob&$push[_][0][members][]=aaa", result)
},
testParamShallow: function(t) {

0 comments on commit 03dca28

Please sign in to comment.
You can’t perform that action at this time.