* See #158.
==================
* Adds 0deg to 0 minification where possible.
+* Adds better non-adjacent selector merging when body is the same.
* Fixed issue [#182](https://github.com/GoalSmashers/clean-css/issues/182) - removing space after closing brace.
[3.0.2 / 2015-01-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.1...v3.0.2)
token.metadata.selectorsList = newSelectors.list;
}
+function unsafeSelector(value) {
+ return /\.|\*| :/.test(value);
+}
+
AdvancedOptimizer.prototype.isSpecial = function (selector) {
return this.options.compatibility.selectors.special.test(selector);
};
}
};
+AdvancedOptimizer.prototype.mergeNonAdjacentByBody = function (tokens) {
+ var candidates = {};
+
+ for (var i = tokens.length - 1; i >= 0; i--) {
+ var token = tokens[i];
+ if (token.kind != 'selector')
+ continue;
+
+ if (token.body.length > 0 && unsafeSelector(token.metadata.selector))
+ candidates = {};
+
+ var oldToken = candidates[token.metadata.body];
+ if (oldToken && !this.isSpecial(token.metadata.selector) && !this.isSpecial(oldToken.metadata.selector)) {
+ changeSelectorOf(
+ token,
+ CleanUp.selectors(oldToken.value.concat(token.value), false)
+ );
+
+ oldToken.body = [];
+ candidates[token.metadata.body] = null;
+ }
+
+ candidates[token.metadata.body] = token;
+ }
+};
+
function optimizeProperties(tokens, propertyOptimizer) {
for (var i = 0, l = tokens.length; i < l; i++) {
var token = tokens[i];
self.removeDuplicates(tokens);
self.mergeAdjacent(tokens);
+
+ self.mergeNonAdjacentByBody(tokens);
}
_optimize(tokens);
[hidden],audio:not([controls]){display:none}
html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}
button,html,input,select,textarea{font-family:sans-serif}
-body{margin:0}
+body,figure,form{margin:0}
a:focus{outline:dotted thin}
a:active,a:hover{outline:0}
h1,h2,h3,h4,h5,h6{margin:0;font-weight:700}
nav ol,nav ul{list-style:none}
img{-ms-interpolation-mode:bicubic}
svg:not(:root){overflow:hidden}
-figure,form{margin:0}
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
legend{border:0;padding:0;white-space:normal}
button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline}
a:focus,a:hover{color:#09f}
a{color:#06c;text-decoration:underline}
blockquote{margin:1.5em;color:#666;font-style:italic}
-dfn,strong{font-weight:700}
+dfn,dl dt,strong,th{font-weight:700}
dfn,em{font-style:italic}
sub,sup{line-height:0}
abbr,acronym{border-bottom:1px dotted #666}
ul{list-style-type:disc}
ol{list-style-type:decimal}
dl{margin:0 0 1.5em}
-dl dt{font-weight:700}
dd{margin-left:1.5em}
table{margin-bottom:1.4em;width:100%}
-th{font-weight:700}
thead th{background:#c3d9ff}
caption,td,th{padding:4px 10px 4px 5px}
tbody tr.even td,tbody tr:nth-child(even) td{background:#e5ecf9}
'with repeated selectors': [
'#zero>p,.one,.two{color:red}.two,#zero>p,.three{color:red}',
'#zero>p,.one,.three,.two{color:red}'
+ ],
+ 'of element selectors': [
+ 'p{color:red}a{color:#000}div{color:red}',
+ 'div,p{color:red}a{color:#000}'
+ ],
+ 'of element selectors inside @media': [
+ '@media screen{p{color:red}a{color:#000}div{color:red}}',
+ '@media screen{div,p{color:red}a{color:#000}}'
+ ],
+ 'of element selectors with a class selector in between': [
+ 'p{color:red}.a{color:#000}div{color:red}',
+ 'p{color:red}.a{color:#000}div{color:red}'
+ ],
+ 'of element selectors with an empty class selector in between': [
+ 'p{color:red}.a{}div{color:red}',
+ 'div,p{color:red}'
]
}),
'same bodies - IE8 compat': cssContext({