* Fixed issue [#500](https://github.com/jakubpawlowicz/clean-css/issues/500) - merging duplicate adjacent properties.
* Fixed issue [#507](https://github.com/jakubpawlowicz/clean-css/issues/507) - merging longhands into many shorthands.
* Fixed issue [#508](https://github.com/jakubpawlowicz/clean-css/issues/508) - removing duplicate media queries.
+* Fixed issue [#526](https://github.com/jakubpawlowicz/clean-css/issues/526) - shorthand overriding into a function.
[3.1.9 / 2015-04-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.8...v3.1.9)
==================
return count > 1;
}
+function mergingIntoFunction(left, right, validator) {
+ for (var i = 0, l = left.components.length; i < l; i++) {
+ if (anyValue(validator.isValidFunction, left.components[i]))
+ return true;
+ }
+
+ return false;
+}
+
+function anyValue(fn, property) {
+ for (var i = 0, l = property.value.length; i < l; i++) {
+ if (property.value[i][0] == MULTIPLEX_SEPARATOR)
+ continue;
+
+ if (fn(property.value[i][0]))
+ return true;
+ }
+
+ return false;
+}
+
function wouldResultInLongerValue(left, right) {
if (!left.multiplex && !right.multiplex || left.multiplex && right.multiplex)
return false;
if (moreSameShorthands(properties, i - 1, left.name))
continue;
+ if (mergingIntoFunction(left, right, validator))
+ continue;
+
component = left.components.filter(nameMatchFilter(right))[0];
if (everyCombination(mayOverride, component, right, validator)) {
var disabledBackgroundSizeMerging = !compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1;
]);
}
},
- 'shorthand then longhand - color into a function': {
- 'topic': 'p{background:linear-gradient();background-color:red}',
- 'into': function (topic) {
- assert.deepEqual(_optimize(topic, { properties: { backgroundSizeMerging: false } }), [
- [['background', false , false], ['linear-gradient()'], ['red']]
- ]);
- }
- },
'shorthand then longhand - color into a color - with merging off': {
'topic': 'p{background:white;background-color:red}',
'into': function (topic) {
]);
}
},
+ 'shorthand then longhand - non-function into a function': {
+ 'topic': 'p{background:linear-gradient();background-color:red}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background', false , false], ['linear-gradient()']],
+ [['background-color', false , false], ['red']]
+ ]);
+ }
+ },
+ 'shorthand then longhand - function into a non-function': {
+ 'topic': 'p{background:repeat-x;background-image:-webkit-linear-gradient()}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic), [
+ [['background', false , false], ['repeat-x']],
+ [['background-image', false , false], ['-webkit-linear-gradient()']]
+ ]);
+ }
+ },
'shorthand then shorthand - same values': {
'topic': 'p{background:red;background:red}',
'into': function (topic) {