clean-css
Advanced tools
Comparing version 5.1.2 to 5.1.3
@@ -466,3 +466,5 @@ var InvalidPropertyError = require('../invalid-property-error'); | ||
splitComponents.push(splitWith(_property, configuration, validator)); | ||
if (_property.value.length > 0) { | ||
splitComponents.push(splitWith(_property, configuration, validator)); | ||
} | ||
} | ||
@@ -469,0 +471,0 @@ |
var startsAsUrl = require('./starts-as-url'); | ||
var WHITESPACE_PATTERN = /\\?\n|\\?\r\n/g; | ||
var WHITESPACE_PREFIX_PATTERN = /(\()\s+/g; | ||
var WHITESPACE_SUFFIX_PATTERN = /\s+(\))/g; | ||
@@ -12,3 +14,6 @@ var plugin = { | ||
return value.replace(WHITESPACE_PATTERN, ''); | ||
return value | ||
.replace(WHITESPACE_PATTERN, '') | ||
.replace(WHITESPACE_PREFIX_PATTERN, '$1') | ||
.replace(WHITESPACE_SUFFIX_PATTERN, '$1'); | ||
} | ||
@@ -15,0 +20,0 @@ } |
@@ -1,3 +0,33 @@ | ||
var FUNCTION_PATTERN = /^(?:\-moz\-calc|\-webkit\-calc|calc|rgb|hsl|rgba|hsla|min|max|clamp)\(/; | ||
var split = require('../../../utils/split'); | ||
var ANY_FUNCTION_PATTERN = /^(\-(?:moz|ms|o|webkit)\-[a-z\-]+|[a-z\-]+)\((.+)\)$/; | ||
var SKIP_FUNCTION_PATTERN = /^(?:\-moz\-calc|\-webkit\-calc|calc|rgb|hsl|rgba|hsla|min|max|clamp|expression)\(/; | ||
var TOKEN_SEPARATOR_PATTERN = /([\s,\/])/; | ||
function removeRecursively(value, options) { | ||
var functionTokens; | ||
var tokens; | ||
if (SKIP_FUNCTION_PATTERN.test(value)) { | ||
return value; | ||
} | ||
functionTokens = ANY_FUNCTION_PATTERN.exec(value); | ||
if (!functionTokens) { | ||
return removeZeros(value, options); | ||
} | ||
tokens = split(functionTokens[2], TOKEN_SEPARATOR_PATTERN) | ||
.map(function (token) { return removeRecursively(token, options); }); | ||
return functionTokens[1] + '(' + tokens.join('') + ')'; | ||
} | ||
function removeZeros(value, options) { | ||
return value | ||
.replace(options.unitsRegexp, '$1' + '0' + '$2') | ||
.replace(options.unitsRegexp, '$1' + '0' + '$2'); | ||
} | ||
var plugin = { | ||
@@ -10,6 +40,2 @@ level1: { | ||
if (FUNCTION_PATTERN.test(value)) { | ||
return value; | ||
} | ||
if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width')) { | ||
@@ -19,5 +45,3 @@ return value; | ||
return value | ||
.replace(options.unitsRegexp, '$1' + '0' + '$2') | ||
.replace(options.unitsRegexp, '$1' + '0' + '$2'); | ||
return removeRecursively(value, options); | ||
} | ||
@@ -24,0 +48,0 @@ } |
var Marker = require('../tokenizer/marker'); | ||
function is(value, separator, isSeparatorRegex) { | ||
return isSeparatorRegex ? | ||
separator.test(value) : | ||
value === separator; | ||
} | ||
function split(value, separator) { | ||
@@ -13,4 +19,5 @@ var openLevel = Marker.OPEN_ROUND_BRACKET; | ||
var parts = []; | ||
var isSeparatorRegex = typeof(separator) == 'object' && 'exec' in separator; | ||
if (value.indexOf(separator) == -1) { | ||
if (!isSeparatorRegex && value.indexOf(separator) == -1) { | ||
return [value]; | ||
@@ -30,4 +37,9 @@ } | ||
if (level === 0 && cursor > 0 && cursor + 1 < len && value[cursor] == separator) { | ||
if (level === 0 && cursor > 0 && cursor + 1 < len && is(value[cursor], separator, isSeparatorRegex)) { | ||
parts.push(value.substring(lastStart, cursor)); | ||
if (isSeparatorRegex && separator.exec(value[cursor]).length > 1) { | ||
parts.push(value[cursor]); | ||
} | ||
lastStart = cursor + 1; | ||
@@ -42,3 +54,3 @@ } | ||
lastCharacter = lastValue[lastValue.length - 1]; | ||
if (lastCharacter == separator) { | ||
if (is(lastCharacter, separator, isSeparatorRegex)) { | ||
lastValue = lastValue.substring(0, lastValue.length - 1); | ||
@@ -45,0 +57,0 @@ } |
{ | ||
"name": "clean-css", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"author": "Jakub Pawlowicz <contact@jakubpawlowicz.com> (https://jakubpawlowicz.com)", | ||
@@ -5,0 +5,0 @@ "description": "A well-tested CSS minifier", |
Sorry, the diff of this file is too big to display
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
481701
10328