demos/Collage/fabric.js
function getGradientDefs(doc) {
    var linearGradientEls = doc.getElementsByTagName('linearGradient'),
        radialGradientEls = doc.getElementsByTagName('radialGradient'),
        el,
        gradientDefs = { };

    for (var i = linearGradientEls.length; i--; ) {
      el = linearGradientEls[i];
      gradientDefs[el.getAttribute('id')] = el;
    }

    for (var i = radialGradientEls.length; i--; ) {
      el = radialGradientEls[i];
      gradientDefs[el.getAttribute('id')] = el;
    }

    return gradientDefs;
  }
function getGradientDefs(doc) {
    var linearGradientEls = doc.getElementsByTagName('linearGradient'),
        radialGradientEls = doc.getElementsByTagName('radialGradient'),
        el,
        gradientDefs = { };

    for (var i = linearGradientEls.length; i--; ) {
      el = linearGradientEls[i];
      gradientDefs[el.getAttribute('id')] = el;
    }

    for (var i = radialGradientEls.length; i--; ) {
      el = radialGradientEls[i];
      gradientDefs[el.getAttribute('id')] = el;
    }

    return gradientDefs;
  }
function getGradientDefs ( doc ) { var linearGradientEls = doc . getElementsByTagName ( 'linearGradient' ) , radialGradientEls = doc . getElementsByTagName ( 'radialGradient' ) , el , gradientDefs = { } ; for ( var i = linearGradientEls . length ; i -- ; ) { el = linearGradientEls [ i ] ; gradientDefs [ el . getAttribute ( 'id' ) ] = el ; } for ( var i = radialGradientEls . length ; i -- ; ) { el = radialGradientEls [ i ] ; gradientDefs [ el . getAttribute ( 'id' ) ] = el ; } return gradientDefs ; }
Parses an SVG document, returning all of the gradient declarations found in it
@static
@function
@memberOf fabric
@method getGradientDefs
@param {SVGDocument} doc SVG document to parse
@return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element
Parses an SVG document returning all of the gradient declarations found in it