From: Jakub Pawlowicz Date: Sun, 22 Mar 2015 16:56:28 +0000 (+0000) Subject: Removes empty element removal from `mergeAdjacent`. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cb95d85a319b68eb70c61df3396ee834595b48cf;p=clean-css.git Removes empty element removal from `mergeAdjacent`. After all we do it now in one pass at the end. --- diff --git a/lib/selectors/optimizers/advanced.js b/lib/selectors/optimizers/advanced.js index 2ed2fc82..ac8036e3 100644 --- a/lib/selectors/optimizers/advanced.js +++ b/lib/selectors/optimizers/advanced.js @@ -62,7 +62,6 @@ AdvancedOptimizer.prototype.removeDuplicates = function (tokens) { }; AdvancedOptimizer.prototype.mergeAdjacent = function (tokens) { - var forRemoval = []; var lastToken = [null, [], []]; var adjacentSpace = this.options.compatibility.selectors.adjacentSpace; @@ -77,19 +76,15 @@ AdvancedOptimizer.prototype.mergeAdjacent = function (tokens) { if (lastToken[0] == 'selector' && stringifySelector(token[1]) == stringifySelector(lastToken[1])) { var joinAt = [lastToken[2].length]; lastToken[2] = this.propertyOptimizer.process(token[1], lastToken[2].concat(token[2]), joinAt, true); - forRemoval.push(i); + token[2] = []; } else if (lastToken[0] == 'selector' && stringifyBody(token[2]) == stringifyBody(lastToken[2]) && !this.isSpecial(stringifySelector(token[1])) && !this.isSpecial(stringifySelector(lastToken[1]))) { lastToken[1] = CleanUp.selectors(lastToken[1].concat(token[1]), false, adjacentSpace); - forRemoval.push(i); + token[2] = []; } else { lastToken = token; } } - - for (var j = 0, m = forRemoval.length; j < m; j++) { - tokens.splice(forRemoval[j] - j, 1); - } }; AdvancedOptimizer.prototype.reduceNonAdjacent = function (tokens) {