CoreFiles by mySites.guru
jquery.serialize-object.js31 lines, 783 bytes, from wordpress-5.2.21.zip
Raw History Compare with 5.2.20
md5
d15c29a18d9ffa8b9b4ae86c3c0cfa22
sha1
ad78e2a60469f4e000a3fc800a4ac066ff7b5c82
sha256
08a40a02bef57c6ef69371c0567917234871d5245298d72571806796e32f2d06
/*!
 * jQuery serializeObject - v0.2 - 1/20/2010
 * http://benalman.com/projects/jquery-misc-plugins/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

// Whereas .serializeArray() serializes a form into an array, .serializeObject()
// serializes a form into an (arguably more useful) object.

(function($,undefined){
  '$:nomunge'; // Used by YUI compressor.
  
  $.fn.serializeObject = function(){
    var obj = {};
    
    $.each( this.serializeArray(), function(i,o){
      var n = o.name,
        v = o.value;
        
        obj[n] = obj[n] === undefined ? v
          : $.isArray( obj[n] ) ? obj[n].concat( v )
          : [ obj[n], v ];
    });
    
    return obj;
  };
  
})(jQuery);

The same content is in 921 releases, WordPress 3.1-beta1 to 5.7-beta3. See them all, or every version of this file.