Skip to content

Commit

Permalink
In BundleTransformer.CleanCss added support of Clean-css version 4.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Taritsyn committed Sep 6, 2017
1 parent dcd5015 commit 4441014
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
<projectUrl>https://github.com/Taritsyn/BundleTransformer</projectUrl>
<iconUrl>https://raw.githubusercontent.com/Taritsyn/BundleTransformer/master/images/icons/128/BundleTransformer_CleanCss_Logo_128x128.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>BundleTransformer.CleanCss contains one minifier-adapter for minification of CSS code - `CleanCssMinifier`. `CleanCssMinifier` is based on the Clean-css (https://github.com/jakubpawlowicz/clean-css) version 4.1.7.
<description>BundleTransformer.CleanCss contains one minifier-adapter for minification of CSS code - `CleanCssMinifier`. `CleanCssMinifier` is based on the Clean-css (https://github.com/jakubpawlowicz/clean-css) version 4.1.8.

As a JS engine is used the JavaScript Engine Switcher library (https://github.com/Taritsyn/JavaScriptEngineSwitcher). For correct working of this module, you need to install one of the following NuGet packages: JavaScriptEngineSwitcher.Msie, JavaScriptEngineSwitcher.V8 or JavaScriptEngineSwitcher.ChakraCore.</description>
<summary>BundleTransformer.CleanCss contains one minifier-adapter for minification of CSS code - `CleanCssMinifier`. `CleanCssMinifier` is based on the Clean-css version 4.1.7.</summary>
<releaseNotes>Added support of Clean-css version 4.1.7.</releaseNotes>
<summary>BundleTransformer.CleanCss contains one minifier-adapter for minification of CSS code - `CleanCssMinifier`. `CleanCssMinifier` is based on the Clean-css version 4.1.8.</summary>
<releaseNotes>Added support of Clean-css version 4.1.8.</releaseNotes>
<copyright>Copyright (c) 2012-2017 Andrey Taritsyn - http://www.taritsyn.ru</copyright>
<language>en-US</language>
<tags>BundleTransformer System.Web.Optimization IBundleTransform ASP.NET CSS Bundling Minification Minifier Minify Clean-css</tags>
<dependencies>
<dependency id="BundleTransformer.Core" version="1.9.160" />
<dependency id="BundleTransformer.Core" version="1.9.171" />
<dependency id="JavaScriptEngineSwitcher.Core" version="2.0.0" />
<dependency id="Newtonsoft.Json" version="8.0.2" />
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions NuGet/BundleTransformer.CleanCss/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
===========
BundleTransformer.CleanCss contains one minifier-adapter for minification of
CSS code - `CleanCssMinifier`. `CleanCssMinifier` is based on the Clean-css
(https://github.com/jakubpawlowicz/clean-css) version 4.1.7.
(https://github.com/jakubpawlowicz/clean-css) version 4.1.8.

As a JS engine is used the JavaScript Engine Switcher library
(https://github.com/Taritsyn/JavaScriptEngineSwitcher).

=============
RELEASE NOTES
=============
Added support of Clean-css version 4.1.7.
Added support of Clean-css version 4.1.8.

====================
POST-INSTALL ACTIONS
Expand Down
33 changes: 23 additions & 10 deletions src/BundleTransformer.CleanCss/Resources/clean-css-combined.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (!String.prototype.hasOwnProperty('repeat')) {
}

/*!
* Clean-css v4.1.7
* Clean-css v4.1.8
* https://github.com/jakubpawlowicz/clean-css
*
* Copyright (C) 2017 JakubPawlowicz.com
Expand Down Expand Up @@ -134,6 +134,7 @@ var CleanCss = (function(){
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 = /^('.*'|".*")$/;
Expand Down Expand Up @@ -203,11 +204,15 @@ var CleanCss = (function(){
.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) {
Expand Down Expand Up @@ -8599,7 +8604,6 @@ var CleanCss = (function(){
path.resolve(inlinerContext.rebaseTo, uri);
var relativeToCurrentPath = path.relative(currentPath, absoluteUri);
var importedStyles;
var importedTokens;
var isAllowed = isAllowedResource(uri, false, inlinerContext.inline);
var normalizedPath = normalizePath(relativeToCurrentPath);
var isLoaded = normalizedPath in inlinerContext.externalContext.sourcesContent;
Expand Down Expand Up @@ -8627,10 +8631,14 @@ var CleanCss = (function(){
inlinerContext.externalContext.sourcesContent[normalizedPath] = importedStyles;
inlinerContext.externalContext.stats.originalSize += importedStyles.length;
importedTokens = fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function (tokens) { return tokens; });
importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata);
return fromStyles(importedStyles, inlinerContext.externalContext, inlinerContext, function (importedTokens) {
importedTokens = wrapInMedia(importedTokens, mediaQuery, metadata);
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens);
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
inlinerContext.outputTokens = inlinerContext.outputTokens.concat(importedTokens);
return doInlineImports(inlinerContext);
});
}
inlinerContext.sourceTokens = inlinerContext.sourceTokens.slice(1);
Expand Down Expand Up @@ -8804,6 +8812,7 @@ var CleanCss = (function(){
var wasCommentStart = false;
var isCommentEnd;
var wasCommentEnd = false;
var isCommentEndMarker;
var isEscaped;
var wasEscaped = false;
var seekingValue = false;
Expand All @@ -8818,7 +8827,8 @@ var CleanCss = (function(){
isNewLineNix = character == Marker.NEW_LINE_NIX;
isNewLineWin = character == Marker.NEW_LINE_NIX && source[position.index - 1] == Marker.NEW_LINE_WIN;
isCommentStart = !wasCommentEnd && level != Level.COMMENT && !isQuoted && character == Marker.ASTERISK && source[position.index - 1] == Marker.FORWARD_SLASH;
isCommentEnd = !wasCommentStart && level == Level.COMMENT && character == Marker.FORWARD_SLASH && source[position.index - 1] == Marker.ASTERISK;
isCommentEndMarker = !wasCommentStart && !isQuoted && character == Marker.FORWARD_SLASH && source[position.index - 1] == Marker.ASTERISK;
isCommentEnd = level == Level.COMMENT && isCommentEndMarker;

metadata = buffer.length === 0 ?
[position.line, position.column, position.source] :
Expand Down Expand Up @@ -8854,6 +8864,9 @@ var CleanCss = (function(){
level = levels.pop();
metadata = metadatas.pop() || null;
buffer = buffers.pop() || [];
} else if (isCommentEndMarker && source[position.index + 1] != Marker.ASTERISK) {
externalContext.warnings.push('Unexpected \'*/\' at ' + formatPosition([position.line, position.column, position.source]) + '.');
buffer = [];
} else if (character == Marker.SINGLE_QUOTE && !isQuoted) {
// single quotation start, e.g. a[href^='https<--
levels.push(level);
Expand Down

0 comments on commit 4441014

Please sign in to comment.