format: prettify entire project
This commit is contained in:
64
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js
generated
vendored
64
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js
generated
vendored
@ -3,7 +3,8 @@ var isMergeable = require('./is-mergeable');
|
||||
var sortSelectors = require('../level-1/sort-selectors');
|
||||
var tidyRules = require('../level-1/tidy-rules');
|
||||
|
||||
var OptimizationLevel = require('../../options/optimization-level').OptimizationLevel;
|
||||
var OptimizationLevel =
|
||||
require('../../options/optimization-level').OptimizationLevel;
|
||||
|
||||
var serializeBody = require('../../writer/one-time').body;
|
||||
var serializeRules = require('../../writer/one-time').rules;
|
||||
@ -30,27 +31,38 @@ function removeAnyUnsafeElements(left, candidates) {
|
||||
var right = candidates[body];
|
||||
var rightSelector = withoutModifier(serializeRules(right[1]));
|
||||
|
||||
if (rightSelector.indexOf(leftSelector) > -1 || leftSelector.indexOf(rightSelector) > -1)
|
||||
if (
|
||||
rightSelector.indexOf(leftSelector) > -1 ||
|
||||
leftSelector.indexOf(rightSelector) > -1
|
||||
)
|
||||
delete candidates[body];
|
||||
}
|
||||
}
|
||||
|
||||
function mergeNonAdjacentByBody(tokens, context) {
|
||||
var options = context.options;
|
||||
var mergeSemantically = options.level[OptimizationLevel.Two].mergeSemantically;
|
||||
var mergeSemantically =
|
||||
options.level[OptimizationLevel.Two].mergeSemantically;
|
||||
var adjacentSpace = options.compatibility.selectors.adjacentSpace;
|
||||
var selectorsSortingMethod = options.level[OptimizationLevel.One].selectorsSortingMethod;
|
||||
var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses;
|
||||
var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements;
|
||||
var multiplePseudoMerging = options.compatibility.selectors.multiplePseudoMerging;
|
||||
var selectorsSortingMethod =
|
||||
options.level[OptimizationLevel.One].selectorsSortingMethod;
|
||||
var mergeablePseudoClasses =
|
||||
options.compatibility.selectors.mergeablePseudoClasses;
|
||||
var mergeablePseudoElements =
|
||||
options.compatibility.selectors.mergeablePseudoElements;
|
||||
var multiplePseudoMerging =
|
||||
options.compatibility.selectors.multiplePseudoMerging;
|
||||
var candidates = {};
|
||||
|
||||
for (var i = tokens.length - 1; i >= 0; i--) {
|
||||
var token = tokens[i];
|
||||
if (token[0] != Token.RULE)
|
||||
continue;
|
||||
if (token[0] != Token.RULE) continue;
|
||||
|
||||
if (token[2].length > 0 && (!mergeSemantically && unsafeSelector(serializeRules(token[1]))))
|
||||
if (
|
||||
token[2].length > 0 &&
|
||||
!mergeSemantically &&
|
||||
unsafeSelector(serializeRules(token[1]))
|
||||
)
|
||||
candidates = {};
|
||||
|
||||
if (token[2].length > 0 && mergeSemantically && isBemElement(token))
|
||||
@ -58,13 +70,33 @@ function mergeNonAdjacentByBody(tokens, context) {
|
||||
|
||||
var candidateBody = serializeBody(token[2]);
|
||||
var oldToken = candidates[candidateBody];
|
||||
if (oldToken &&
|
||||
isMergeable(serializeRules(token[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) &&
|
||||
isMergeable(serializeRules(oldToken[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging)) {
|
||||
|
||||
if (
|
||||
oldToken &&
|
||||
isMergeable(
|
||||
serializeRules(token[1]),
|
||||
mergeablePseudoClasses,
|
||||
mergeablePseudoElements,
|
||||
multiplePseudoMerging
|
||||
) &&
|
||||
isMergeable(
|
||||
serializeRules(oldToken[1]),
|
||||
mergeablePseudoClasses,
|
||||
mergeablePseudoElements,
|
||||
multiplePseudoMerging
|
||||
)
|
||||
) {
|
||||
if (token[2].length > 0) {
|
||||
token[1] = tidyRules(oldToken[1].concat(token[1]), false, adjacentSpace, false, context.warnings);
|
||||
token[1] = token[1].length > 1 ? sortSelectors(token[1], selectorsSortingMethod) : token[1];
|
||||
token[1] = tidyRules(
|
||||
oldToken[1].concat(token[1]),
|
||||
false,
|
||||
adjacentSpace,
|
||||
false,
|
||||
context.warnings
|
||||
);
|
||||
token[1] =
|
||||
token[1].length > 1 ?
|
||||
sortSelectors(token[1], selectorsSortingMethod)
|
||||
: token[1];
|
||||
} else {
|
||||
token[1] = oldToken[1].concat(token[1]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user