Comparing version 1.7.0 to 1.7.1
@@ -0,1 +1,6 @@ | ||
## 1.7.1 (March 16, 2016) | ||
- pass block mode to tokenizer for correct parsing of declarations properties with `//` hack | ||
- fix wrongly `@import` and `@charset` removal on double exclamation comment | ||
## 1.7.0 (March 10, 2016) | ||
@@ -2,0 +7,0 @@ |
@@ -89,2 +89,3 @@ var List = require('../utils/list.js'); | ||
var blockNum = 1; | ||
var blockRules; | ||
@@ -99,2 +100,3 @@ if (typeof ast[0] === 'string') { | ||
block.stylesheet = compressBlock(block.stylesheet, restructuring, blockNum++, logger); | ||
blockRules = block.stylesheet.rules; | ||
@@ -116,3 +118,3 @@ if (block.comment) { | ||
// add \n after comment if block is not empty | ||
if (!block.stylesheet.rules.isEmpty()) { | ||
if (!blockRules.isEmpty()) { | ||
result.insert(List.createItem({ | ||
@@ -125,7 +127,5 @@ type: 'Raw', | ||
result.appendList(block.stylesheet.rules); | ||
if (firstAtrulesAllowed && !blockRules.isEmpty()) { | ||
var lastRule = blockRules.last(); | ||
if (firstAtrulesAllowed && !result.isEmpty()) { | ||
var lastRule = result.last(); | ||
if (lastRule.type !== 'Atrule' || | ||
@@ -136,2 +136,4 @@ (lastRule.name !== 'import' && lastRule.name !== 'charset')) { | ||
} | ||
result.appendList(blockRules); | ||
} while (block.offset < ast.length); | ||
@@ -138,0 +140,0 @@ |
@@ -71,2 +71,7 @@ 'use strict'; | ||
var blockMode = { | ||
'declaration': true, | ||
'property': true | ||
}; | ||
function parseError(message) { | ||
@@ -1604,3 +1609,3 @@ var error = new Error(message); | ||
tokens = tokenize(source, options.line, options.column); | ||
tokens = tokenize(source, blockMode.hasOwnProperty(rule), options.line, options.column); | ||
@@ -1607,0 +1612,0 @@ if (tokens.length) { |
@@ -95,3 +95,3 @@ 'use strict'; | ||
function tokenize(source, initLine, initColumn) { | ||
function tokenize(source, initBlockMode, initLine, initColumn) { | ||
function pushToken(type, line, column, value) { | ||
@@ -117,3 +117,4 @@ tokens.push({ | ||
var lastPos = 0; | ||
var blockMode = 0; | ||
var minBlockMode = initBlockMode ? 1 : 0; | ||
var blockMode = minBlockMode; | ||
var code; | ||
@@ -177,3 +178,5 @@ var next; | ||
} else if (code === RIGHT_CURLY_BRACE) { | ||
blockMode--; | ||
if (blockMode > minBlockMode) { | ||
blockMode--; | ||
} | ||
} | ||
@@ -180,0 +183,0 @@ |
{ | ||
"name": "csso", | ||
"description": "CSSO — CSS optimizer", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "CSSO (CSS Optimizer) is a CSS minifier with structural optimisations", | ||
"keywords": [ | ||
"css", | ||
"minifier", | ||
"minify", | ||
"compress", | ||
"optimisation" | ||
], | ||
"homepage": "https://github.com/css/csso", | ||
@@ -6,0 +13,0 @@ "author": "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (https://github.com/afelix)", |
@@ -5,10 +5,11 @@ [![NPM version](https://img.shields.io/npm/v/csso.svg)](https://www.npmjs.com/package/csso) | ||
[![NPM Downloads](https://img.shields.io/npm/dm/csso.svg)](https://www.npmjs.com/package/csso) | ||
[![Dependency Status](https://img.shields.io/david/css/csso.svg)](https://david-dm.org/css/csso) | ||
[![devDependency Status](https://img.shields.io/david/dev/css/csso.svg)](https://david-dm.org/css/csso#info=devDependencies) | ||
[![Twitter](https://img.shields.io/badge/Twitter-@cssoptimizer-blue.svg)](https://twitter.com/cssoptimizer) | ||
CSSO (CSS Optimizer) is a CSS minimizer unlike others. In addition to usual minification techniques it can perform structural optimization of CSS files, resulting in smaller file size compared to other minifiers. | ||
CSSO (CSS Optimizer) is a CSS minifier. It performs three sort of transformations: cleaning (removing redundant), compression (replacement for shorter form) and restructuring (merge of declarations, rulesets and so on). As a result your CSS becomes much smaller. | ||
## Install | ||
[![Originated by Yandex](https://github.com/css/csso/blob/master/docs/yandex.png)](https://www.yandex.com/) | ||
[![Sponsored by Avito](https://github.com/css/csso/blob/master/docs/avito.png)](https://www.avito.ru/) | ||
## Usage | ||
``` | ||
@@ -18,3 +19,3 @@ npm install -g csso | ||
## Usage | ||
Or try out CSSO [right in your browser](http://css.github.io/csso/csso.html) (web interface). | ||
@@ -26,2 +27,3 @@ ### Runners | ||
- Broccoli: [broccoli-csso](https://github.com/sindresorhus/broccoli-csso) | ||
- PostCSS: [postcss-csso](https://github.com/lahmatiy/postcss-csso) | ||
@@ -28,0 +30,0 @@ ### Command line |
Sorry, the diff of this file is too big to display
311132
6310
217