]> source.dussan.org Git - jquery.git/commitdiff
Serialize: Fix object detection
authorMichał Gołębiowski <m.goleb@gmail.com>
Mon, 7 Sep 2015 21:22:56 +0000 (23:22 +0200)
committerMichał Gołębiowski <m.goleb@gmail.com>
Mon, 7 Sep 2015 21:22:56 +0000 (23:22 +0200)
jQuery.type doesn't just return "null" for null but also e.g. "array"
for arrays instead of object so it's not really a typeof analogue.

My suggestion was stupid. Sorry.

Refs 3d7ce0a65f0707ff01a851822e57ba80adcff075

src/serialize.js

index e0839dc096f7e2af1b3556081f3586125d22c9e7..94698fc2fc459dbe231176fb04106e066cf2d351 100644 (file)
@@ -28,7 +28,7 @@ function buildParams( prefix, obj, traditional, add ) {
 
                                // Item is non-scalar (array or object), encode its numeric index.
                                buildParams(
-                                       prefix + "[" + ( jQuery.type( v ) === "object" ? i : "" ) + "]",
+                                       prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
                                        v,
                                        traditional,
                                        add