jquery.getAttrs: Add jsduck documentation
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 27 Apr 2014 14:25:37 +0000 (16:25 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 29 Apr 2014 11:06:06 +0000 (13:06 +0200)
Change-Id: Ic7c10bb4fdeb7d76c0b6b09dab6957536601a20a

maintenance/jsduck/config.json
resources/src/jquery/jquery.getAttrs.js

index 5d2e304..d203baf 100644 (file)
@@ -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",
index 25b806b..c44831c 100644 (file)
@@ -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
+ */