lib/resolver/cssGradient.js
function pasteGradient(property, gradients) {
		var rule = property.parent;
		var alignVendor = prefs.get('css.alignVendor');
		var omitDir = prefs.get('css.gradient.omitDefaultDirection');
		
		// we may have aligned gradient definitions: find the smallest value
		// separator
		var sep = property.styleSeparator;
		var before = property.styleBefore;
		
		// first, remove all properties within CSS rule with the same name and
		// gradient definition
		rule.getAll(similarPropertyNames(property)).forEach(function(item) {
			if (item != property && /gradient/i.test(item.value())) {
				if (item.styleSeparator.length < sep.length) {
					sep = item.styleSeparator;
				}
				if (item.styleBefore.length < before.length) {
					before = item.styleBefore;
				}
				rule.remove(item);
			}
		});
		
		if (alignVendor) {
			// update prefix
			if (before != property.styleBefore) {
				var fullRange = property.fullRange();
				rule._updateSource(before, fullRange.start, fullRange.start + property.styleBefore.length);
				property.styleBefore = before;
			}
			
			// update separator value
			if (sep != property.styleSeparator) {
				rule._updateSource(sep, property.nameRange().end, property.valueRange().start);
				property.styleSeparator = sep;
			}
		}
		
		var value = property.value();

		// create list of properties to insert
		var propsToInsert = getPropertiesForGradient(gradients, property);
		
		// align prefixed values
		if (alignVendor) {
			var names = [], values = [];
			propsToInsert.forEach(function(item) {
				names.push(item.name);
				values.push(item.value);
			});
			values.push(property.value());
			names.push(property.name());
			
			var valuePads = utils.getStringsPads(values.map(function(v) {
				return v.substring(0, v.indexOf('('));
			}));
			
			var namePads = utils.getStringsPads(names);
			property.name(namePads[namePads.length - 1] + property.name());
			
			propsToInsert.forEach(function(prop, i) {
				prop.name = namePads[i] + prop.name;
				prop.value = valuePads[i] + prop.value;
			});
			
			property.value(valuePads[valuePads.length - 1] + property.value());
		}
		
		// put vendor-prefixed definitions before current rule
		propsToInsert.forEach(function(prop) {
			rule.add(prop.name, prop.value, rule.indexOf(property));
		});

		// put vanilla-clean gradient definition into current rule
		property.value(insertGradientsIntoCSSValue(gradients, value, {
			placeholder: '${2}',
			omitDefaultDirection: omitDir
		}));
	}
function pasteGradient(property, gradients) {
		var rule = property.parent;
		var alignVendor = prefs.get('css.alignVendor');
		var omitDir = prefs.get('css.gradient.omitDefaultDirection');
		
		// we may have aligned gradient definitions: find the smallest value
		// separator
		var sep = property.styleSeparator;
		var before = property.styleBefore;
		
		// first, remove all properties within CSS rule with the same name and
		// gradient definition
		rule.getAll(similarPropertyNames(property)).forEach(function(item) {
			if (item != property && /gradient/i.test(item.value())) {
				if (item.styleSeparator.length < sep.length) {
					sep = item.styleSeparator;
				}
				if (item.styleBefore.length < before.length) {
					before = item.styleBefore;
				}
				rule.remove(item);
			}
		});
		
		if (alignVendor) {
			// update prefix
			if (before != property.styleBefore) {
				var fullRange = property.fullRange();
				rule._updateSource(before, fullRange.start, fullRange.start + property.styleBefore.length);
				property.styleBefore = before;
			}
			
			// update separator value
			if (sep != property.styleSeparator) {
				rule._updateSource(sep, property.nameRange().end, property.valueRange().start);
				property.styleSeparator = sep;
			}
		}
		
		var value = property.value();

		// create list of properties to insert
		var propsToInsert = getPropertiesForGradient(gradients, property);
		
		// align prefixed values
		if (alignVendor) {
			var names = [], values = [];
			propsToInsert.forEach(function(item) {
				names.push(item.name);
				values.push(item.value);
			});
			values.push(property.value());
			names.push(property.name());
			
			var valuePads = utils.getStringsPads(values.map(function(v) {
				return v.substring(0, v.indexOf('('));
			}));
			
			var namePads = utils.getStringsPads(names);
			property.name(namePads[namePads.length - 1] + property.name());
			
			propsToInsert.forEach(function(prop, i) {
				prop.name = namePads[i] + prop.name;
				prop.value = valuePads[i] + prop.value;
			});
			
			property.value(valuePads[valuePads.length - 1] + property.value());
		}
		
		// put vendor-prefixed definitions before current rule
		propsToInsert.forEach(function(prop) {
			rule.add(prop.name, prop.value, rule.indexOf(property));
		});

		// put vanilla-clean gradient definition into current rule
		property.value(insertGradientsIntoCSSValue(gradients, value, {
			placeholder: '${2}',
			omitDefaultDirection: omitDir
		}));
	}
function pasteGradient ( property , gradients ) { var rule = property . parent ; var alignVendor = prefs . get ( 'css.alignVendor' ) ; var omitDir = prefs . get ( 'css.gradient.omitDefaultDirection' ) ; // we may have aligned gradient definitions: find the smallest value // separator var sep = property . styleSeparator ; var before = property . styleBefore ; // first, remove all properties within CSS rule with the same name and // gradient definition rule . getAll ( similarPropertyNames ( property ) ) . forEach ( function ( item ) { if ( item != property && / gradient / i . test ( item . value ( ) ) ) { if ( item . styleSeparator . length < sep . length ) { sep = item . styleSeparator ; } if ( item . styleBefore . length < before . length ) { before = item . styleBefore ; } rule . remove ( item ) ; } } ) ; if ( alignVendor ) { // update prefix if ( before != property . styleBefore ) { var fullRange = property . fullRange ( ) ; rule . _updateSource ( before , fullRange . start , fullRange . start + property . styleBefore . length ) ; property . styleBefore = before ; } // update separator value if ( sep != property . styleSeparator ) { rule . _updateSource ( sep , property . nameRange ( ) . end , property . valueRange ( ) . start ) ; property . styleSeparator = sep ; } } var value = property . value ( ) ; // create list of properties to insert var propsToInsert = getPropertiesForGradient ( gradients , property ) ; // align prefixed values if ( alignVendor ) { var names = [ ] , values = [ ] ; propsToInsert . forEach ( function ( item ) { names . push ( item . name ) ; values . push ( item . value ) ; } ) ; values . push ( property . value ( ) ) ; names . push ( property . name ( ) ) ; var valuePads = utils . getStringsPads ( values . map ( function ( v ) { return v . substring ( 0 , v . indexOf ( '(' ) ) ; } ) ) ; var namePads = utils . getStringsPads ( names ) ; property . name ( namePads [ namePads . length - 1 ] + property . name ( ) ) ; propsToInsert . forEach ( function ( prop , i ) { prop . name = namePads [ i ] + prop . name ; prop . value = valuePads [ i ] + prop . value ; } ) ; property . value ( valuePads [ valuePads . length - 1 ] + property . value ( ) ) ; } // put vendor-prefixed definitions before current rule propsToInsert . forEach ( function ( prop ) { rule . add ( prop . name , prop . value , rule . indexOf ( property ) ) ; } ) ; // put vanilla-clean gradient definition into current rule property . value ( insertGradientsIntoCSSValue ( gradients , value , { placeholder : '${2}' , omitDefaultDirection : omitDir } ) ) ; }
Pastes gradient definition into CSS rule with correct vendor-prefixes
@param {EditElement} property Matched CSS property
@param {Array} gradients List of gradients to insert
Pastes gradient definition into CSS rule with correct vendor - prefixes