CoreFiles by mySites.guru
jquery.serialize-object.js31 lines, 769 bytes, from wordpress-5.7.21.zip
Raw History Compare with 5.7.20
md5
062a8544d0420d750f9f36aae4d3f221
sha1
62edc653486605304238c4077fb7cb1b52c393ad
sha256
6879fbda93174f19926cf0409f828450b4035740384cb1c46462becf3aa5367d
/*!
 * jQuery serializeObject - v0.2-wp - 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
          : Array.isArray( obj[n] ) ? obj[n].concat( v )
          : [ obj[n], v ];
    });

    return obj;
  };

})(jQuery);

The same content is in 373 releases, WordPress 5.7-RC1 to 7.2-RC1. See them all, or every version of this file.