Comparing version 1.2.16 to 1.2.17
@@ -172,2 +172,4 @@ function TRBL(name, imp) { | ||
this.shorts = {}; | ||
this.shorts2 = {}; | ||
this.ccrules = {}; // clean comment rules — special case to resolve ambiguity | ||
@@ -194,2 +196,6 @@ this.crules = {}; // compress rules | ||
this.initRules(this.frules, this.defFCfg); | ||
this.shortGroupID = 0; | ||
this.lastShortGroupID = 0; | ||
this.lastShortSelector = 0; | ||
}; | ||
@@ -422,2 +428,3 @@ | ||
xs = this.copyArray(x); | ||
x = this.walk(this.rjrules, x, '/0'); | ||
this.disjoin(x); | ||
@@ -458,2 +465,3 @@ x = this.walk(this.msrules, x, '/0'); | ||
var t, s, r, sr; | ||
for (var i = container.length - 1; i > -1; i--) { | ||
@@ -463,2 +471,3 @@ t = container[i]; | ||
if (t[1] === 'ruleset') { | ||
t[0].shortGroupID = this.shortGroupID++; | ||
s = t[2]; | ||
@@ -939,6 +948,8 @@ if (s.length > 3) { | ||
} | ||
var x, p, v, imp, s, key, | ||
pre = this.pathUp(path) + '/' + (freeze ? '&' + freezeID + '&' : '') + selector + '/'; | ||
var x, p, v, imp, s, key, sh, | ||
pre = this.pathUp(path) + '/' + (freeze ? '&' + freezeID + '&' : '') + selector + '/', | ||
createNew, shortsI, shortGroupID = container[0].shortGroupID; | ||
for (var i = token.length - 1; i > -1; i--) { | ||
createNew = true; | ||
x = token[i]; | ||
@@ -952,18 +963,36 @@ if (x[1] === 'declaration') { | ||
key = pre + TRBL.extractMain(p); | ||
if (s = this.shorts[key]) { | ||
if (imp && !s.imp) s.invalid = true; | ||
} else { | ||
s = new TRBL(p, imp); | ||
var shorts = this.shorts2[key] || []; | ||
shortsI = shorts.length === 0 ? 0 : shorts.length - 1; | ||
if (!this.lastShortSelector || selector === this.lastShortSelector || shortGroupID === this.lastShortGroupID) { | ||
if (shorts.length) { | ||
sh = shorts[shortsI]; | ||
if (imp && !sh.imp) sh.invalid = true; | ||
createNew = false; | ||
} | ||
} | ||
if (createNew) { | ||
x[0].replaceByShort = true; | ||
x[0].shorthandKey = key; | ||
x[0].shorthandKey = { key: key, i: shortsI }; | ||
sh = new TRBL(p, imp); | ||
shorts.push(sh); | ||
} | ||
if (!s.invalid) { | ||
s.add(p, v[0].s, v.slice(2), imp); | ||
this.shorts[key] = s; | ||
if (!sh.invalid) { | ||
x[0].removeByShort = true; | ||
x[0].shorthandKey = key; | ||
x[0].shorthandKey = { key: key, i: shortsI }; | ||
sh.add(p, v[0].s, v.slice(2), imp); | ||
} | ||
this.shorts2[key] = shorts; | ||
this.lastShortSelector = selector; | ||
this.lastShortGroupID = shortGroupID; | ||
} | ||
} | ||
} | ||
return token; | ||
@@ -974,5 +1003,5 @@ }; | ||
if (token[0].removeByShort || token[0].replaceByShort) { | ||
var s, t; | ||
var s, t, sKey = token[0].shorthandKey; | ||
s = this.shorts[token[0].shorthandKey]; | ||
s = this.shorts2[sKey.key][sKey.i]; | ||
@@ -1013,2 +1042,3 @@ if (!s.invalid && s.isOkToMinimize()) { | ||
} | ||
var x, p, v, imp, t, | ||
@@ -1148,2 +1178,3 @@ pre = this.pathUp(path) + '/' + selector + '/', | ||
x, t, ppre; | ||
if (prop in this.nlTable) { | ||
@@ -1173,2 +1204,3 @@ x = this.nlTable[prop]; | ||
th = this.getHash(ts); | ||
if (this.equalHash(th, ph)) { | ||
@@ -1175,0 +1207,0 @@ p[3] = p[3].concat(token[3].splice(2)); |
@@ -543,2 +543,53 @@ # Содержание | ||
Минимизация не происходит в случаях, когда один набор `selector X / shorthands` прерывается другим набором `selector Y / shorthands`. | ||
* Было: | ||
.test1 { | ||
margin-top: 0 | ||
} | ||
.test2 { | ||
margin-top: 100px | ||
} | ||
.test1 { | ||
margin-left: 0 | ||
} | ||
.test1 { | ||
margin-bottom: 0 | ||
} | ||
.test1 { | ||
margin-right: 0 | ||
} | ||
* Стало: | ||
.test1 { | ||
margin-top: 0 | ||
} | ||
.test2 { | ||
margin-top: 100px | ||
} | ||
.test1 { | ||
margin-left: 0; | ||
margin-bottom: 0; | ||
margin-right: 0 | ||
} | ||
* Могло быть (неправильно): | ||
.test2 { | ||
margin-top: 100px | ||
} | ||
.test1 { | ||
margin: 0 | ||
} | ||
К сожалению, результат рендеринга последнего варианта отличается от рендеринга исходного стиля, потому такая минимизация недопустима. | ||
### 2.2.9. Специальная минимизация псевдоклассов | ||
@@ -545,0 +596,0 @@ |
{ | ||
"name": "csso", | ||
"description": "CSSO — CSS optimizer", | ||
"version": "1.2.16", | ||
"version": "1.2.17", | ||
"homepage": "http://github.com/css/csso", | ||
@@ -6,0 +6,0 @@ "author": "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (http://github.com/afelix)", |
@@ -7,2 +7,4 @@ | ||
this.shorts = {}; | ||
this.shorts2 = {}; | ||
this.ccrules = {}; // clean comment rules — special case to resolve ambiguity | ||
@@ -29,2 +31,6 @@ this.crules = {}; // compress rules | ||
this.initRules(this.frules, this.defFCfg); | ||
this.shortGroupID = 0; | ||
this.lastShortGroupID = 0; | ||
this.lastShortSelector = 0; | ||
}; | ||
@@ -257,2 +263,3 @@ | ||
xs = this.copyArray(x); | ||
x = this.walk(this.rjrules, x, '/0'); | ||
this.disjoin(x); | ||
@@ -293,2 +300,3 @@ x = this.walk(this.msrules, x, '/0'); | ||
var t, s, r, sr; | ||
for (var i = container.length - 1; i > -1; i--) { | ||
@@ -298,2 +306,3 @@ t = container[i]; | ||
if (t[1] === 'ruleset') { | ||
t[0].shortGroupID = this.shortGroupID++; | ||
s = t[2]; | ||
@@ -774,6 +783,8 @@ if (s.length > 3) { | ||
} | ||
var x, p, v, imp, s, key, | ||
pre = this.pathUp(path) + '/' + (freeze ? '&' + freezeID + '&' : '') + selector + '/'; | ||
var x, p, v, imp, s, key, sh, | ||
pre = this.pathUp(path) + '/' + (freeze ? '&' + freezeID + '&' : '') + selector + '/', | ||
createNew, shortsI, shortGroupID = container[0].shortGroupID; | ||
for (var i = token.length - 1; i > -1; i--) { | ||
createNew = true; | ||
x = token[i]; | ||
@@ -787,18 +798,36 @@ if (x[1] === 'declaration') { | ||
key = pre + TRBL.extractMain(p); | ||
if (s = this.shorts[key]) { | ||
if (imp && !s.imp) s.invalid = true; | ||
} else { | ||
s = new TRBL(p, imp); | ||
var shorts = this.shorts2[key] || []; | ||
shortsI = shorts.length === 0 ? 0 : shorts.length - 1; | ||
if (!this.lastShortSelector || selector === this.lastShortSelector || shortGroupID === this.lastShortGroupID) { | ||
if (shorts.length) { | ||
sh = shorts[shortsI]; | ||
if (imp && !sh.imp) sh.invalid = true; | ||
createNew = false; | ||
} | ||
} | ||
if (createNew) { | ||
x[0].replaceByShort = true; | ||
x[0].shorthandKey = key; | ||
x[0].shorthandKey = { key: key, i: shortsI }; | ||
sh = new TRBL(p, imp); | ||
shorts.push(sh); | ||
} | ||
if (!s.invalid) { | ||
s.add(p, v[0].s, v.slice(2), imp); | ||
this.shorts[key] = s; | ||
if (!sh.invalid) { | ||
x[0].removeByShort = true; | ||
x[0].shorthandKey = key; | ||
x[0].shorthandKey = { key: key, i: shortsI }; | ||
sh.add(p, v[0].s, v.slice(2), imp); | ||
} | ||
this.shorts2[key] = shorts; | ||
this.lastShortSelector = selector; | ||
this.lastShortGroupID = shortGroupID; | ||
} | ||
} | ||
} | ||
return token; | ||
@@ -809,5 +838,5 @@ }; | ||
if (token[0].removeByShort || token[0].replaceByShort) { | ||
var s, t; | ||
var s, t, sKey = token[0].shorthandKey; | ||
s = this.shorts[token[0].shorthandKey]; | ||
s = this.shorts2[sKey.key][sKey.i]; | ||
@@ -848,2 +877,3 @@ if (!s.invalid && s.isOkToMinimize()) { | ||
} | ||
var x, p, v, imp, t, | ||
@@ -983,2 +1013,3 @@ pre = this.pathUp(path) + '/' + selector + '/', | ||
x, t, ppre; | ||
if (prop in this.nlTable) { | ||
@@ -1008,2 +1039,3 @@ x = this.nlTable[prop]; | ||
th = this.getHash(ts); | ||
if (this.equalHash(th, ph)) { | ||
@@ -1010,0 +1042,0 @@ p[3] = p[3].concat(token[3].splice(2)); |
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
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
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
387315
1287
7520