'ie8': /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:not|:target|:visited|:empty|:first\-of|:last|:nth|:only|:root)/
};
+ var minificationsMade = [];
+
var propertyOptimizer = new PropertyOptimizer();
var cleanUpSelector = function(selectors) {
for (var j = 0, n = forRemoval.length; j < n; j++) {
tokens.splice(forRemoval[j] - j, 1);
}
+
+ minificationsMade.unshift(forRemoval.length > 0);
};
var mergeAdjacent = function(tokens) {
for (var j = 0, m = forRemoval.length; j < m; j++) {
tokens.splice(forRemoval[j] - j, 1);
}
+
+ minificationsMade.unshift(forRemoval.length > 0);
};
var reduceNonAdjacent = function(tokens) {
var matched = {};
var matchedMoreThanOnce = [];
var partiallyReduced = [];
+ var reduced = false;
var token, selector, selectors;
for (var i = 0, l = tokens.length; i < l; i++) {
}
if (token.selector == selector) {
- token.body = reducedBody.join(';');
+ var joinedBody = reducedBody.join(';');
+ reduced = reduced || (token.body != joinedBody);
+ token.body = joinedBody;
} else {
token._partials = token._partials || [];
token._partials.push(reducedBody.join(';'));
break;
}
- if (k == n)
+ if (k == n) {
token.body = newBody;
+ reduced = reduced || true;
+ }
}
delete token._partials;
}
+
+ minificationsMade.unshift(reduced);
};
var optimize = function(tokens) {
+ var firstRun = true;
+ var noChanges = function() {
+ return !firstRun &&
+ minificationsMade[0] === false &&
+ minificationsMade[1] === false;
+ };
+
tokens = Array.isArray(tokens) ? tokens : [tokens];
for (var i = 0, l = tokens.length; i < l; i++) {
var token = tokens[i];
}
}
- removeDuplicates(tokens);
- mergeAdjacent(tokens);
- reduceNonAdjacent(tokens);
+ // Run until 2 last operations do not yield any changes
+ minificationsMade = [];
+ while (true) {
+ if (noChanges())
+ break;
+ removeDuplicates(tokens);
+
+ if (noChanges())
+ break;
+ mergeAdjacent(tokens);
+
+ if (noChanges())
+ break;
+ reduceNonAdjacent(tokens);
+
+ firstRun = false;
+ }
};
var rebuild = function(tokens) {
.site-liberation .w14unit .block-call-items .mini-tpl .big{width:392px;height:261px}
.site-liberation .w14unit .block-call-items .mini-tpl .pano{width:392px;height:85px}
.site-liberation .w11unit .block-call-items .mini-tpl .pano{width:300px;height:65px}
-.site-liberation .block-call-items .tpl-visual-square-left h5,.site-liberation .block-call-items .tpl-visual-square-left-arround h5{text-transform:none}
-.site-liberation .block-call-items .tpl-visual-square-left h5,.site-liberation .block-call-items .tpl-visual-square-left-arround h5{font-family:Georgia,"Times New Roman",Times,serif;font-size:13px;font-weight:700}
+.site-liberation .block-call-items .tpl-visual-square-left h5,.site-liberation .block-call-items .tpl-visual-square-left-arround h5{text-transform:none;font-family:Georgia,"Times New Roman",Times,serif;font-size:13px;font-weight:700}
.site-liberation .block-call-items .mini-tpl h4{font-size:16px;font-weight:700}
.site-liberation .block-call-items .tpl-flash-news-29unit,.site-liberation .block-call-items .tpl-flash-news-29unit:last-of-type{border-bottom:1px dotted #ddd;margin:0 0 14px;clear:both}
.site-liberation .block-call-items .tpl-flash-news-29unit .big{margin-right:28px}
html.js body.dummy div#mainContent div#core-liberation div.col9 div.block div.block-content div.favorites-frontpages div.col-left div.cartridge{width:388px}
html.js body.dummy div#mainContent div#core-liberation div.col9 div.block div.block-content div.favorites-folders div.block-call-items div.block-content div.mini-tpl div.cartridge{margin-left:0;width:129px}
html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand div.object-content{margin-right:0;min-height:0;border-bottom:0}
-html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand{border-bottom:1px solid #E7E7E7}
+html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand{border-bottom:1px solid #E7E7E7}
\ No newline at end of file
'p{color:red}.one{font-size:12px;text-shadow:none}'
]
}),
+ 'rerun optimizers': cssContext({
+ 'selectors reducible once': [
+ '.one{color:red;margin:0}.two{color:red}.one{margin:0}',
+ '.one,.two{color:red}.one{margin:0}'
+ ]
+ }),
'same bodies': cssContext({
'of two non-adjacent selectors': '.one{color:red}.two{color:#00f}.three{color:red}',
'of two adjacent single selectors': [