diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/clean-css/lib/optimizer | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/clean-css/lib/optimizer')
3 files changed, 24 insertions, 18 deletions
diff --git a/node_modules/clean-css/lib/optimizer/level-1/optimize.js b/node_modules/clean-css/lib/optimizer/level-1/optimize.js index 5a6da47c0..82cb9531d 100644 --- a/node_modules/clean-css/lib/optimizer/level-1/optimize.js +++ b/node_modules/clean-css/lib/optimizer/level-1/optimize.js @@ -98,11 +98,11 @@ function optimizeColors(name, value, compatibility) { .replace(/hsl\((-?\d+),(-?\d+)%?,(-?\d+)%?\)/g, function (match, hue, saturation, lightness) { return shortenHsl(hue, saturation, lightness); }) - .replace(/(^|[^='"])#([0-9a-f]{6})/gi, function (match, prefix, color) { + .replace(/(^|[^='"])#([0-9a-f]{6})($|[^0-9a-f])/gi, function (match, prefix, color, suffix) { if (color[0] == color[1] && color[2] == color[3] && color[4] == color[5]) { - return (prefix + '#' + color[0] + color[2] + color[4]).toLowerCase(); + return (prefix + '#' + color[0] + color[2] + color[4]).toLowerCase() + suffix; } else { - return (prefix + '#' + color).toLowerCase(); + return (prefix + '#' + color).toLowerCase() + suffix; } }) .replace(/(^|[^='"])#([0-9a-f]{3})/gi, function (match, prefix, color) { @@ -269,7 +269,7 @@ function optimizeUnits(name, value, unitsRegexp) { return value; } - if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height')) { + if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width')) { return value; } @@ -491,10 +491,7 @@ function optimizeBody(properties, context) { restoreFromOptimizing(_properties); removeUnused(_properties); - - if (_properties.length != properties.length) { - removeComments(properties, options); - } + removeComments(properties, options); } function removeComments(tokens, options) { @@ -654,7 +651,7 @@ function level1Optimize(tokens, context) { break; } - if (levelOptions.removeEmpty && (token[1].length === 0 || (token[2] && token[2].length === 0))) { + if (token[0] == Token.COMMENT && token[1].length === 0 || levelOptions.removeEmpty && (token[1].length === 0 || (token[2] && token[2].length === 0))) { tokens.splice(i, 1); i--; l--; diff --git a/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js b/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js index b47ed6b79..0af3b2fe7 100644 --- a/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js +++ b/node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js @@ -70,7 +70,7 @@ function removeWhitespace(value, format) { isNewLineNix = character == Marker.NEW_LINE_NIX; isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.NEW_LINE_WIN; isQuoted = isSingleQuoted || isDoubleQuoted; - isRelation = !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character); + isRelation = !isAttribute && !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character); isWhitespace = WHITESPACE_PATTERN.test(character); if (wasEscaped && isQuoted && isNewLineWin) { diff --git a/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js b/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js index e60d5e7c2..7285991a4 100644 --- a/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js +++ b/node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js @@ -19,7 +19,8 @@ function removeUnusedAtRules(tokens, context) { function removeUnusedAtRule(tokens, matchCallback, markCallback, context) { var atRules = {}; var atRule; - var token; + var atRuleTokens; + var atRuleToken; var zeroAt; var i, l; @@ -34,9 +35,13 @@ function removeUnusedAtRule(tokens, matchCallback, markCallback, context) { markUsedAtRules(tokens, markCallback, atRules, context); for (atRule in atRules) { - token = atRules[atRule]; - zeroAt = token[0] == Token.AT_RULE ? 1 : 2; - token[zeroAt] = []; + atRuleTokens = atRules[atRule]; + + for (i = 0, l = atRuleTokens.length; i < l; i++) { + atRuleToken = atRuleTokens[i]; + zeroAt = atRuleToken[0] == Token.AT_RULE ? 1 : 2; + atRuleToken[zeroAt] = []; + } } } @@ -60,7 +65,8 @@ function matchCounterStyle(token, atRules) { if (token[0] == Token.AT_RULE_BLOCK && token[1][0][1].indexOf('@counter-style') === 0) { match = token[1][0][1].split(' ')[1]; - atRules[match] = token; + atRules[match] = atRules[match] || []; + atRules[match].push(token); } } @@ -102,7 +108,8 @@ function matchFontFace(token, atRules) { if (property[1][1] == 'font-family') { match = property[2][1].toLowerCase(); - atRules[match] = token; + atRules[match] = atRules[match] || []; + atRules[match].push(token); break; } } @@ -155,7 +162,8 @@ function matchKeyframe(token, atRules) { if (token[0] == Token.NESTED_BLOCK && keyframeRegex.test(token[1][0][1])) { match = token[1][0][1].split(' ')[1]; - atRules[match] = token; + atRules[match] = atRules[match] || []; + atRules[match].push(token); } } @@ -200,7 +208,8 @@ function matchNamespace(token, atRules) { if (token[0] == Token.AT_RULE && token[1].indexOf('@namespace') === 0) { match = token[1].split(' ')[1]; - atRules[match] = token; + atRules[match] = atRules[match] || []; + atRules[match].push(token); } } |