diff options
| author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 | 
|---|---|---|
| committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 | 
| commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
| tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/clean-css/lib/optimizer/level-1 | |
| parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) | |
update packages
Diffstat (limited to 'node_modules/clean-css/lib/optimizer/level-1')
| -rw-r--r-- | node_modules/clean-css/lib/optimizer/level-1/optimize.js | 32 | ||||
| -rw-r--r-- | node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js | 2 | 
2 files changed, 21 insertions, 13 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 82cb9531d..13cfd8c52 100644 --- a/node_modules/clean-css/lib/optimizer/level-1/optimize.js +++ b/node_modules/clean-css/lib/optimizer/level-1/optimize.js @@ -19,6 +19,8 @@ var Marker = require('../../tokenizer/marker');  var formatPosition = require('../../utils/format-position');  var split = require('../../utils/split'); +var serializeRules = require('../../writer/one-time').rules; +  var IgnoreProperty = 'ignore-property';  var CHARSET_TOKEN = '@charset'; @@ -29,6 +31,7 @@ var DEFAULT_ROUNDING_PRECISION = require('../../options/rounding-precision').DEF  var WHOLE_PIXEL_VALUE = /(?:^|\s|\()(-?\d+)px/;  var TIME_VALUE = /^(\-?[\d\.]+)(m?s)$/; +var HEX_VALUE_PATTERN = /[0-9a-f]/i;  var PROPERTY_NAME_PATTERN = /^(?:\-chrome\-|\-[\w\-]+\w|\w[\w\-]+\w|\-\-\S+)$/;  var IMPORT_PREFIX_PATTERN = /^@import/i;  var QUOTED_PATTERN = /^('.*'|".*")$/; @@ -98,11 +101,15 @@ 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})($|[^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() + suffix; +    .replace(/(^|[^='"])#([0-9a-f]{6})/gi, function (match, prefix, color, at, inputValue) { +      var suffix = inputValue[at + match.length]; + +      if (suffix && HEX_VALUE_PATTERN.test(suffix)) { +        return match; +      } else if (color[0] == color[1] && color[2] == color[3] && color[4] == color[5]) { +        return (prefix + '#' + color[0] + color[2] + color[4]).toLowerCase();        } else { -        return (prefix + '#' + color).toLowerCase() + suffix; +        return (prefix + '#' + color).toLowerCase();        }      })      .replace(/(^|[^='"])#([0-9a-f]{3})/gi, function (match, prefix, color) { @@ -329,7 +336,7 @@ function optimizeZeroUnits(name, value) {  }  function removeQuotes(name, value) { -  if (name == 'content' || name.indexOf('font-feature-settings') > -1 || name.indexOf('grid-') > -1) { +  if (name == 'content' || name.indexOf('font-variation-settings') > -1 || name.indexOf('font-feature-settings') > -1 || name.indexOf('grid-') > -1) {      return value;    } @@ -344,8 +351,9 @@ function removeUrlQuotes(value) {      value;  } -function transformValue(propertyName, propertyValue, transformCallback) { -  var transformedValue = transformCallback(propertyName, propertyValue); +function transformValue(propertyName, propertyValue, rule, transformCallback) { +  var selector = serializeRules(rule); +  var transformedValue = transformCallback(propertyName, propertyValue, selector);    if (transformedValue === undefined) {      return propertyValue; @@ -358,7 +366,7 @@ function transformValue(propertyName, propertyValue, transformCallback) {  // -function optimizeBody(properties, context) { +function optimizeBody(rule, properties, context) {    var options = context.options;    var levelOptions = options.level[OptimizationLevel.One];    var property, name, type, value; @@ -403,7 +411,7 @@ function optimizeBody(properties, context) {      }      if (property.block) { -      optimizeBody(property.value[0][1], context); +      optimizeBody(rule, property.value[0][1], context);        continue;      } @@ -462,7 +470,7 @@ function optimizeBody(properties, context) {          }        } -      value = transformValue(name, value, levelOptions.transform); +      value = transformValue(name, value, rule, levelOptions.transform);        if (value === IgnoreProperty) {          property.unused = true; @@ -632,7 +640,7 @@ function level1Optimize(tokens, context) {          mayHaveCharset = true;          break;        case Token.AT_RULE_BLOCK: -        optimizeBody(token[2], context); +        optimizeBody(token[1], token[2], context);          afterRules = true;          break;        case Token.NESTED_BLOCK: @@ -646,7 +654,7 @@ function level1Optimize(tokens, context) {        case Token.RULE:          token[1] = levelOptions.tidySelectors ? tidyRules(token[1], !ie7Hack, adjacentSpace, format, context.warnings) : token[1];          token[1] = token[1].length > 1 ? sortSelectors(token[1], levelOptions.selectorsSortingMethod) : token[1]; -        optimizeBody(token[2], context); +        optimizeBody(token[1], token[2], context);          afterRules = true;          break;      } 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 0af3b2fe7..d046d0efd 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 @@ -68,7 +68,7 @@ function removeWhitespace(value, format) {      character = value[i];      isNewLineNix = character == Marker.NEW_LINE_NIX; -    isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.NEW_LINE_WIN; +    isNewLineWin = character == Marker.NEW_LINE_NIX && value[i - 1] == Marker.CARRIAGE_RETURN;      isQuoted = isSingleQuoted || isDoubleQuoted;      isRelation = !isAttribute && !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character);      isWhitespace = WHITESPACE_PATTERN.test(character); | 
