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/level-1 | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/clean-css/lib/optimizer/level-1')
-rw-r--r-- | node_modules/clean-css/lib/optimizer/level-1/optimize.js | 15 | ||||
-rw-r--r-- | node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js | 2 |
2 files changed, 7 insertions, 10 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) { |