if (token.kind != 'selector')
continue;
- var selectors = token.value.length > 1 && !this.isSpecial(token.metadata.selector) ?
+ var isComplexAndNotSpecial = token.value.length > 1 && !this.isSpecial(token.metadata.selector);
+ var selectors = isComplexAndNotSpecial ?
[token.metadata.selector].concat(token.metadata.selectorsList) :
[token.metadata.selector];
candidates[selector].push({
where: i,
- partial: selector != token.metadata.selector,
- list: token.metadata.selectorsList
+ list: token.metadata.selectorsList,
+ isPartial: isComplexAndNotSpecial && j > 0,
+ isComplex: isComplexAndNotSpecial && j === 0
});
}
}
var selector = repeated[i];
var data = candidates[selector];
- if (data.length < 2)
- continue;
-
/* jshint loopfunc: true */
this.reduceSelector(tokens, selector, data, {
filterOut: function (idx, bodies) {
- return data[idx].partial && bodies.length === 0;
+ return data[idx].isPartial && bodies.length === 0;
},
callback: function (token, newBody, processedCount, tokenIdx) {
- if (!data[processedCount - tokenIdx - 1].partial) {
+ if (!data[processedCount - tokenIdx - 1].isPartial) {
changeBodyOf(token, newBody);
reduced = true;
}
allSelectors:
for (var complexSelector in candidates) {
- if (complexSelector.indexOf(',') == -1)
+ var into = candidates[complexSelector];
+ if (!into[0].isComplex)
continue;
- var into = candidates[complexSelector];
var intoPosition = into[into.length - 1].where;
var intoToken = tokens[intoPosition];