Comparing version 1.2.17 to 1.2.18
@@ -43,2 +43,3 @@ function TRBL(name, imp) { | ||
var s = this.sides, | ||
currentSide, | ||
i, x, side, a = [], last, | ||
@@ -50,3 +51,3 @@ imp = imp ? 1 : 0, | ||
if (side in s) { | ||
if (!s[side]) { | ||
if (!(currentSide = s[side]) || (imp && !currentSide.imp)) { | ||
s[side] = { s: imp ? sValue.substring(0, sValue.length - 10) : sValue, t: [tValue[0]], imp: imp }; | ||
@@ -150,3 +151,3 @@ if (tValue[0][1] === 'unary') s[side].t.push(tValue[1]); | ||
if (this.imp) r.push([{ s: '!important'}, 'important']); | ||
if (this.impSum()) r.push([{ s: '!important'}, 'important']); | ||
@@ -493,2 +494,3 @@ return r; | ||
if (t && Array.isArray(t)) { | ||
t[0].parent = container; | ||
if (this.isContainer(t)) t = this.walk(rules, t, path + '/' + i); // go inside | ||
@@ -761,2 +763,8 @@ if (t === null) container.splice(i, 1); | ||
CSSOCompressor.prototype.findDeclaration = function(token) { | ||
var parent = token; | ||
while ((parent = parent[0].parent) && parent[1] !== 'declaration'); | ||
return parent; | ||
}; | ||
CSSOCompressor.prototype.cleanUnary = function(token, rule, container, i) { | ||
@@ -837,3 +845,7 @@ var next = container[i + 1]; | ||
CSSOCompressor.prototype.compressDimension = function(token) { | ||
if (token[2][2] === '0') return token[2]; | ||
var declaration; | ||
if (token[2][2] === '0') { | ||
if (token[3][2] === 's' && (declaration = this.findDeclaration(token)) && declaration[2][2][2] === '-moz-transition') return; | ||
return token[2]; | ||
} | ||
}; | ||
@@ -963,3 +975,2 @@ | ||
key = pre + TRBL.extractMain(p); | ||
var shorts = this.shorts2[key] || []; | ||
@@ -971,3 +982,3 @@ shortsI = shorts.length === 0 ? 0 : shorts.length - 1; | ||
sh = shorts[shortsI]; | ||
if (imp && !sh.imp) sh.invalid = true; | ||
//if (imp && !sh.imp) sh.invalid = true; | ||
createNew = false; | ||
@@ -1088,5 +1099,7 @@ } | ||
0 // rgba | ||
]; | ||
], | ||
vID = ''; | ||
for (var i = 0; i < _v.length; i++) { | ||
if (!vID) vID = this.getVendorIDFromToken(_v[i]); | ||
switch(_v[i][1]) { | ||
@@ -1111,5 +1124,36 @@ case 'vhash': | ||
return fp + pre + p + colorMark.join(''); | ||
return fp + pre + p + colorMark.join('') + (vID ? vID : ''); | ||
}; | ||
CSSOCompressor.prototype.vendorID = { | ||
'-o-': 'o', | ||
'-moz-': 'm', | ||
'-webkit-': 'w', | ||
'-ms-': 'i', | ||
'-epub-': 'e', | ||
'-apple-': 'a', | ||
'-xv-': 'x', | ||
'-wap-': 'p' | ||
}; | ||
CSSOCompressor.prototype.getVendorIDFromToken = function(token) { | ||
var vID; | ||
switch(token[1]) { | ||
case 'ident': | ||
if (vID = this.getVendorFromString(token[2])) return this.vendorID[vID]; | ||
break; | ||
case 'funktion': | ||
if (vID = this.getVendorFromString(token[2][2])) return this.vendorID[vID]; | ||
break; | ||
} | ||
}; | ||
CSSOCompressor.prototype.getVendorFromString = function(string) { | ||
var vendor = string.charAt(0), i; | ||
if (vendor === '-') { | ||
if ((i = string.indexOf('-', 2)) !== -1) return string.substr(0, i + 1); | ||
} | ||
return ''; | ||
}; | ||
CSSOCompressor.prototype.deleteProperty = function(block, id) { | ||
@@ -1172,8 +1216,4 @@ var d; | ||
var vendor = name.charAt(0), i; | ||
if (vendor === '-') { | ||
if ((i = name.indexOf('-', 2)) !== -1) vendor = name.substr(0, i + 1); | ||
} else vendor = ''; | ||
var prop = name.substr(vendor.length), | ||
var vendor = this.getVendorFromString(name), | ||
prop = name.substr(vendor.length), | ||
x, t, ppre; | ||
@@ -1183,3 +1223,3 @@ | ||
x = this.nlTable[prop]; | ||
for (i = 0; i < x.length; i++) { | ||
for (var i = 0; i < x.length; i++) { | ||
ppre = this.buildPPre(pre, hack + vendor + x[i], v, d, freeze); | ||
@@ -1186,0 +1226,0 @@ if (t = props[ppre]) return (!imp || t.imp); |
{ | ||
"name": "csso", | ||
"description": "CSSO — CSS optimizer", | ||
"version": "1.2.17", | ||
"version": "1.2.18", | ||
"homepage": "http://github.com/css/csso", | ||
@@ -6,0 +6,0 @@ "author": "Sergey Kryzhanovsky <skryzhanovsky@ya.ru> (http://github.com/afelix)", |
@@ -325,2 +325,3 @@ | ||
if (t && Array.isArray(t)) { | ||
t[0].parent = container; | ||
if (this.isContainer(t)) t = this.walk(rules, t, path + '/' + i); // go inside | ||
@@ -593,2 +594,8 @@ if (t === null) container.splice(i, 1); | ||
CSSOCompressor.prototype.findDeclaration = function(token) { | ||
var parent = token; | ||
while ((parent = parent[0].parent) && parent[1] !== 'declaration'); | ||
return parent; | ||
}; | ||
CSSOCompressor.prototype.cleanUnary = function(token, rule, container, i) { | ||
@@ -669,3 +676,7 @@ var next = container[i + 1]; | ||
CSSOCompressor.prototype.compressDimension = function(token) { | ||
if (token[2][2] === '0') return token[2]; | ||
var declaration; | ||
if (token[2][2] === '0') { | ||
if (token[3][2] === 's' && (declaration = this.findDeclaration(token)) && declaration[2][2][2] === '-moz-transition') return; | ||
return token[2]; | ||
} | ||
}; | ||
@@ -795,3 +806,2 @@ | ||
key = pre + TRBL.extractMain(p); | ||
var shorts = this.shorts2[key] || []; | ||
@@ -803,3 +813,3 @@ shortsI = shorts.length === 0 ? 0 : shorts.length - 1; | ||
sh = shorts[shortsI]; | ||
if (imp && !sh.imp) sh.invalid = true; | ||
//if (imp && !sh.imp) sh.invalid = true; | ||
createNew = false; | ||
@@ -920,5 +930,7 @@ } | ||
0 // rgba | ||
]; | ||
], | ||
vID = ''; | ||
for (var i = 0; i < _v.length; i++) { | ||
if (!vID) vID = this.getVendorIDFromToken(_v[i]); | ||
switch(_v[i][1]) { | ||
@@ -943,5 +955,36 @@ case 'vhash': | ||
return fp + pre + p + colorMark.join(''); | ||
return fp + pre + p + colorMark.join('') + (vID ? vID : ''); | ||
}; | ||
CSSOCompressor.prototype.vendorID = { | ||
'-o-': 'o', | ||
'-moz-': 'm', | ||
'-webkit-': 'w', | ||
'-ms-': 'i', | ||
'-epub-': 'e', | ||
'-apple-': 'a', | ||
'-xv-': 'x', | ||
'-wap-': 'p' | ||
}; | ||
CSSOCompressor.prototype.getVendorIDFromToken = function(token) { | ||
var vID; | ||
switch(token[1]) { | ||
case 'ident': | ||
if (vID = this.getVendorFromString(token[2])) return this.vendorID[vID]; | ||
break; | ||
case 'funktion': | ||
if (vID = this.getVendorFromString(token[2][2])) return this.vendorID[vID]; | ||
break; | ||
} | ||
}; | ||
CSSOCompressor.prototype.getVendorFromString = function(string) { | ||
var vendor = string.charAt(0), i; | ||
if (vendor === '-') { | ||
if ((i = string.indexOf('-', 2)) !== -1) return string.substr(0, i + 1); | ||
} | ||
return ''; | ||
}; | ||
CSSOCompressor.prototype.deleteProperty = function(block, id) { | ||
@@ -1004,8 +1047,4 @@ var d; | ||
var vendor = name.charAt(0), i; | ||
if (vendor === '-') { | ||
if ((i = name.indexOf('-', 2)) !== -1) vendor = name.substr(0, i + 1); | ||
} else vendor = ''; | ||
var prop = name.substr(vendor.length), | ||
var vendor = this.getVendorFromString(name), | ||
prop = name.substr(vendor.length), | ||
x, t, ppre; | ||
@@ -1015,3 +1054,3 @@ | ||
x = this.nlTable[prop]; | ||
for (i = 0; i < x.length; i++) { | ||
for (var i = 0; i < x.length; i++) { | ||
ppre = this.buildPPre(pre, hack + vendor + x[i], v, d, freeze); | ||
@@ -1018,0 +1057,0 @@ if (t = props[ppre]) return (!imp || t.imp); |
@@ -43,2 +43,3 @@ function TRBL(name, imp) { | ||
var s = this.sides, | ||
currentSide, | ||
i, x, side, a = [], last, | ||
@@ -50,3 +51,3 @@ imp = imp ? 1 : 0, | ||
if (side in s) { | ||
if (!s[side]) { | ||
if (!(currentSide = s[side]) || (imp && !currentSide.imp)) { | ||
s[side] = { s: imp ? sValue.substring(0, sValue.length - 10) : sValue, t: [tValue[0]], imp: imp }; | ||
@@ -150,3 +151,3 @@ if (tValue[0][1] === 'unary') s[side].t.push(tValue[1]); | ||
if (this.imp) r.push([{ s: '!important'}, 'important']); | ||
if (this.impSum()) r.push([{ s: '!important'}, 'important']); | ||
@@ -153,0 +154,0 @@ return r; |
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
392564
1303
7678