/* globals module, require */
(function(module) {
  'use strict';

  var postcss, _options, rGradientEnclosedInBrackets, parse_gradient_value;




  function LegacyIEGradient(options) {
    postcss = require('postcss');
    _options = typeof options !== 'undefined' ? options : { };
    rGradientEnclosedInBrackets = /.*gradient\s*\(((?:\([^\)]*\)|[^\)\(]*)*)\)/;
    parse_gradient_value = require('./parse-gradient-value');
  }

  LegacyIEGradient.prototype.process = function(css, options) {
    return postcss(this.postcss).process(css, options).css;
  };

  LegacyIEGradient.prototype.postcss = function(css) {
    css.eachDecl(function(decl, i) {
      var rule = decl.parent;
      var value = decl.value;
      var prop = decl.prop;
      var result;

      if ( background(prop) && linearGradient(value) ) {
        result = parse_gradient_value.parse(decl.toString());

        if (result) {
          var ieDecl = postcss.decl({
            prop: 'filter',
            value: 'progid:DXImageTransform.Microsoft.gradient(startColorstr=' + result.colorStopList[0]['color'] + ', endColorstr=' + result.colorStopList[1]['color'] + ')'
          });
          rule.insertAfter(i, ieDecl);
        }
      }
    });
  };

  function background(prop) {
    // Stubbed for now
    return true;
  }

  function linearGradient(value) {
    // Stubbed for now
    return true;
  }

  var legacyIEGradient = function(options) {
    return new LegacyIEGradient(options);
  };
  legacyIEGradient.process = function(css, options, postcssoptions) {
    return new LegacyIEGradient(options).process(css, postcssoptions);
  };

  module.exports = legacyIEGradient;
})(module);

@@ -1258,121 +1258,530 @@
     
-// Stubbed for now%0A    return true;%0A  %7D%0A%0A  function linearGradient(value) %7B%0A    // Stubbed for now%0A    return tru
+return prop === %22background%22 %7C%7C prop === %22background-image%22;%0A  %7D%0A%0A  function linearGradient(value) %7B%0A    var gradient_type = '';%0A    var paran_position = value.indexOf('(');%0A%0A    if (paran_position === -1) %7B%0A      return false;%0A    %7D%0A%0A    gradient_type = value.substr(0, paran_position);%0A    var valid_gradient_types = %5B 'linear-gradient', 'radial-gradient', 'repeating-linear-gradient', 'repeating-radial-gradient' %5D;%0A    if (valid_gradient_types.indexOf(gradient_type) !== -1) %7B%0A      return true;%0A    %7D%0A%0A    return fals
 e;%0A 

Implement actual tests to improve performance by not processing declarations that aren't gradients.