Comparing version 0.0.15 to 0.0.16
@@ -5,3 +5,3 @@ { | ||
"description": "Port of YUI CSS Compressor to NodeJS", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "css", |
@@ -5,2 +5,4 @@ UglifyCSS is a port of [YUI Compressor](https://github.com/yui/yuicompressor) to [NodeJS](http://nodejs.org) for its CSS part. Its name is a reference to the awesome [UglifyJS](https://github.com/mishoo/UglifyJS) but UglifyCSS is not a CSS parser. Like YUI CSS Compressor, it applies many regexp replacements. Note that a [port to JavaScript](https://github.com/yui/ycssmin) is also available in the YUI Compressor repository. | ||
Be sure to submit valid CSS to UglifyCSS or you could get weird results. | ||
### Installation | ||
@@ -7,0 +9,0 @@ |
@@ -260,2 +260,31 @@ /** | ||
// Collect all comment blocks and return new content with comment placeholders | ||
// (comments is an array thus passed by reference) | ||
function collectComments(content, comments) { | ||
var table = []; | ||
var from = 0; | ||
var start, end; | ||
while (true) { | ||
start = content.indexOf("/*", from); | ||
if (start > -1) { | ||
end = content.indexOf("*/", start + 2); | ||
if (end > -1) { | ||
comments.push(content.slice(start + 2, end)); | ||
table.push(content.slice(from, start)); | ||
table.push("/*___PRESERVE_CANDIDATE_COMMENT_" + (comments.length - 1) + "___*/"); | ||
from = end + 2; | ||
} else { | ||
// unterminated comment | ||
end = -2; | ||
break; | ||
} | ||
} else { | ||
break; | ||
} | ||
} | ||
table.push(content.slice(end + 2)); | ||
return table.join(""); | ||
} | ||
// Uglify a CSS string | ||
@@ -266,3 +295,2 @@ | ||
var startIndex, | ||
endIndex, | ||
comments = [], | ||
@@ -282,25 +310,8 @@ preservedTokens = [], | ||
lines = [], | ||
vars = {}, | ||
partial; | ||
vars = {}; | ||
options = options || defaultOptions; | ||
content = extractDataUrls(content, preservedTokens); | ||
content = collectComments(content, comments); | ||
// collect all comment blocks... | ||
content = content.split("/*"); | ||
partial = ""; | ||
for (i = 0, c = content.length; i < c; ++i) { | ||
endIndex = content[i].indexOf("*/"); | ||
if (endIndex > -1) { | ||
comments.push(partial + content[i].slice(0, endIndex)); | ||
partial = ""; | ||
content[i] = "/*___PRESERVE_CANDIDATE_COMMENT_" + (comments.length - 1) + "___" + content[i].slice(endIndex); | ||
} else if (i > 0) { | ||
partial += content[i]; | ||
content[i] = ""; | ||
} | ||
} | ||
content = content.join("") + partial; | ||
// preserve strings so their content doesn't get accidentally minified | ||
@@ -307,0 +318,0 @@ pattern = /("([^\\"]|\\.|\\)*")|('([^\\']|\\.|\\)*')/g; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
6398311
141
117199
73
1