]> 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 22:33:09 +0000 (00:33 +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.

(cherry-picked from 14c0fe44328f22debb5b531d2b671923658542b3)

Refs 3d7ce0a65f0707ff01a851822e57ba80adcff075

src/serialize.js

index 580bd7d00a0f72c23ae1b7702261ada07987530b..ce96a90d67427571a14af5dabf1fa76c94152418 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