From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- resources/src/jquery/jquery.getAttrs.js | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'resources/src/jquery/jquery.getAttrs.js') diff --git a/resources/src/jquery/jquery.getAttrs.js b/resources/src/jquery/jquery.getAttrs.js index c44831c4..64827fb7 100644 --- a/resources/src/jquery/jquery.getAttrs.js +++ b/resources/src/jquery/jquery.getAttrs.js @@ -2,38 +2,37 @@ * @class jQuery.plugin.getAttrs */ +function serializeControls( controls ) { + var i, + data = {}, + len = controls.length; + + for ( i = 0; i < len; i++ ) { + data[ controls[i].name ] = controls[i].value; + } + + return data; +} + /** * Get the attributes of an element directy as a plain object. * - * If there are more elements in the collection, like most jQuery get/read methods, - * this method will use the first element in the collection. - * - * In IE6, the `attributes` map of a node includes *all* allowed attributes - * for an element (including those not set). Those will have values like - * `undefined`, `null`, `0`, `false`, `""` or `"inherit"`. + * If there is more than one element in the collection, similar to most other jQuery getter methods, + * this will use the first element in the collection. * - * However there may be attributes genuinely set to one of those values, and there - * is no way to distinguish between attributes set to that and those not set and - * it being the default. If you need them, set `all` to `true`. They are filtered out - * by default. - * - * @param {boolean} [all=false] * @return {Object} */ -jQuery.fn.getAttrs = function ( all ) { - var map = this[0].attributes, - attrs = {}, - len = map.length, - i, v; - - for ( i = 0; i < len; i++ ) { - v = map[i].nodeValue; - if ( all || ( v && v !== 'inherit' ) ) { - attrs[ map[i].nodeName ] = v; - } - } +jQuery.fn.getAttrs = function () { + return serializeControls( this[0].attributes ); +}; - return attrs; +/** + * Get form data as a plain object mapping form control names to their values. + * + * @return {Object} + */ +jQuery.fn.serializeObject = function () { + return serializeControls( this.serializeArray() ); }; /** -- cgit v1.2.3-54-g00ecf