==================
* Fixed issue [#693](https://github.com/jakubpawlowicz/clean-css/issues/693) - restructuring edge case.
+* Fixed issue [#711](https://github.com/jakubpawlowicz/clean-css/issues/711) - border fuzzy matching.
[3.4.8 / 2015-11-13](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.7...v3.4.8)
==================
function _styleFilter(validator) {
return function (value) {
- return value[0] != 'inherit' && validator.isValidStyle(value[0]);
+ return value[0] != 'inherit' && validator.isValidStyle(value[0]) && !validator.isValidColorValue(value[0]);
};
}
function _widthFilter(validator) {
return function (value) {
- return value[0] != 'inherit' && validator.isValidWidth(value[0]);
+ return value[0] != 'inherit' && validator.isValidWidth(value[0]) && !validator.isValidStyleKeyword(value[0]) && !validator.isValidColorValue(value[0]);
};
}
var color1 = property1.value[0][0];
var color2 = property2.value[0][0];
+ if (!validator.colorOpacity && (validator.isValidRgbaColor(color1) || validator.isValidHslaColor(color1)))
+ return false;
+ if (!validator.colorOpacity && (validator.isValidRgbaColor(color2) || validator.isValidHslaColor(color2)))
+ return false;
+
// (hex | named)
if (validator.isValidNamedColor(color2) || validator.isValidHexColor(color2))
return true;
var compatibleCssUnitRegexStr = '(\\-?\\.?\\d+\\.?\\d*(' + validUnits.join('|') + '|)|auto|inherit)';
this.compatibleCssUnitRegex = new RegExp('^' + compatibleCssUnitRegexStr + '$', 'i');
this.compatibleCssUnitAnyRegex = new RegExp('^(none|' + widthKeywords.join('|') + '|' + compatibleCssUnitRegexStr + '|' + cssVariableRegexStr + '|' + cssFunctionNoVendorRegexStr + '|' + cssFunctionVendorRegexStr + ')$', 'i');
+
+ this.colorOpacity = compatibility.colors.opacity;
}
Validator.prototype.isValidHexColor = function (s) {
Validator.prototype.isValidColor = function (s) {
return this.isValidNamedColor(s) ||
- this.isValidHexColor(s) ||
- this.isValidRgbaColor(s) ||
- this.isValidHslaColor(s) ||
+ this.isValidColorValue(s) ||
this.isValidVariable(s) ||
this.isValidVendorPrefixedValue(s);
};
+Validator.prototype.isValidColorValue = function (s) {
+ return this.isValidHexColor(s) ||
+ this.isValidRgbaColor(s) ||
+ this.isValidHslaColor(s);
+};
+
Validator.prototype.isValidUrl = function (s) {
// NOTE: at this point all URLs are replaced with placeholders by clean-css, so we check for those placeholders
return s.indexOf('__ESCAPED_URL_CLEAN_CSS') === 0;
};
Validator.prototype.isValidStyle = function (s) {
- return styleKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
+ return this.isValidStyleKeyword(s) || this.isValidVariable(s);
+};
+
+Validator.prototype.isValidStyleKeyword = function (s) {
+ return styleKeywords.indexOf(s) >= 0;
};
Validator.prototype.isValidWidth = function (s) {
- return this.isValidUnit(s) || widthKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
+ return this.isValidUnit(s) || this.isValidWidthKeyword(s) || this.isValidVariable(s);
+};
+
+Validator.prototype.isValidWidthKeyword = function (s) {
+ return widthKeywords.indexOf(s) >= 0;
};
Validator.prototype.isValidVendorPrefixedValue = function (s) {
assert.deepEqual(components[2].name, 'border-color');
assert.deepEqual(components[2].value, [['red']]);
}
+ },
+ 'missing width': {
+ 'topic': function () {
+ return _breakUp([[['border'], ['solid'], ['rgba(0,0,0,0)']]]);
+ },
+ 'has 3 components': function (components) {
+ assert.lengthOf(components, 3);
+ },
+ 'has border-width': function (components) {
+ assert.deepEqual(components[0].name, 'border-width');
+ assert.deepEqual(components[0].value, [['medium']]);
+ },
+ 'has border-style': function (components) {
+ assert.deepEqual(components[1].name, 'border-style');
+ assert.deepEqual(components[1].value, [['solid']]);
+ },
+ 'has border-color': function (components) {
+ assert.deepEqual(components[2].name, 'border-color');
+ assert.deepEqual(components[2].value, [['rgba(0,0,0,0)']]);
+ }
}
},
'border radius': {
]);
}
},
- 'longhand then shorthand - with unprefixed function 123': {
+ 'longhand then shorthand - with unprefixed function': {
'topic': 'p{background-color:red;background:linear-gradient(red,blue)}',
'into': function (topic) {
assert.deepEqual(_optimize(topic), [
]);
}
},
+ 'shorthand then longhand - border with rgba() and color opacity on': {
+ 'topic': 'p{border:solid rgba(0,0,0,0);border-color:transparent}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic, { colors: { opacity: true } }), [
+ [['border'], ['solid'], ['transparent']]
+ ]);
+ }
+ },
+ 'shorthand then longhand - border with rgba() and color opacity off': {
+ 'topic': 'p{border:solid rgba(0,0,0,0);border-color:transparent}',
+ 'into': function (topic) {
+ assert.deepEqual(_optimize(topic, { colors: { opacity: false } }), [
+ [['border'], ['solid'], ['rgba(0,0,0,0)']],
+ [['border-color'], ['transparent']]
+ ]);
+ }
+ },
'shorthand then longhand - color into a color - with merging off': {
'topic': 'p{background:white;background-color:red}',
'into': function (topic) {