Comparing version 1.2.11 to 1.2.12
@@ -219,2 +219,3 @@ function TRBL(name, imp) { | ||
'compressNumber': 1, | ||
'cleanUnary': 1, | ||
'compressColor': 1, | ||
@@ -273,2 +274,3 @@ 'compressDimension': 1, | ||
'compressNumber', | ||
'cleanUnary', | ||
'compressColor', | ||
@@ -306,2 +308,5 @@ 'compressDimension', | ||
}, | ||
'cleanUnary': { | ||
'unary': 1 | ||
}, | ||
'compressColor': { | ||
@@ -732,3 +737,3 @@ 'vhash': 1, | ||
CSSOCompressor.prototype.compressNumber = function(token) { | ||
CSSOCompressor.prototype.compressNumber = function(token, rule, container, i) { | ||
var x = token[2]; | ||
@@ -746,2 +751,8 @@ | ||
CSSOCompressor.prototype.cleanUnary = function(token, rule, container, i) { | ||
var next = container[i + 1]; | ||
if (next && next[1] === 'number' && next[2] === '0') return null; | ||
return token; | ||
}; | ||
CSSOCompressor.prototype.compressColor = function(token, rule, container, i) { | ||
@@ -826,5 +837,5 @@ switch(rule) { | ||
} | ||
if (container[1] === 'attrib' && /^('|")[a-zA-Z0-9]*('|")$/.test(r)) { | ||
r = r.substring(1, r.length - 1); | ||
} | ||
// if (container[1] === 'attrib' && /^('|")[a-zA-Z0-9]*('|")$/.test(r)) { | ||
// r = r.substring(1, r.length - 1); | ||
// } | ||
if (s.length !== r.length) return [{}, 'string', r]; | ||
@@ -975,2 +986,7 @@ }; | ||
CSSOCompressor.prototype.dontRestructure = { | ||
'src': 1, // https://github.com/afelix/csso/issues/50 | ||
'clip': 1 // https://github.com/afelix/csso/issues/57 | ||
}; | ||
CSSOCompressor.prototype.restructureBlock = function(token, rule, container, j, path) { | ||
@@ -1006,3 +1022,3 @@ if (container[1] === 'ruleset') { | ||
x[0].id = path + '/' + i; | ||
if (p !== 'src' && (t = props[ppre])) { // see https://github.com/afelix/csso/issues/50 about 'src' | ||
if (!this.dontRestructure[p] && (t = props[ppre])) { | ||
if ((isPseudo && freezeID === t.freezeID) || // pseudo from equal selectors group | ||
@@ -1009,0 +1025,0 @@ (!isPseudo && pseudoID === t.pseudoID) || // not pseudo from equal pseudo signature group |
@@ -10,7 +10,6 @@ # Table of contents | ||
* 2.1.4\. Removal of invalid @charset and @import declarations | ||
* 2.1.5\. Removal of quotation marks of attribute selector string | ||
* 2.1.6\. Minification of color properties | ||
* 2.1.7\. Minification of 0 | ||
* 2.1.8\. Minification of multi-line strings | ||
* 2.1.9\. Minification of the font-weight property | ||
* 2.1.5\. Minification of color properties | ||
* 2.1.6\. Minification of 0 | ||
* 2.1.7\. Minification of multi-line strings | ||
* 2.1.8\. Minification of the font-weight property | ||
* 2.2\. Structural optimization | ||
@@ -127,19 +126,4 @@ * 2.2.1\. Merging blocks with identical selectors | ||
### 2.1.5. Removal of quotation marks of attribute selector string | ||
### 2.1.5. Minification of color properties | ||
In some cases, the removal of quatation marks of attribute selector string is possible: | ||
* Before: | ||
.a[title="test"] { | ||
color: red | ||
} | ||
* After: | ||
.a[title=test] { | ||
color: red | ||
} | ||
### 2.1.6. Minification of color properties | ||
Some color values are minimized according to \[[CSS 2.1 / 4.3.6 Colors](http://www.w3.org/TR/CSS21/syndata.html#color-units)\]. | ||
@@ -166,3 +150,3 @@ | ||
### 2.1.7. Minification of 0 | ||
### 2.1.6. Minification of 0 | ||
@@ -184,3 +168,3 @@ In some cases, the numeric values can be compacted to `0` or even dropped. | ||
### 2.1.8. Minification of multi-line strings | ||
### 2.1.7. Minification of multi-line strings | ||
@@ -202,3 +186,3 @@ Multi-line strings are minified according to \[[CSS 2.1 / 4.3.7 Strings](http://www.w3.org/TR/CSS21/syndata.html#strings)\]. | ||
### 2.1.9. Minification of the font-weight property | ||
### 2.1.8. Minification of the font-weight property | ||
@@ -205,0 +189,0 @@ The `bold` and `normal` values of the `font-weight` property are minimized according to \[[CSS 2.1 / 15.6 Font boldness: the 'font-weight' property](http://www.w3.org/TR/CSS21/fonts.html#font-boldness)\]. |
@@ -10,7 +10,6 @@ # Содержание | ||
* 2.1.4\. Удаление неправильных @charset и @import | ||
* 2.1.5\. Удаление кавычек из строк в селекторе атрибута | ||
* 2.1.6\. Минимизация цвета | ||
* 2.1.7\. Минимизация 0 | ||
* 2.1.8\. Слияние многострочных строк в однострочные | ||
* 2.1.9\. Минимизация font-weight | ||
* 2.1.5\. Минимизация цвета | ||
* 2.1.6\. Минимизация 0 | ||
* 2.1.7\. Слияние многострочных строк в однострочные | ||
* 2.1.8\. Минимизация font-weight | ||
* 2.2\. Минимизация с изменением структуры | ||
@@ -131,19 +130,4 @@ * 2.2.1\. Слияние блоков с одинаковыми селекторами | ||
### 2.1.5. Удаление кавычек из строк в селекторе атрибута | ||
### 2.1.5. Минимизация цвета | ||
В некоторых случаях возможно удаление кавычек из строк в селекторе атрибута: | ||
* Before: | ||
.a[title="test"] { | ||
color: red | ||
} | ||
* After: | ||
.a[title=test] { | ||
color: red | ||
} | ||
### 2.1.6. Минимизация цвета | ||
Некоторые значения цвета минимизируются согласно \[[CSS 2.1 / 4.3.6 Colors](http://www.w3.org/TR/CSS21/syndata.html#color-units)\]. | ||
@@ -170,3 +154,3 @@ | ||
### 2.1.7. Минимизация 0 | ||
### 2.1.6. Минимизация 0 | ||
@@ -188,3 +172,3 @@ В ряде случаев числовое значение можно сократить до `0` или же отбросить `0`. | ||
### 2.1.8. Слияние многострочных строк в однострочные | ||
### 2.1.7. Слияние многострочных строк в однострочные | ||
@@ -206,3 +190,3 @@ Многострочные строки минимизируются согласно \[[CSS 2.1 / 4.3.7 Strings](http://www.w3.org/TR/CSS21/syndata.html#strings)\]. | ||
### 2.1.9. Минимизация font-weight | ||
### 2.1.8. Минимизация font-weight | ||
@@ -209,0 +193,0 @@ Значения `bold` и `normal` свойства `font-weight` минимизируются согласно \[[CSS 2.1 / 15.6 Font boldness: the 'font-weight' property](http://www.w3.org/TR/CSS21/fonts.html#font-boldness)\]. |
{ | ||
"name": "csso", | ||
"description": "CSSO — CSS optimizer", | ||
"version": "1.2.11", | ||
"version": "1.2.12", | ||
"homepage": "http://github.com/afelix/csso", | ||
@@ -6,0 +6,0 @@ "author": "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (http://github.com/afelix)", |
@@ -35,5 +35,5 @@ # 1. Introduction | ||
To install: | ||
To install (global): | ||
* run `npm install csso` | ||
* run `npm install csso -g` | ||
@@ -109,3 +109,2 @@ To update: | ||
* Removal of invalid `@charset` и `@import` declarations | ||
* Removal of quotation marks of attribute selector string | ||
* Minification of color properties | ||
@@ -139,1 +138,5 @@ * Minification of `0` | ||
* CSSO is licensed under [MIT](https://github.com/afelix/csso/blob/master/MIT-LICENSE.txt) | ||
<!-- Yandex.Metrika counter --> | ||
<img src="//mc.yandex.ru/watch/12831025" style="position:absolute; left:-9999px;" alt="" /> | ||
<!-- /Yandex.Metrika counter --> |
@@ -35,5 +35,5 @@ # 1. Описание | ||
Установка: | ||
Установка (глобально): | ||
* выполнить `npm install csso` | ||
* выполнить `npm install csso -g` | ||
@@ -109,3 +109,2 @@ Обновление: | ||
* Удаление неправильных `@charset` и `@import` | ||
* Удаление кавычек из строк в селекторе атрибута | ||
* Минимизация цвета | ||
@@ -139,1 +138,5 @@ * Минимизация `0` | ||
* CSSO распространяется под [лицензией MIT](https://github.com/afelix/csso/blob/master/MIT-LICENSE.txt) | ||
<!-- Yandex.Metrika counter --> | ||
<img src="//mc.yandex.ru/watch/12831025" style="position:absolute; left:-9999px;" alt="" /> | ||
<!-- /Yandex.Metrika counter --> |
@@ -54,2 +54,3 @@ function CSSOCompressor() {} | ||
'compressNumber': 1, | ||
'cleanUnary': 1, | ||
'compressColor': 1, | ||
@@ -108,2 +109,3 @@ 'compressDimension': 1, | ||
'compressNumber', | ||
'cleanUnary', | ||
'compressColor', | ||
@@ -141,2 +143,5 @@ 'compressDimension', | ||
}, | ||
'cleanUnary': { | ||
'unary': 1 | ||
}, | ||
'compressColor': { | ||
@@ -567,3 +572,3 @@ 'vhash': 1, | ||
CSSOCompressor.prototype.compressNumber = function(token) { | ||
CSSOCompressor.prototype.compressNumber = function(token, rule, container, i) { | ||
var x = token[2]; | ||
@@ -581,2 +586,8 @@ | ||
CSSOCompressor.prototype.cleanUnary = function(token, rule, container, i) { | ||
var next = container[i + 1]; | ||
if (next && next[1] === 'number' && next[2] === '0') return null; | ||
return token; | ||
}; | ||
CSSOCompressor.prototype.compressColor = function(token, rule, container, i) { | ||
@@ -661,5 +672,5 @@ switch(rule) { | ||
} | ||
if (container[1] === 'attrib' && /^('|")[a-zA-Z0-9]*('|")$/.test(r)) { | ||
r = r.substring(1, r.length - 1); | ||
} | ||
// if (container[1] === 'attrib' && /^('|")[a-zA-Z0-9]*('|")$/.test(r)) { | ||
// r = r.substring(1, r.length - 1); | ||
// } | ||
if (s.length !== r.length) return [{}, 'string', r]; | ||
@@ -810,2 +821,7 @@ }; | ||
CSSOCompressor.prototype.dontRestructure = { | ||
'src': 1, // https://github.com/afelix/csso/issues/50 | ||
'clip': 1 // https://github.com/afelix/csso/issues/57 | ||
}; | ||
CSSOCompressor.prototype.restructureBlock = function(token, rule, container, j, path) { | ||
@@ -841,3 +857,3 @@ if (container[1] === 'ruleset') { | ||
x[0].id = path + '/' + i; | ||
if (p !== 'src' && (t = props[ppre])) { // see https://github.com/afelix/csso/issues/50 about 'src' | ||
if (!this.dontRestructure[p] && (t = props[ppre])) { | ||
if ((isPseudo && freezeID === t.freezeID) || // pseudo from equal selectors group | ||
@@ -844,0 +860,0 @@ (!isPseudo && pseudoID === t.pseudoID) || // not pseudo from equal pseudo signature group |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
381231
1268
7386
140