clean-css
Advanced tools
Comparing version 3.4.8 to 3.4.9
@@ -0,1 +1,10 @@ | ||
[3.4.9 / 2016-01-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.8...v3.4.9) | ||
================== | ||
* Sped up merging by body advanced optimization. | ||
* 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. | ||
* Fixed issue [#714](https://github.com/jakubpawlowicz/clean-css/issues/714) - stringifying property level at rules. | ||
* Fixed issue [#715](https://github.com/jakubpawlowicz/clean-css/issues/715) - stack too deep in comment scan. | ||
[3.4.8 / 2015-11-13](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.7...v3.4.8) | ||
@@ -2,0 +11,0 @@ ================== |
@@ -126,29 +126,27 @@ var fs = require('fs'); | ||
// idx can be still within last matched comment (many @import statements inside one comment) | ||
if (idx > lastStartIndex && idx < lastEndIndex) | ||
return true; | ||
do { | ||
// idx can be still within last matched comment (many @import statements inside one comment) | ||
if (idx > lastStartIndex && idx < lastEndIndex) | ||
return true; | ||
comment = data.match(commentRegex); | ||
comment = data.match(commentRegex); | ||
if (!comment) { | ||
noComments = true; | ||
return false; | ||
} | ||
if (!comment) { | ||
noComments = true; | ||
return false; | ||
} | ||
// get the indexes relative to the current data chunk | ||
lastStartIndex = localStartIndex = comment.index; | ||
localEndIndex = localStartIndex + comment[0].length; | ||
// get the indexes relative to the current data chunk | ||
lastStartIndex = localStartIndex = comment.index; | ||
localEndIndex = localStartIndex + comment[0].length; | ||
// calculate the indexes relative to the full original data | ||
globalEndIndex = localEndIndex + lastEndIndex; | ||
globalStartIndex = globalEndIndex - comment[0].length; | ||
// calculate the indexes relative to the full original data | ||
globalEndIndex = localEndIndex + lastEndIndex; | ||
globalStartIndex = globalEndIndex - comment[0].length; | ||
// chop off data up to and including current comment block | ||
data = data.substring(localEndIndex); | ||
lastEndIndex = globalEndIndex; | ||
// chop off data up to and including current comment block | ||
data = data.substring(localEndIndex); | ||
lastEndIndex = globalEndIndex; | ||
} while (globalEndIndex < idx); | ||
// re-run scan if comment ended before the idx | ||
if (globalEndIndex < idx) | ||
return scanner(idx); | ||
return globalEndIndex > idx && idx > globalStartIndex; | ||
@@ -155,0 +153,0 @@ }; |
@@ -14,3 +14,3 @@ var wrapSingle = require('./wrap-for-optimizing').single; | ||
return function (value) { | ||
return value[0] != 'inherit' && validator.isValidStyle(value[0]); | ||
return value[0] != 'inherit' && validator.isValidStyle(value[0]) && !validator.isValidColorValue(value[0]); | ||
}; | ||
@@ -31,3 +31,3 @@ } | ||
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]); | ||
}; | ||
@@ -34,0 +34,0 @@ } |
@@ -43,2 +43,7 @@ // Functions that decide what value can override what. | ||
if (!validator.colorOpacity && (validator.isValidRgbaColor(color1) || validator.isValidHslaColor(color1))) | ||
return false; | ||
if (!validator.colorOpacity && (validator.isValidRgbaColor(color2) || validator.isValidHslaColor(color2))) | ||
return false; | ||
// (hex | named) | ||
@@ -45,0 +50,0 @@ if (validator.isValidNamedColor(color2) || validator.isValidHexColor(color2)) |
@@ -41,2 +41,4 @@ // Validates various CSS property values | ||
this.compatibleCssUnitAnyRegex = new RegExp('^(none|' + widthKeywords.join('|') + '|' + compatibleCssUnitRegexStr + '|' + cssVariableRegexStr + '|' + cssFunctionNoVendorRegexStr + '|' + cssFunctionVendorRegexStr + ')$', 'i'); | ||
this.colorOpacity = compatibility.colors.opacity; | ||
} | ||
@@ -69,5 +71,3 @@ | ||
return this.isValidNamedColor(s) || | ||
this.isValidHexColor(s) || | ||
this.isValidRgbaColor(s) || | ||
this.isValidHslaColor(s) || | ||
this.isValidColorValue(s) || | ||
this.isValidVariable(s) || | ||
@@ -77,2 +77,8 @@ this.isValidVendorPrefixedValue(s); | ||
Validator.prototype.isValidColorValue = function (s) { | ||
return this.isValidHexColor(s) || | ||
this.isValidRgbaColor(s) || | ||
this.isValidHslaColor(s); | ||
}; | ||
Validator.prototype.isValidUrl = function (s) { | ||
@@ -165,9 +171,17 @@ // NOTE: at this point all URLs are replaced with placeholders by clean-css, so we check for those placeholders | ||
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) { | ||
@@ -174,0 +188,0 @@ return /^-([A-Za-z0-9]|-)*$/gi.test(s); |
@@ -46,8 +46,11 @@ var stringifyBody = require('../stringifier/one-time').body; | ||
var oldToken = candidates[stringifyBody(token[2])]; | ||
var candidateBody = stringifyBody(token[2]); | ||
var oldToken = candidates[candidateBody]; | ||
if (oldToken && !isSpecial(options, stringifySelectors(token[1])) && !isSpecial(options, stringifySelectors(oldToken[1]))) { | ||
token[1] = cleanUpSelectors(oldToken[1].concat(token[1]), false, adjacentSpace); | ||
token[1] = token[2].length > 0 ? | ||
cleanUpSelectors(oldToken[1].concat(token[1]), false, adjacentSpace) : | ||
oldToken[1].concat(token[1]); | ||
oldToken[2] = []; | ||
candidates[stringifyBody(token[2])] = null; | ||
candidates[candidateBody] = null; | ||
} | ||
@@ -54,0 +57,0 @@ |
@@ -7,2 +7,3 @@ var extractProperties = require('./extractor'); | ||
var isSpecial = require('./is-special'); | ||
var cloneArray = require('../utils/clone-array'); | ||
@@ -13,2 +14,9 @@ function naturalSorter(a, b) { | ||
function cloneAndMergeSelectors(propertyA, propertyB) { | ||
var cloned = cloneArray(propertyA); | ||
cloned[5] = cloned[5].concat(propertyB[5]); | ||
return cloned; | ||
} | ||
function restructure(tokens, options) { | ||
@@ -278,2 +286,3 @@ var movableTokens = {}; | ||
var j, k, m; | ||
var samePropertyAt; | ||
@@ -320,4 +329,9 @@ if (token[0] == 'selector') { | ||
if (!movedSameProperty) | ||
if (!movedSameProperty) { | ||
movedSameProperty = property[0] == movedProperty[0] && property[1] == movedProperty[1]; | ||
if (movedSameProperty) { | ||
samePropertyAt = k; | ||
} | ||
} | ||
} | ||
@@ -332,4 +346,7 @@ | ||
if (!movedSameProperty) | ||
if (movedSameProperty) { | ||
movedProperties[samePropertyAt] = cloneAndMergeSelectors(movedProperties[samePropertyAt], property); | ||
} else { | ||
movedProperties.push(property); | ||
} | ||
} | ||
@@ -336,0 +353,0 @@ |
@@ -100,3 +100,3 @@ var lineBreak = require('os').EOL; | ||
if (isVariableDeclaration && Array.isArray(token[1][0][0])) { | ||
if (isVariableDeclaration && atRulesOrProperties(token[1])) { | ||
store('{', context); | ||
@@ -119,2 +119,11 @@ body(token[1], context); | ||
function atRulesOrProperties(values) { | ||
for (var i = 0, l = values.length; i < l; i++) { | ||
if (values[i][0] == AT_RULE || Array.isArray(values[i][0])) | ||
return true; | ||
} | ||
return false; | ||
} | ||
function all(tokens, context) { | ||
@@ -121,0 +130,0 @@ var joinCharacter = context.keepBreaks ? lineBreak : ''; |
{ | ||
"name": "clean-css", | ||
"version": "3.4.8", | ||
"version": "3.4.9", | ||
"author": "Jakub Pawlowicz <contact@jakubpawlowicz.com> (http://twitter.com/jakubpawlowicz)", | ||
@@ -5,0 +5,0 @@ "description": "A well-tested CSS minifier", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
299393
5805