We don't need to do a full selector cleanup, just remove repetitions
and remap.
AdvancedOptimizer.prototype.restructure = function (tokens) {
var movableTokens = {};
var movedProperties = [];
- var adjacentSpace = this.options.compatibility.selectors.adjacentSpace;
var self = this;
function tokensToMerge(sourceTokens) {
beforeSize += selectorLength;
}
- allSelectors = CleanUp.selectors(allSelectors, false, adjacentSpace);
+ allSelectors = CleanUp.selectorDuplicates(allSelectors);
afterSize += allSelectors.list.join(',').length + valueSize;
if (afterSize < beforeSize)
};
},
+ selectorDuplicates: function (selectors) {
+ var plain = [];
+ var tokenized = [];
+
+ for (var i = 0, l = selectors.length; i < l; i++) {
+ var selector = selectors[i];
+
+ if (plain.indexOf(selector.value) == -1) {
+ plain.push(selector.value);
+ tokenized.push(selector);
+ }
+ }
+
+ return {
+ list: plain.sort(),
+ tokenized: tokenized.sort(selectorSorter)
+ };
+ },
+
block: function (block) {
return block
.replace(/\s+/g, ' ')