[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/resources/src/jquery/ -> jquery.getAttrs.js (source)

   1  /**
   2   * @class jQuery.plugin.getAttrs
   3   */
   4  
   5  /**
   6   * Get the attributes of an element directy as a plain object.
   7   *
   8   * If there are more elements in the collection, like most jQuery get/read methods,
   9   * this method will use the first element in the collection.
  10   *
  11   * In IE6, the `attributes` map of a node includes *all* allowed attributes
  12   * for an element (including those not set). Those will have values like
  13   * `undefined`, `null`, `0`, `false`, `""` or `"inherit"`.
  14   *
  15   * However there may be attributes genuinely set to one of those values, and there
  16   * is no way to distinguish between attributes set to that and those not set and
  17   * it being the default. If you need them, set `all` to `true`. They are filtered out
  18   * by default.
  19   *
  20   * @param {boolean} [all=false]
  21   * @return {Object}
  22   */
  23  jQuery.fn.getAttrs = function ( all ) {
  24      var map = this[0].attributes,
  25          attrs = {},
  26          len = map.length,
  27          i, v;
  28  
  29      for ( i = 0; i < len; i++ ) {
  30          v = map[i].nodeValue;
  31          if ( all || ( v && v !== 'inherit' ) ) {
  32              attrs[ map[i].nodeName ] = v;
  33          }
  34      }
  35  
  36      return attrs;
  37  };
  38  
  39  /**
  40   * @class jQuery
  41   * @mixins jQuery.plugin.getAttrs
  42   */


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1