From: Michał Gołębiowski Date: Mon, 7 Sep 2015 21:22:56 +0000 (+0200) Subject: Serialize: Fix object detection X-Git-Tag: 2.2.0~159 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=14c0fe44328f22debb5b531d2b671923658542b3;p=jquery.git Serialize: Fix object detection 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 --- diff --git a/src/serialize.js b/src/serialize.js index e0839dc09..94698fc2f 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -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