From c361c994cf9be52c45adbd60456d22885fb63180 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 27 Apr 2014 16:25:37 +0200 Subject: [PATCH] jquery.getAttrs: Add jsduck documentation Change-Id: Ic7c10bb4fdeb7d76c0b6b09dab6957536601a20a --- maintenance/jsduck/config.json | 1 + resources/src/jquery/jquery.getAttrs.js | 30 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/maintenance/jsduck/config.json b/maintenance/jsduck/config.json index 5d2e304c58..d203bafa2c 100644 --- a/maintenance/jsduck/config.json +++ b/maintenance/jsduck/config.json @@ -22,6 +22,7 @@ "../../resources/src/jquery/jquery.byteLimit.js", "../../resources/src/jquery/jquery.client.js", "../../resources/src/jquery/jquery.colorUtil.js", + "../../resources/src/jquery/jquery.getAttrs.js", "../../resources/src/jquery/jquery.localize.js", "../../resources/src/jquery/jquery.makeCollapsible.js", "../../resources/src/jquery/jquery.spinner.js", diff --git a/resources/src/jquery/jquery.getAttrs.js b/resources/src/jquery/jquery.getAttrs.js index 25b806b6e6..c44831c404 100644 --- a/resources/src/jquery/jquery.getAttrs.js +++ b/resources/src/jquery/jquery.getAttrs.js @@ -1,7 +1,24 @@ /** - * Utility to get all attributes of an element directy as an object. + * @class jQuery.plugin.getAttrs + */ + +/** + * 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"`. * - * @author Timo Tijhof, 2011 + * 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, @@ -10,10 +27,6 @@ jQuery.fn.getAttrs = function ( all ) { i, v; for ( i = 0; i < len; i++ ) { - // IE6 includes *all* allowed attributes for thew element (including those - // not set). Those have values like undefined, null, 0, false, "" or "inherit". - // However there may be genuine attributes set to that. If you need them, - // set all to true. They are excluded by default. v = map[i].nodeValue; if ( all || ( v && v !== 'inherit' ) ) { attrs[ map[i].nodeName ] = v; @@ -22,3 +35,8 @@ jQuery.fn.getAttrs = function ( all ) { return attrs; }; + +/** + * @class jQuery + * @mixins jQuery.plugin.getAttrs + */ -- 2.20.1