Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clean-css

Package Overview
Dependencies
Maintainers
2
Versions
211
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clean-css - npm Package Compare versions

Comparing version 4.0.8 to 4.0.9

15

lib/optimizer/level-1/optimize.js

@@ -291,10 +291,9 @@ var shortenHex = require('./shorten-hex');

function optimizePrecision(_, value, precisionOptions) {
var optimizedValue = value.replace(/(\d)\.($|\D)/g, '$1$2');
if (!precisionOptions.matcher || value.indexOf('.') === -1) {
return optimizedValue;
if (!precisionOptions.enabled || value.indexOf('.') === -1) {
return value;
}
return optimizedValue
.replace(precisionOptions.matcher, function (match, integerPart, fractionPart, unit) {
return value
.replace(precisionOptions.decimalPointMatcher, '$1$2$3')
.replace(precisionOptions.zeroMatcher, function (match, integerPart, fractionPart, unit) {
var multiplier = precisionOptions.units[unit].multiplier;

@@ -653,3 +652,5 @@ var parsedInteger = parseInt(integerPart);

if (optimizable.length > 0) {
precisionOptions.matcher = new RegExp('(\\d*)(\\.\\d+)(' + optimizable.join('|') + ')', 'g');
precisionOptions.enabled = true;
precisionOptions.decimalPointMatcher = new RegExp('(\\d)\\.($|' + optimizable.join('|') + ')($|\W)', 'g');
precisionOptions.zeroMatcher = new RegExp('(\\d*)(\\.\\d+)(' + optimizable.join('|') + ')', 'g');
}

@@ -656,0 +657,0 @@

@@ -0,5 +1,10 @@

var SUPPORTED_COMPACT_BLOCK_MATCHER = /^@media\W/;
function tidyBlock(values, spaceAfterClosingBrace) {
var withoutSpaceAfterClosingBrace;
var i;
for (i = values.length - 1; i >= 0; i--) {
withoutSpaceAfterClosingBrace = !spaceAfterClosingBrace && SUPPORTED_COMPACT_BLOCK_MATCHER.test(values[i][1]);
values[i][1] = values[i][1]

@@ -12,3 +17,3 @@ .replace(/\n|\r\n/g, ' ')

.replace(/"([a-zA-Z][a-zA-Z\d\-_]+)"/, '$1')
.replace(spaceAfterClosingBrace ? null : /\) /g, ')');
.replace(withoutSpaceAfterClosingBrace ? /\) /g : null, ')');
}

@@ -15,0 +20,0 @@

@@ -5,3 +5,9 @@ var Spaces = require('../../options/format').Spaces;

var CASE_ATTRIBUTE_PATTERN = /[\s"'][iI]\s*\]/;
var CASE_RESTORE_PATTERN = /([\d\w])([iI])\]/g;
var DOUBLE_QUOTE_CASE_PATTERN = /="([a-zA-Z][a-zA-Z\d\-_]+)"([iI])/g;
var DOUBLE_QUOTE_PATTERN = /="([a-zA-Z][a-zA-Z\d\-_]+)"(\s|\])/g;
var HTML_COMMENT_PATTERN = /^(?:(?:<!--|-->)\s*)+/;
var SINGLE_QUOTE_CASE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'([iI])/g;
var SINGLE_QUOTE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'(\s|\])/g;
var RELATION_PATTERN = /[>\+~]/;

@@ -58,2 +64,3 @@ var WHITESPACE_PATTERN = /\s/;

var wasWhitespace = false;
var withCaseAttribute = CASE_ATTRIBUTE_PATTERN.test(value);
var spaceAroundRelation = format && format.spaces[Spaces.AroundSelectorRelation];

@@ -133,9 +140,17 @@ var i, l;

return stripped.join('');
return stripped
.join('')
.replace(withCaseAttribute ? CASE_RESTORE_PATTERN : null, '$1 $2]');
}
function removeQuotes(value) {
if (value.indexOf('\'') == -1 && value.indexOf('"') == -1) {
return value;
}
return value
.replace(/='([a-zA-Z][a-zA-Z\d\-_]+)'/g, '=$1')
.replace(/="([a-zA-Z][a-zA-Z\d\-_]+)"/g, '=$1');
.replace(SINGLE_QUOTE_CASE_PATTERN, '=$1 $2')
.replace(SINGLE_QUOTE_PATTERN, '=$1$2')
.replace(DOUBLE_QUOTE_CASE_PATTERN, '=$1 $2')
.replace(DOUBLE_QUOTE_PATTERN, '=$1$2');
}

@@ -142,0 +157,0 @@

@@ -32,3 +32,3 @@ var fs = require('fs');

return tokens.length > 0 ?
return context.options.sourceMap && tokens.length > 0 ?
doApplySourceMaps(applyContext) :

@@ -35,0 +35,0 @@ callback(tokens);

@@ -24,3 +24,5 @@ var fs = require('fs');

return doLoadOriginalSources(loadContext);
return context.options.sourceMap && context.options.sourceMapInlineSources ?
doLoadOriginalSources(loadContext) :
callback();
}

@@ -27,0 +29,0 @@

@@ -27,5 +27,3 @@ var fs = require('fs');

return applySourceMaps(tokens, context, function () {
return context.options.sourceMapInlineSources ?
loadOriginalSources(context, function () { return callback(tokens); }) :
callback(tokens);
return loadOriginalSources(context, function () { return callback(tokens); });
});

@@ -32,0 +30,0 @@ });

{
"name": "clean-css",
"version": "4.0.8",
"version": "4.0.9",
"author": "Jakub Pawlowicz <contact@jakubpawlowicz.com> (http://twitter.com/jakubpawlowicz)",

@@ -5,0 +5,0 @@ "description": "A well-tested CSS minifier",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc