It should be handled in stringifier and so it's now.
As it turns out the previous way was not giving optimal output when
building source maps either.
var commentsProcessor = new CommentsProcessor(context, options.keepSpecialComments, options.keepBreaks, options.sourceMap);
var expressionsProcessor = new ExpressionsProcessor(options.sourceMap);
var freeTextProcessor = new FreeTextProcessor(options.sourceMap);
- var urlsProcessor = new UrlsProcessor(context, options.sourceMap, !options.compatibility.properties.spaceAfterClosingBrace);
+ var urlsProcessor = new UrlsProcessor(context, options.sourceMap);
var urlRebase = new UrlRebase(context);
var selectorsOptimizer = new SelectorsOptimizer(options, context);
}
function afterClosingBrace(token, valueIndex) {
- return token[valueIndex][0][token[valueIndex][0].length - 1] == ')';
+ return token[valueIndex][0][token[valueIndex][0].length - 1] == ')' || token[valueIndex][0].indexOf('__ESCAPED_URL_CLEAN_CSS') === 0;
}
function afterComma(token, valueIndex) {
return token[0][0] == 'filter' || token[0][0] == '-ms-filter';
}
-function inSpecialContext(token, valueIndex) {
- return afterClosingBrace(token, valueIndex) ||
+function inSpecialContext(token, valueIndex, context) {
+ return !context.spaceAfterClosingBrace && afterClosingBrace(token, valueIndex) ||
beforeSlash(token, valueIndex) ||
afterSlash(token, valueIndex) ||
beforeComma(token, valueIndex) ||
if (j == m - 1 && isImportant)
store('!important', context);
- if (j < m - 1 && (inFilter(token) || !inSpecialContext(token, j))) {
+ if (j < m - 1 && (inFilter(token) || !inSpecialContext(token, j, context))) {
store(' ', context);
} else if (j == m - 1 && !isLast && hasMoreProperties(tokens, position + 1)) {
store(';', context);
var context = {
keepBreaks: options.keepBreaks,
output: [],
+ spaceAfterClosingBrace: options.compatibility.properties.spaceAfterClosingBrace,
store: store
};
outputMap: new SourceMapGenerator(),
restore: restoreCallback,
sourceMapInlineSources: options.sourceMapInlineSources,
+ spaceAfterClosingBrace: options.compatibility.properties.spaceAfterClosingBrace,
store: store
};
var lineBreak = require('os').EOL;
-function UrlsProcessor(context, saveWaypoints, removeTrailingSpace) {
+function UrlsProcessor(context, saveWaypoints) {
this.urls = new EscapeStore('URL');
this.context = context;
this.saveWaypoints = saveWaypoints;
- this.removeTrailingSpace = removeTrailingSpace;
}
// Strip urls by replacing them by a special
var url = normalize(this.urls.restore(nextMatch.match));
tempData.push(url);
- cursor = nextMatch.end + (this.removeTrailingSpace && data[nextMatch.end] == ' ' ? 1 : 0);
+ cursor = nextMatch.end;
}
return tempData.length > 0 ?
'advanced in ie8 mode': cssContext({
'plain component to complex shorthand': [
'a{background:linear-gradient(to bottom,#000,#fff 4em) #000;background-color:#fff}',
- 'a{background:linear-gradient(to bottom,#000,#fff 4em)#000;background-color:#fff}'
+ 'a{background:linear-gradient(to bottom,#000,#fff 4em) #000;background-color:#fff}'
],
'plain component to shorthand': [
'a{background:url(bg.png) #000;background-color:#fff}',
return new CleanCSS({ sourceMap: true }).minify('a{background:url(image.png);background-color:#eee;background-repeat:repeat-x}');
},
'has right output': function (minified) {
- assert.equal(minified.styles, 'a{background:url(image.png) repeat-x #eee}');
+ assert.equal(minified.styles, 'a{background:url(image.png)repeat-x #eee}');
},
'has 5 mappings': function (minified) {
assert.lengthOf(minified.sourceMap._mappings._array, 5);
'has a `repeat-x` mapping': function (minified) {
var mapping = {
generatedLine: 1,
- generatedColumn: 28,
+ generatedColumn: 27,
originalLine: 1,
originalColumn: 68,
source: '$stdin',
'has a `#eee` mapping': function (minified) {
var mapping = {
generatedLine: 1,
- generatedColumn: 37,
+ generatedColumn: 36,
originalLine: 1,
originalColumn: 45,
source: '$stdin',
var lineBreak = require('os').EOL;
-function processorContext(name, context, saveWaypoints, removeTrailingSpace) {
+function processorContext(name, context, saveWaypoints) {
var vowContext = {};
function escaped (expected) {
return function (source) {
- var escaped = new UrlsProcessor(null, saveWaypoints, removeTrailingSpace).escape(source);
+ var escaped = new UrlsProcessor(null, saveWaypoints).escape(source);
assert.equal(escaped, expected);
};
}
function restored (expected) {
return function (source) {
- var processor = new UrlsProcessor(null, saveWaypoints, removeTrailingSpace);
+ var processor = new UrlsProcessor(null, saveWaypoints);
var restored = processor.restore(processor.escape(source));
assert.equal(restored, expected);
};
]
}, true)
)
- .addBatch(
- processorContext('trailing space', {
- 'removed': [
- 'div{background:url(some/file.png) repeat}',
- 'div{background:__ESCAPED_URL_CLEAN_CSS0(0,18)__ repeat}',
- 'div{background:url(some/file.png)repeat}'
- ],
- 'no space': [
- 'div{background:url(some/file.png)}',
- 'div{background:__ESCAPED_URL_CLEAN_CSS0(0,18)__}',
- 'div{background:url(some/file.png)}'
- ]
- }, true, true)
- )
.export(module);