mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 20:30:04 +02:00
update packages to latest version
This commit is contained in:
31
node_modules/clean-css/lib/optimizer/level-2/extract-properties.js
generated
vendored
31
node_modules/clean-css/lib/optimizer/level-2/extract-properties.js
generated
vendored
@@ -15,17 +15,15 @@ function extractProperties(token) {
|
||||
var i, l;
|
||||
|
||||
if (token[0] == Token.RULE) {
|
||||
inSpecificSelector = !/[\.\+>~]/.test(serializeRules(token[1]));
|
||||
inSpecificSelector = !/[.+>~]/.test(serializeRules(token[1]));
|
||||
|
||||
for (i = 0, l = token[2].length; i < l; i++) {
|
||||
property = token[2][i];
|
||||
|
||||
if (property[0] != Token.PROPERTY)
|
||||
continue;
|
||||
if (property[0] != Token.PROPERTY) { continue; }
|
||||
|
||||
name = property[1][1];
|
||||
if (name.length === 0)
|
||||
continue;
|
||||
if (name.length === 0) { continue; }
|
||||
|
||||
value = serializeValue(property, i);
|
||||
|
||||
@@ -49,22 +47,15 @@ function extractProperties(token) {
|
||||
}
|
||||
|
||||
function findNameRoot(name) {
|
||||
if (name == 'list-style')
|
||||
return name;
|
||||
if (name.indexOf('-radius') > 0)
|
||||
return 'border-radius';
|
||||
if (name == 'border-collapse' || name == 'border-spacing' || name == 'border-image')
|
||||
return name;
|
||||
if (name.indexOf('border-') === 0 && /^border\-\w+\-\w+$/.test(name))
|
||||
return name.match(/border\-\w+/)[0];
|
||||
if (name.indexOf('border-') === 0 && /^border\-\w+$/.test(name))
|
||||
return 'border';
|
||||
if (name.indexOf('text-') === 0)
|
||||
return name;
|
||||
if (name == '-chrome-')
|
||||
return name;
|
||||
if (name == 'list-style') { return name; }
|
||||
if (name.indexOf('-radius') > 0) { return 'border-radius'; }
|
||||
if (name == 'border-collapse' || name == 'border-spacing' || name == 'border-image') { return name; }
|
||||
if (name.indexOf('border-') === 0 && /^border-\w+-\w+$/.test(name)) { return name.match(/border-\w+/)[0]; }
|
||||
if (name.indexOf('border-') === 0 && /^border-\w+$/.test(name)) { return 'border'; }
|
||||
if (name.indexOf('text-') === 0) { return name; }
|
||||
if (name == '-chrome-') { return name; }
|
||||
|
||||
return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
|
||||
return name.replace(/^-\w+-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
|
||||
}
|
||||
|
||||
module.exports = extractProperties;
|
||||
|
49
node_modules/clean-css/lib/optimizer/level-2/is-mergeable.js
generated
vendored
49
node_modules/clean-css/lib/optimizer/level-2/is-mergeable.js
generated
vendored
@@ -15,7 +15,7 @@ var PSEUDO_CLASSES_WITH_ARGUMENTS = [
|
||||
':nth-last-of-type',
|
||||
':nth-of-type'
|
||||
];
|
||||
var RELATION_PATTERN = /[>\+~]/;
|
||||
var RELATION_PATTERN = /[>+~]/;
|
||||
var UNMIXABLE_PSEUDO_CLASSES = [
|
||||
':after',
|
||||
':before',
|
||||
@@ -44,10 +44,17 @@ function isMergeable(selector, mergeablePseudoClasses, mergeablePseudoElements,
|
||||
for (i = 0, l = singleSelectors.length; i < l; i++) {
|
||||
singleSelector = singleSelectors[i];
|
||||
|
||||
if (singleSelector.length === 0 ||
|
||||
isDeepSelector(singleSelector) ||
|
||||
isVendorPrefixed(singleSelector) ||
|
||||
(singleSelector.indexOf(Marker.COLON) > -1 && !areMergeable(singleSelector, extractPseudoFrom(singleSelector), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging))) {
|
||||
if (singleSelector.length === 0
|
||||
|| isDeepSelector(singleSelector)
|
||||
|| isVendorPrefixed(singleSelector)
|
||||
|| (singleSelector.indexOf(Marker.COLON) > -1
|
||||
&& !areMergeable(
|
||||
singleSelector,
|
||||
extractPseudoFrom(singleSelector),
|
||||
mergeablePseudoClasses,
|
||||
mergeablePseudoElements,
|
||||
multiplePseudoMerging
|
||||
))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -143,10 +150,10 @@ function extractPseudoFrom(selector) {
|
||||
}
|
||||
|
||||
function areMergeable(selector, matches, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) {
|
||||
return areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements) &&
|
||||
needArguments(matches) &&
|
||||
(matches.length < 2 || !someIncorrectlyChained(selector, matches)) &&
|
||||
(matches.length < 2 || multiplePseudoMerging && allMixable(matches));
|
||||
return areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements)
|
||||
&& needArguments(matches)
|
||||
&& (matches.length < 2 || !someIncorrectlyChained(selector, matches))
|
||||
&& (matches.length < 2 || multiplePseudoMerging && allMixable(matches));
|
||||
}
|
||||
|
||||
function areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements) {
|
||||
@@ -156,9 +163,9 @@ function areAllowed(matches, mergeablePseudoClasses, mergeablePseudoElements) {
|
||||
|
||||
for (i = 0, l = matches.length; i < l; i++) {
|
||||
match = matches[i];
|
||||
name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 ?
|
||||
match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET)) :
|
||||
match;
|
||||
name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1
|
||||
? match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET))
|
||||
: match;
|
||||
|
||||
if (mergeablePseudoClasses.indexOf(name) === -1 && mergeablePseudoElements.indexOf(name) === -1) {
|
||||
return false;
|
||||
@@ -180,9 +187,9 @@ function needArguments(matches) {
|
||||
|
||||
bracketOpensAt = match.indexOf(Marker.OPEN_ROUND_BRACKET);
|
||||
hasArguments = bracketOpensAt > -1;
|
||||
name = hasArguments ?
|
||||
match.substring(0, bracketOpensAt) :
|
||||
match;
|
||||
name = hasArguments
|
||||
? match.substring(0, bracketOpensAt)
|
||||
: match;
|
||||
|
||||
if (hasArguments && PSEUDO_CLASSES_WITH_ARGUMENTS.indexOf(name) == -1) {
|
||||
return false;
|
||||
@@ -221,12 +228,12 @@ function someIncorrectlyChained(selector, matches) {
|
||||
areChained = matchAt + match.length == nextMatchAt;
|
||||
|
||||
if (areChained) {
|
||||
name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 ?
|
||||
match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET)) :
|
||||
match;
|
||||
nextName = nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET) > -1 ?
|
||||
nextMatch.substring(0, nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET)) :
|
||||
nextMatch;
|
||||
name = match.indexOf(Marker.OPEN_ROUND_BRACKET) > -1
|
||||
? match.substring(0, match.indexOf(Marker.OPEN_ROUND_BRACKET))
|
||||
: match;
|
||||
nextName = nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET) > -1
|
||||
? nextMatch.substring(0, nextMatch.indexOf(Marker.OPEN_ROUND_BRACKET))
|
||||
: nextMatch;
|
||||
|
||||
if (name != NOT_PSEUDO || nextName != NOT_PSEUDO) {
|
||||
return true;
|
||||
|
13
node_modules/clean-css/lib/optimizer/level-2/merge-adjacent.js
generated
vendored
13
node_modules/clean-css/lib/optimizer/level-2/merge-adjacent.js
generated
vendored
@@ -34,10 +34,15 @@ function mergeAdjacent(tokens, context) {
|
||||
Array.prototype.push.apply(lastToken[2], token[2]);
|
||||
optimizeProperties(lastToken[2], true, true, context);
|
||||
token[2] = [];
|
||||
} else if (lastToken[0] == Token.RULE && serializeBody(token[2]) == serializeBody(lastToken[2]) &&
|
||||
isMergeable(serializeRules(token[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) &&
|
||||
isMergeable(serializeRules(lastToken[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) &&
|
||||
lastToken[1].length < mergeLimit) {
|
||||
} else if (lastToken[0] == Token.RULE && serializeBody(token[2]) == serializeBody(lastToken[2])
|
||||
&& isMergeable(serializeRules(token[1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging)
|
||||
&& isMergeable(
|
||||
serializeRules(lastToken[1]),
|
||||
mergeablePseudoClasses,
|
||||
mergeablePseudoElements,
|
||||
multiplePseudoMerging
|
||||
)
|
||||
&& lastToken[1].length < mergeLimit) {
|
||||
lastToken[1] = tidyRules(lastToken[1].concat(token[1]), false, adjacentSpace, false, context.warnings);
|
||||
lastToken[1] = lastToken.length > 1 ? sortSelectors(lastToken[1], selectorsSortingMethod) : lastToken[1];
|
||||
token[2] = [];
|
||||
|
16
node_modules/clean-css/lib/optimizer/level-2/merge-media-queries.js
generated
vendored
16
node_modules/clean-css/lib/optimizer/level-2/merge-media-queries.js
generated
vendored
@@ -53,17 +53,18 @@ function mergeMediaQueries(tokens, context) {
|
||||
var traversedProperties = extractProperties(tokens[from]);
|
||||
from += delta;
|
||||
|
||||
if (mergeSemantically && allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties, specificityCache)) {
|
||||
if (mergeSemantically
|
||||
&& allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties, specificityCache)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!canReorder(movedProperties, traversedProperties, specificityCache))
|
||||
continue directionLoop;
|
||||
if (!canReorder(movedProperties, traversedProperties, specificityCache)) { continue directionLoop; }
|
||||
}
|
||||
|
||||
target[2] = topToBottom ?
|
||||
source[2].concat(target[2]) :
|
||||
target[2].concat(source[2]);
|
||||
target[2] = topToBottom
|
||||
? source[2].concat(target[2])
|
||||
: target[2].concat(source[2]);
|
||||
source[2] = [];
|
||||
|
||||
reduced.push(target);
|
||||
@@ -91,7 +92,8 @@ function allSameRulePropertiesCanBeReordered(movedProperties, traversedPropertie
|
||||
traversedProperty = traversedProperties[j];
|
||||
traversedRule = traversedProperty[5];
|
||||
|
||||
if (rulesOverlap(movedRule, traversedRule, true) && !canReorderSingle(movedProperty, traversedProperty, specificityCache)) {
|
||||
if (rulesOverlap(movedRule, traversedRule, true)
|
||||
&& !canReorderSingle(movedProperty, traversedProperty, specificityCache)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
32
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js
generated
vendored
32
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-body.js
generated
vendored
@@ -20,7 +20,7 @@ function isBemElement(token) {
|
||||
}
|
||||
|
||||
function withoutModifier(selector) {
|
||||
return selector.replace(/--[^ ,>\+~:]+/g, '');
|
||||
return selector.replace(/--[^ ,>+~:]+/g, '');
|
||||
}
|
||||
|
||||
function removeAnyUnsafeElements(left, candidates) {
|
||||
@@ -30,8 +30,9 @@ 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,21 +48,28 @@ function mergeNonAdjacentByBody(tokens, context) {
|
||||
|
||||
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]))))
|
||||
candidates = {};
|
||||
if (token[2].length > 0 && (!mergeSemantically && unsafeSelector(serializeRules(token[1])))) { candidates = {}; }
|
||||
|
||||
if (token[2].length > 0 && mergeSemantically && isBemElement(token))
|
||||
removeAnyUnsafeElements(token, candidates);
|
||||
if (token[2].length > 0 && mergeSemantically && isBemElement(token)) { removeAnyUnsafeElements(token, candidates); }
|
||||
|
||||
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];
|
||||
|
21
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-selector.js
generated
vendored
21
node_modules/clean-css/lib/optimizer/level-2/merge-non-adjacent-by-selector.js
generated
vendored
@@ -14,16 +14,13 @@ function mergeNonAdjacentBySelector(tokens, context) {
|
||||
var i;
|
||||
|
||||
for (i = tokens.length - 1; i >= 0; i--) {
|
||||
if (tokens[i][0] != Token.RULE)
|
||||
continue;
|
||||
if (tokens[i][2].length === 0)
|
||||
continue;
|
||||
if (tokens[i][0] != Token.RULE) { continue; }
|
||||
if (tokens[i][2].length === 0) { continue; }
|
||||
|
||||
var selector = serializeRules(tokens[i][1]);
|
||||
allSelectors[selector] = [i].concat(allSelectors[selector] || []);
|
||||
|
||||
if (allSelectors[selector].length == 2)
|
||||
repeatedSelectors.push(selector);
|
||||
if (allSelectors[selector].length == 2) { repeatedSelectors.push(selector); }
|
||||
}
|
||||
|
||||
for (i = repeatedSelectors.length - 1; i >= 0; i--) {
|
||||
@@ -51,14 +48,12 @@ function mergeNonAdjacentBySelector(tokens, context) {
|
||||
from += delta;
|
||||
|
||||
// traversed then moved as we move selectors towards the start
|
||||
var reorderable = topToBottom ?
|
||||
canReorder(movedProperties, traversedProperties, specificityCache) :
|
||||
canReorder(traversedProperties, movedProperties, specificityCache);
|
||||
var reorderable = topToBottom
|
||||
? canReorder(movedProperties, traversedProperties, specificityCache)
|
||||
: canReorder(traversedProperties, movedProperties, specificityCache);
|
||||
|
||||
if (!reorderable && !topToBottom)
|
||||
continue selectorIterator;
|
||||
if (!reorderable && topToBottom)
|
||||
continue directionIterator;
|
||||
if (!reorderable && !topToBottom) { continue selectorIterator; }
|
||||
if (!reorderable && topToBottom) { continue directionIterator; }
|
||||
}
|
||||
|
||||
if (topToBottom) {
|
||||
|
34
node_modules/clean-css/lib/optimizer/level-2/optimize.js
generated
vendored
34
node_modules/clean-css/lib/optimizer/level-2/optimize.js
generated
vendored
@@ -21,18 +21,18 @@ function removeEmpty(tokens) {
|
||||
var isEmpty = false;
|
||||
|
||||
switch (token[0]) {
|
||||
case Token.RULE:
|
||||
isEmpty = token[1].length === 0 || token[2].length === 0;
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
removeEmpty(token[2]);
|
||||
isEmpty = token[2].length === 0;
|
||||
break;
|
||||
case Token.AT_RULE:
|
||||
isEmpty = token[1].length === 0;
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
isEmpty = token[2].length === 0;
|
||||
case Token.RULE:
|
||||
isEmpty = token[1].length === 0 || token[2].length === 0;
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
removeEmpty(token[2]);
|
||||
isEmpty = token[2].length === 0;
|
||||
break;
|
||||
case Token.AT_RULE:
|
||||
isEmpty = token[1].length === 0;
|
||||
break;
|
||||
case Token.AT_RULE_BLOCK:
|
||||
isEmpty = token[2].length === 0;
|
||||
}
|
||||
|
||||
if (isEmpty) {
|
||||
@@ -59,11 +59,11 @@ function recursivelyOptimizeProperties(tokens, context) {
|
||||
var token = tokens[i];
|
||||
|
||||
switch (token[0]) {
|
||||
case Token.RULE:
|
||||
optimizeProperties(token[2], true, true, context);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
recursivelyOptimizeProperties(token[2], context);
|
||||
case Token.RULE:
|
||||
optimizeProperties(token[2], true, true, context);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
recursivelyOptimizeProperties(token[2], context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js
generated
vendored
4
node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js
generated
vendored
@@ -7,7 +7,7 @@ function findComponentIn(shorthand, longhand) {
|
||||
}
|
||||
|
||||
function nameComparator(to) {
|
||||
return function (property) {
|
||||
return function(property) {
|
||||
return to.name === property.name;
|
||||
};
|
||||
}
|
||||
@@ -33,8 +33,6 @@ function findInSubComponents(shorthand, comparator) {
|
||||
return longhandMatch;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
module.exports = findComponentIn;
|
||||
|
3
node_modules/clean-css/lib/optimizer/level-2/properties/has-inherit.js
generated
vendored
3
node_modules/clean-css/lib/optimizer/level-2/properties/has-inherit.js
generated
vendored
@@ -1,7 +1,6 @@
|
||||
function hasInherit(property) {
|
||||
for (var i = property.value.length - 1; i >= 0; i--) {
|
||||
if (property.value[i][1] == 'inherit')
|
||||
return true;
|
||||
if (property.value[i][1] == 'inherit') { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
|
3
node_modules/clean-css/lib/optimizer/level-2/properties/has-unset.js
generated
vendored
3
node_modules/clean-css/lib/optimizer/level-2/properties/has-unset.js
generated
vendored
@@ -1,7 +1,6 @@
|
||||
function hasUnset(property) {
|
||||
for (var i = property.value.length - 1; i >= 0; i--) {
|
||||
if (property.value[i][1] == 'unset')
|
||||
return true;
|
||||
if (property.value[i][1] == 'unset') { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
|
6
node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js
generated
vendored
6
node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js
generated
vendored
@@ -1,8 +1,8 @@
|
||||
var configuration = require('../../configuration');
|
||||
|
||||
function isComponentOf(property1, property2, shallow) {
|
||||
return isDirectComponentOf(property1, property2) ||
|
||||
!shallow && !!configuration[property1.name].shorthandComponents && isSubComponentOf(property1, property2);
|
||||
return isDirectComponentOf(property1, property2)
|
||||
|| !shallow && !!configuration[property1.name].shorthandComponents && isSubComponentOf(property1, property2);
|
||||
}
|
||||
|
||||
function isDirectComponentOf(property1, property2) {
|
||||
@@ -14,7 +14,7 @@ function isDirectComponentOf(property1, property2) {
|
||||
function isSubComponentOf(property1, property2) {
|
||||
return property1
|
||||
.components
|
||||
.some(function (component) {
|
||||
.some(function(component) {
|
||||
return isDirectComponentOf(component, property2);
|
||||
});
|
||||
}
|
||||
|
11
node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js
generated
vendored
11
node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js
generated
vendored
@@ -336,9 +336,8 @@ function inferComponentValue(components, propertyName) {
|
||||
|
||||
if ('oppositeTo' in descriptor) {
|
||||
return components[descriptor.oppositeTo].value;
|
||||
} else {
|
||||
return [[Token.PROPERTY_VALUE, descriptor.defaultValue]];
|
||||
}
|
||||
return [[Token.PROPERTY_VALUE, descriptor.defaultValue]];
|
||||
}
|
||||
|
||||
function joinMetadata(components, at) {
|
||||
@@ -367,11 +366,10 @@ function metadataSorter(metadata1, metadata2) {
|
||||
|
||||
if (line1 < line2) {
|
||||
return -1;
|
||||
} else if (line1 === line2) {
|
||||
} if (line1 === line2) {
|
||||
return column1 < column2 ? -1 : 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function buildSequenceWithInheritShorthand(components, shorthandName, validator) {
|
||||
@@ -481,9 +479,8 @@ function inferInsertAtFrom(properties, candidateComponents, shorthandName) {
|
||||
|
||||
if (shorthandName == 'border' && traversesVia(properties.slice(firstCandidatePosition, lastCandidatePosition), 'border-image')) {
|
||||
return firstCandidatePosition;
|
||||
} else {
|
||||
return lastCandidatePosition;
|
||||
}
|
||||
return lastCandidatePosition;
|
||||
}
|
||||
|
||||
function traversesVia(properties, propertyName) {
|
||||
|
154
node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js
generated
vendored
154
node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js
generated
vendored
@@ -59,19 +59,20 @@ function overrideSimple(property, by) {
|
||||
}
|
||||
|
||||
function override(property, by) {
|
||||
if (by.multiplex)
|
||||
if (by.multiplex) {
|
||||
overrideByMultiplex(property, by);
|
||||
else if (property.multiplex)
|
||||
} else if (property.multiplex) {
|
||||
overrideIntoMultiplex(property, by);
|
||||
else
|
||||
} else {
|
||||
overrideSimple(property, by);
|
||||
}
|
||||
}
|
||||
|
||||
function overrideShorthand(property, by) {
|
||||
by.unused = true;
|
||||
|
||||
for (var i = 0, l = property.components.length; i < l; i++) {
|
||||
override(property.components[i], by.components[i], property.multiplex);
|
||||
override(property.components[i], by.components[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +102,9 @@ function turnShorthandValueIntoMultiplex(property, size) {
|
||||
function turnLonghandValueIntoMultiplex(property, size) {
|
||||
var descriptor = configuration[property.name];
|
||||
var withRealValue = descriptor.intoMultiplexMode == 'real';
|
||||
var withValue = descriptor.intoMultiplexMode == 'real' ?
|
||||
property.value.slice(0) :
|
||||
(descriptor.intoMultiplexMode == 'placeholder' ? descriptor.placeholderValue : descriptor.defaultValue);
|
||||
var withValue = descriptor.intoMultiplexMode == 'real'
|
||||
? property.value.slice(0)
|
||||
: (descriptor.intoMultiplexMode == 'placeholder' ? descriptor.placeholderValue : descriptor.defaultValue);
|
||||
var i = multiplexSize(property);
|
||||
var j;
|
||||
var m = withValue.length;
|
||||
@@ -125,8 +126,7 @@ function multiplexSize(component) {
|
||||
var size = 0;
|
||||
|
||||
for (var i = 0, l = component.value.length; i < l; i++) {
|
||||
if (component.value[i][1] == Marker.COMMA)
|
||||
size++;
|
||||
if (component.value[i][1] == Marker.COMMA) { size++; }
|
||||
}
|
||||
|
||||
return size + 1;
|
||||
@@ -147,10 +147,8 @@ function moreSameShorthands(properties, startAt, name) {
|
||||
var count = 0;
|
||||
|
||||
for (var i = startAt; i >= 0; i--) {
|
||||
if (properties[i].name == name && !properties[i].unused)
|
||||
count++;
|
||||
if (count > 1)
|
||||
break;
|
||||
if (properties[i].name == name && !properties[i].unused) { count++; }
|
||||
if (count > 1) { break; }
|
||||
}
|
||||
|
||||
return count > 1;
|
||||
@@ -158,9 +156,8 @@ function moreSameShorthands(properties, startAt, name) {
|
||||
|
||||
function overridingFunction(shorthand, validator) {
|
||||
for (var i = 0, l = shorthand.components.length; i < l; i++) {
|
||||
if (!anyValue(validator.isUrl, shorthand.components[i]) && anyValue(validator.isFunction, shorthand.components[i])) {
|
||||
return true;
|
||||
}
|
||||
if (!anyValue(validator.isUrl, shorthand.components[i])
|
||||
&& anyValue(validator.isFunction, shorthand.components[i])) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -168,19 +165,16 @@ function overridingFunction(shorthand, validator) {
|
||||
|
||||
function anyValue(fn, property) {
|
||||
for (var i = 0, l = property.value.length; i < l; i++) {
|
||||
if (property.value[i][1] == Marker.COMMA)
|
||||
continue;
|
||||
if (property.value[i][1] == Marker.COMMA) { continue; }
|
||||
|
||||
if (fn(property.value[i][1]))
|
||||
return true;
|
||||
if (fn(property.value[i][1])) { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function wouldResultInLongerValue(left, right) {
|
||||
if (!left.multiplex && !right.multiplex || left.multiplex && right.multiplex)
|
||||
return false;
|
||||
if (!left.multiplex && !right.multiplex || left.multiplex && right.multiplex) { return false; }
|
||||
|
||||
var multiplex = left.multiplex ? left : right;
|
||||
var simple = left.multiplex ? right : left;
|
||||
@@ -215,19 +209,18 @@ function isCompactable(property) {
|
||||
}
|
||||
|
||||
function noneOverrideHack(left, right) {
|
||||
return !left.multiplex &&
|
||||
(left.name == 'background' || left.name == 'background-image') &&
|
||||
right.multiplex &&
|
||||
(right.name == 'background' || right.name == 'background-image') &&
|
||||
anyLayerIsNone(right.value);
|
||||
return !left.multiplex
|
||||
&& (left.name == 'background' || left.name == 'background-image')
|
||||
&& right.multiplex
|
||||
&& (right.name == 'background' || right.name == 'background-image')
|
||||
&& anyLayerIsNone(right.value);
|
||||
}
|
||||
|
||||
function anyLayerIsNone(values) {
|
||||
var layers = intoLayers(values);
|
||||
|
||||
for (var i = 0, l = layers.length; i < l; i++) {
|
||||
if (layers[i].length == 1 && layers[i][0][1] == 'none')
|
||||
return true;
|
||||
if (layers[i].length == 1 && layers[i][0][1] == 'none') { return true; }
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -262,11 +255,9 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
for (i = properties.length - 1; i >= 0; i--) {
|
||||
right = properties[i];
|
||||
|
||||
if (!isCompactable(right))
|
||||
continue;
|
||||
if (!isCompactable(right)) { continue; }
|
||||
|
||||
if (right.block)
|
||||
continue;
|
||||
if (right.block) { continue; }
|
||||
|
||||
mayOverride = configuration[right.name].canOverride || sameValue;
|
||||
|
||||
@@ -274,43 +265,32 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
left = properties[j];
|
||||
|
||||
if (!isCompactable(left))
|
||||
continue;
|
||||
if (!isCompactable(left)) { continue; }
|
||||
|
||||
if (left.block)
|
||||
continue;
|
||||
if (left.block) { continue; }
|
||||
|
||||
if (left.dynamic || right.dynamic)
|
||||
continue;
|
||||
if (left.dynamic || right.dynamic) { continue; }
|
||||
|
||||
if (left.unused || right.unused)
|
||||
continue;
|
||||
if (left.unused || right.unused) { continue; }
|
||||
|
||||
if (left.hack && !right.hack && !right.important || !left.hack && !left.important && right.hack)
|
||||
continue;
|
||||
if (left.hack && !right.hack && !right.important || !left.hack && !left.important && right.hack) { continue; }
|
||||
|
||||
if (left.important == right.important && left.hack[0] != right.hack[0])
|
||||
continue;
|
||||
if (left.important == right.important && left.hack[0] != right.hack[0]) { continue; }
|
||||
|
||||
if (left.important == right.important && (left.hack[0] != right.hack[0] || (left.hack[1] && left.hack[1] != right.hack[1])))
|
||||
continue;
|
||||
if (left.important == right.important
|
||||
&& (left.hack[0] != right.hack[0] || (left.hack[1] && left.hack[1] != right.hack[1]))) { continue; }
|
||||
|
||||
if (hasInherit(right))
|
||||
continue;
|
||||
if (hasInherit(right)) { continue; }
|
||||
|
||||
if (noneOverrideHack(left, right))
|
||||
continue;
|
||||
if (noneOverrideHack(left, right)) { continue; }
|
||||
|
||||
if (right.shorthand && isComponentOf(right, left)) {
|
||||
// maybe `left` can be overridden by `right` which is a shorthand?
|
||||
if (!right.important && left.important)
|
||||
continue;
|
||||
if (!right.important && left.important) { continue; }
|
||||
|
||||
if (!sameVendorPrefixesIn([left], right.components))
|
||||
continue;
|
||||
if (!sameVendorPrefixesIn([left], right.components)) { continue; }
|
||||
|
||||
if (!anyValue(validator.isFunction, left) && overridingFunction(right, validator))
|
||||
continue;
|
||||
if (!anyValue(validator.isFunction, left) && overridingFunction(right, validator)) { continue; }
|
||||
|
||||
if (!isMergeableShorthand(right)) {
|
||||
left.unused = true;
|
||||
@@ -336,9 +316,9 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
continue;
|
||||
}
|
||||
|
||||
overriddenComponents = left.shorthand ?
|
||||
left.components:
|
||||
[left];
|
||||
overriddenComponents = left.shorthand
|
||||
? left.components
|
||||
: [left];
|
||||
|
||||
for (k = overriddenComponents.length - 1; k >= 0; k--) {
|
||||
overriddenComponent = overriddenComponents[k];
|
||||
@@ -353,8 +333,7 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
left.unused = true;
|
||||
} else if (withMerging && left.shorthand && !right.shorthand && isComponentOf(left, right, true)) {
|
||||
// maybe `right` can be pulled into `left` which is a shorthand?
|
||||
if (right.important && !left.important)
|
||||
continue;
|
||||
if (right.important && !left.important) { continue; }
|
||||
|
||||
if (!right.important && left.important) {
|
||||
right.unused = true;
|
||||
@@ -362,40 +341,30 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
}
|
||||
|
||||
// Pending more clever algorithm in #527
|
||||
if (moreSameShorthands(properties, i - 1, left.name))
|
||||
continue;
|
||||
if (moreSameShorthands(properties, i - 1, left.name)) { continue; }
|
||||
|
||||
if (overridingFunction(left, validator))
|
||||
continue;
|
||||
if (overridingFunction(left, validator)) { continue; }
|
||||
|
||||
if (!isMergeableShorthand(left))
|
||||
continue;
|
||||
if (!isMergeableShorthand(left)) { continue; }
|
||||
|
||||
if (hasUnset(left) || hasUnset(right))
|
||||
continue;
|
||||
if (hasUnset(left) || hasUnset(right)) { continue; }
|
||||
|
||||
component = findComponentIn(left, right);
|
||||
if (everyValuesPair(mayOverride.bind(null, validator), component, right)) {
|
||||
var disabledBackgroundMerging =
|
||||
!compatibility.properties.backgroundClipMerging && component.name.indexOf('background-clip') > -1 ||
|
||||
!compatibility.properties.backgroundOriginMerging && component.name.indexOf('background-origin') > -1 ||
|
||||
!compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1;
|
||||
var disabledBackgroundMerging = !compatibility.properties.backgroundClipMerging && component.name.indexOf('background-clip') > -1
|
||||
|| !compatibility.properties.backgroundOriginMerging && component.name.indexOf('background-origin') > -1
|
||||
|| !compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1;
|
||||
var nonMergeableValue = configuration[right.name].nonMergeableValue === right.value[0][1];
|
||||
|
||||
if (disabledBackgroundMerging || nonMergeableValue)
|
||||
continue;
|
||||
if (disabledBackgroundMerging || nonMergeableValue) { continue; }
|
||||
|
||||
if (!compatibility.properties.merging && wouldBreakCompatibility(left, validator))
|
||||
continue;
|
||||
if (!compatibility.properties.merging && wouldBreakCompatibility(left, validator)) { continue; }
|
||||
|
||||
if (component.value[0][1] != right.value[0][1] && (hasInherit(left) || hasInherit(right)))
|
||||
continue;
|
||||
if (component.value[0][1] != right.value[0][1] && (hasInherit(left) || hasInherit(right))) { continue; }
|
||||
|
||||
if (wouldResultInLongerValue(left, right))
|
||||
continue;
|
||||
if (wouldResultInLongerValue(left, right)) { continue; }
|
||||
|
||||
if (!left.multiplex && right.multiplex)
|
||||
turnIntoMultiplex(left, multiplexSize(right));
|
||||
if (!left.multiplex && right.multiplex) { turnIntoMultiplex(left, multiplexSize(right)); }
|
||||
|
||||
override(component, right);
|
||||
left.dirty = true;
|
||||
@@ -403,8 +372,7 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
} else if (withMerging && left.shorthand && right.shorthand && left.name == right.name) {
|
||||
// merge if all components can be merged
|
||||
|
||||
if (!left.multiplex && right.multiplex)
|
||||
continue;
|
||||
if (!left.multiplex && right.multiplex) { continue; }
|
||||
|
||||
if (!right.important && left.important) {
|
||||
right.unused = true;
|
||||
@@ -426,8 +394,9 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
var rightComponent = right.components[k];
|
||||
|
||||
mayOverride = configuration[leftComponent.name].canOverride || sameValue;
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), leftComponent, rightComponent))
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), leftComponent, rightComponent)) {
|
||||
continue propertyLoop;
|
||||
}
|
||||
}
|
||||
|
||||
overrideShorthand(left, right);
|
||||
@@ -435,13 +404,11 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
} else if (withMerging && left.shorthand && right.shorthand && isComponentOf(left, right)) {
|
||||
// border is a shorthand but any of its components is a shorthand too
|
||||
|
||||
if (!left.important && right.important)
|
||||
continue;
|
||||
if (!left.important && right.important) { continue; }
|
||||
|
||||
component = findComponentIn(left, right);
|
||||
mayOverride = configuration[right.name].canOverride || sameValue;
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), component, right))
|
||||
continue;
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), component, right)) { continue; }
|
||||
|
||||
if (left.important && !right.important) {
|
||||
right.unused = true;
|
||||
@@ -449,8 +416,7 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
}
|
||||
|
||||
var rightRestored = configuration[right.name].restore(right, configuration);
|
||||
if (rightRestored.length > 1)
|
||||
continue;
|
||||
if (rightRestored.length > 1) { continue; }
|
||||
|
||||
component = findComponentIn(left, right);
|
||||
override(component, right);
|
||||
@@ -465,7 +431,7 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
overridingComponent = right.components[k];
|
||||
mayOverride = configuration[overridingComponent.name].canOverride || sameValue;
|
||||
|
||||
overridable = overridable && everyValuesPair(mayOverride.bind(null, validator), overriddenComponent, overridingComponent);
|
||||
overridable = everyValuesPair(mayOverride.bind(null, validator), overriddenComponent, overridingComponent);
|
||||
}
|
||||
} else {
|
||||
mayOverride = configuration[right.name].canOverride || sameValue;
|
||||
|
@@ -1,9 +1,9 @@
|
||||
var configuration = require('../../configuration');
|
||||
|
||||
function overridesNonComponentShorthand(property1, property2) {
|
||||
return property1.name in configuration &&
|
||||
'overridesShorthands' in configuration[property1.name] &&
|
||||
configuration[property1.name].overridesShorthands.indexOf(property2.name) > -1;
|
||||
return property1.name in configuration
|
||||
&& 'overridesShorthands' in configuration[property1.name]
|
||||
&& configuration[property1.name].overridesShorthands.indexOf(property2.name) > -1;
|
||||
}
|
||||
|
||||
module.exports = overridesNonComponentShorthand;
|
||||
|
12
node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js
generated
vendored
12
node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js
generated
vendored
@@ -36,10 +36,11 @@ function populateComponents(properties, validator, warnings) {
|
||||
}
|
||||
}
|
||||
|
||||
if (property.components.length > 0)
|
||||
if (property.components.length > 0) {
|
||||
property.multiplex = property.components[0].multiplex;
|
||||
else
|
||||
} else {
|
||||
property.unused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +50,12 @@ function onlyValueIsVariable(property, validator) {
|
||||
}
|
||||
|
||||
function moreThanOneValueIsVariable(property, validator) {
|
||||
return property.value.length > 1 && property.value.filter(function (value) { return validator.isVariable(value[1]); }).length > 1;
|
||||
return property.value.length > 1
|
||||
&& property.value.filter(
|
||||
function(value) {
|
||||
return validator.isVariable(value[1]);
|
||||
}
|
||||
).length > 1;
|
||||
}
|
||||
|
||||
module.exports = populateComponents;
|
||||
|
42
node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js
generated
vendored
42
node_modules/clean-css/lib/optimizer/level-2/reduce-non-adjacent.js
generated
vendored
@@ -27,20 +27,17 @@ function reduceNonAdjacent(tokens, context) {
|
||||
}
|
||||
|
||||
var selectorAsString = serializeRules(token[1]);
|
||||
var isComplexAndNotSpecial = token[1].length > 1 &&
|
||||
isMergeable(selectorAsString, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging);
|
||||
var isComplexAndNotSpecial = token[1].length > 1
|
||||
&& isMergeable(selectorAsString, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging);
|
||||
var wrappedSelectors = wrappedSelectorsFrom(token[1]);
|
||||
var selectors = isComplexAndNotSpecial ?
|
||||
[selectorAsString].concat(wrappedSelectors) :
|
||||
[selectorAsString];
|
||||
var selectors = isComplexAndNotSpecial
|
||||
? [selectorAsString].concat(wrappedSelectors)
|
||||
: [selectorAsString];
|
||||
|
||||
for (var j = 0, m = selectors.length; j < m; j++) {
|
||||
var selector = selectors[j];
|
||||
|
||||
if (!candidates[selector])
|
||||
candidates[selector] = [];
|
||||
else
|
||||
repeated.push(selector);
|
||||
if (!candidates[selector]) { candidates[selector] = []; } else { repeated.push(selector); }
|
||||
|
||||
candidates[selector].push({
|
||||
where: i,
|
||||
@@ -71,8 +68,7 @@ function reduceSimpleNonAdjacentCases(tokens, repeated, candidates, options, con
|
||||
}
|
||||
|
||||
function reduceBody(token, newBody, processedCount, tokenIdx) {
|
||||
if (!data[processedCount - tokenIdx - 1].isPartial)
|
||||
token[2] = newBody;
|
||||
if (!data[processedCount - tokenIdx - 1].isPartial) { token[2] = newBody; }
|
||||
}
|
||||
|
||||
for (var i = 0, l = repeated.length; i < l; i++) {
|
||||
@@ -97,23 +93,21 @@ function reduceComplexNonAdjacentCases(tokens, candidates, options, context) {
|
||||
}
|
||||
|
||||
function collectReducedBodies(token, newBody, processedCount, tokenIdx) {
|
||||
if (tokenIdx === 0)
|
||||
localContext.reducedBodies.push(newBody);
|
||||
if (tokenIdx === 0) { localContext.reducedBodies.push(newBody); }
|
||||
}
|
||||
|
||||
allSelectors:
|
||||
for (var complexSelector in candidates) {
|
||||
var into = candidates[complexSelector];
|
||||
if (!into[0].isComplex)
|
||||
continue;
|
||||
if (!into[0].isComplex) { continue; }
|
||||
|
||||
var intoPosition = into[into.length - 1].where;
|
||||
var intoToken = tokens[intoPosition];
|
||||
var reducedBodies = [];
|
||||
|
||||
var selectors = isMergeable(complexSelector, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging) ?
|
||||
into[0].list :
|
||||
[complexSelector];
|
||||
var selectors = isMergeable(complexSelector, mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging)
|
||||
? into[0].list
|
||||
: [complexSelector];
|
||||
|
||||
localContext.intoPosition = intoPosition;
|
||||
localContext.reducedBodies = reducedBodies;
|
||||
@@ -122,8 +116,7 @@ function reduceComplexNonAdjacentCases(tokens, candidates, options, context) {
|
||||
var selector = selectors[j];
|
||||
var data = candidates[selector];
|
||||
|
||||
if (data.length < 2)
|
||||
continue allSelectors;
|
||||
if (data.length < 2) { continue allSelectors; }
|
||||
|
||||
localContext.data = data;
|
||||
|
||||
@@ -132,8 +125,9 @@ function reduceComplexNonAdjacentCases(tokens, candidates, options, context) {
|
||||
callback: collectReducedBodies
|
||||
}, options, context);
|
||||
|
||||
if (serializeBody(reducedBodies[reducedBodies.length - 1]) != serializeBody(reducedBodies[0]))
|
||||
if (serializeBody(reducedBodies[reducedBodies.length - 1]) != serializeBody(reducedBodies[0])) {
|
||||
continue allSelectors;
|
||||
}
|
||||
}
|
||||
|
||||
intoToken[2] = reducedBodies[0];
|
||||
@@ -146,8 +140,7 @@ function reduceSelector(tokens, data, context, options, outerContext) {
|
||||
var processedTokens = [];
|
||||
|
||||
for (var j = data.length - 1; j >= 0; j--) {
|
||||
if (context.filterOut(j, bodies))
|
||||
continue;
|
||||
if (context.filterOut(j, bodies)) { continue; }
|
||||
|
||||
var where = data[j].where;
|
||||
var token = tokens[where];
|
||||
@@ -165,7 +158,8 @@ function reduceSelector(tokens, data, context, options, outerContext) {
|
||||
var tokenIdx = processedCount - 1;
|
||||
|
||||
while (tokenIdx >= 0) {
|
||||
if ((tokenIdx === 0 || (bodies[propertyIdx] && bodiesAsList[tokenIdx].indexOf(bodies[propertyIdx]) > -1)) && propertyIdx > -1) {
|
||||
if ((tokenIdx === 0
|
||||
|| (bodies[propertyIdx] && bodiesAsList[tokenIdx].indexOf(bodies[propertyIdx]) > -1)) && propertyIdx > -1) {
|
||||
propertyIdx--;
|
||||
continue;
|
||||
}
|
||||
|
13
node_modules/clean-css/lib/optimizer/level-2/remove-duplicates.js
generated
vendored
13
node_modules/clean-css/lib/optimizer/level-2/remove-duplicates.js
generated
vendored
@@ -11,15 +11,11 @@ function removeDuplicates(tokens) {
|
||||
|
||||
for (var i = 0, l = tokens.length; i < l; i++) {
|
||||
token = tokens[i];
|
||||
if (token[0] != Token.RULE)
|
||||
continue;
|
||||
if (token[0] != Token.RULE) { continue; }
|
||||
|
||||
id = serializeRules(token[1]);
|
||||
|
||||
if (matched[id] && matched[id].length == 1)
|
||||
moreThanOnce.push(id);
|
||||
else
|
||||
matched[id] = matched[id] || [];
|
||||
if (matched[id] && matched[id].length == 1) { moreThanOnce.push(id); } else { matched[id] = matched[id] || []; }
|
||||
|
||||
matched[id].push(i);
|
||||
}
|
||||
@@ -32,10 +28,7 @@ function removeDuplicates(tokens) {
|
||||
token = tokens[matched[id][j]];
|
||||
body = serializeBody(token[2]);
|
||||
|
||||
if (bodies.indexOf(body) > -1)
|
||||
token[2] = [];
|
||||
else
|
||||
bodies.push(body);
|
||||
if (bodies.indexOf(body) > -1) { token[2] = []; } else { bodies.push(body); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
26
node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js
generated
vendored
26
node_modules/clean-css/lib/optimizer/level-2/remove-unused-at-rules.js
generated
vendored
@@ -5,9 +5,9 @@ var restoreFromOptimizing = require('../restore-from-optimizing');
|
||||
|
||||
var Token = require('../../tokenizer/token');
|
||||
|
||||
var animationNameRegex = /^(\-moz\-|\-o\-|\-webkit\-)?animation-name$/;
|
||||
var animationRegex = /^(\-moz\-|\-o\-|\-webkit\-)?animation$/;
|
||||
var keyframeRegex = /^@(\-moz\-|\-o\-|\-webkit\-)?keyframes /;
|
||||
var animationNameRegex = /^(-moz-|-o-|-webkit-)?animation-name$/;
|
||||
var animationRegex = /^(-moz-|-o-|-webkit-)?animation$/;
|
||||
var keyframeRegex = /^@(-moz-|-o-|-webkit-)?keyframes /;
|
||||
var importantRegex = /\s{0,31}!important$/;
|
||||
var optionalMatchingQuotesRegex = /^(['"]?)(.*)\1$/;
|
||||
|
||||
@@ -59,11 +59,11 @@ function markUsedAtRules(tokens, markCallback, atRules, context) {
|
||||
|
||||
for (i = 0, l = tokens.length; i < l; i++) {
|
||||
switch (tokens[i][0]) {
|
||||
case Token.RULE:
|
||||
boundMarkCallback(tokens[i], context);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
markUsedAtRules(tokens[i][2], markCallback, atRules, context);
|
||||
case Token.RULE:
|
||||
boundMarkCallback(tokens[i], context);
|
||||
break;
|
||||
case Token.NESTED_BLOCK:
|
||||
markUsedAtRules(tokens[i][2], markCallback, atRules, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ function matchCounterStyle(token, atRules) {
|
||||
}
|
||||
|
||||
function markCounterStylesAsUsed(atRules) {
|
||||
return function (token, context) {
|
||||
return function(token, context) {
|
||||
var property;
|
||||
var wrappedProperty;
|
||||
var i, l;
|
||||
@@ -125,7 +125,7 @@ function matchFontFace(token, atRules) {
|
||||
}
|
||||
|
||||
function markFontFacesAsUsed(atRules) {
|
||||
return function (token, context) {
|
||||
return function(token, context) {
|
||||
var property;
|
||||
var wrappedProperty;
|
||||
var component;
|
||||
@@ -176,7 +176,7 @@ function matchKeyframe(token, atRules) {
|
||||
}
|
||||
|
||||
function markKeyframesAsUsed(atRules) {
|
||||
return function (token, context) {
|
||||
return function(token, context) {
|
||||
var property;
|
||||
var wrappedProperty;
|
||||
var component;
|
||||
@@ -222,9 +222,9 @@ function matchNamespace(token, atRules) {
|
||||
}
|
||||
|
||||
function markNamespacesAsUsed(atRules) {
|
||||
var namespaceRegex = new RegExp(Object.keys(atRules).join('\\\||') + '\\\|', 'g');
|
||||
var namespaceRegex = new RegExp(Object.keys(atRules).join('\\||') + '\\|', 'g');
|
||||
|
||||
return function (token) {
|
||||
return function(token) {
|
||||
var match;
|
||||
var scope;
|
||||
var normalizedMatch;
|
||||
|
60
node_modules/clean-css/lib/optimizer/level-2/reorderable.js
generated
vendored
60
node_modules/clean-css/lib/optimizer/level-2/reorderable.js
generated
vendored
@@ -3,14 +3,13 @@
|
||||
var rulesOverlap = require('./rules-overlap');
|
||||
var specificitiesOverlap = require('./specificities-overlap');
|
||||
|
||||
var FLEX_PROPERTIES = /align\-items|box\-align|box\-pack|flex|justify/;
|
||||
var BORDER_PROPERTIES = /^border\-(top|right|bottom|left|color|style|width|radius)/;
|
||||
var FLEX_PROPERTIES = /align-items|box-align|box-pack|flex|justify/;
|
||||
var BORDER_PROPERTIES = /^border-(top|right|bottom|left|color|style|width|radius)/;
|
||||
|
||||
function canReorder(left, right, cache) {
|
||||
for (var i = right.length - 1; i >= 0; i--) {
|
||||
for (var j = left.length - 1; j >= 0; j--) {
|
||||
if (!canReorderSingle(left[j], right[i], cache))
|
||||
return false;
|
||||
if (!canReorderSingle(left[j], right[i], cache)) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,40 +28,41 @@ function canReorderSingle(left, right, cache) {
|
||||
var rightSelector = right[5];
|
||||
var rightInSpecificSelector = right[6];
|
||||
|
||||
if (leftName == 'font' && rightName == 'line-height' || rightName == 'font' && leftName == 'line-height')
|
||||
return false;
|
||||
if (FLEX_PROPERTIES.test(leftName) && FLEX_PROPERTIES.test(rightName))
|
||||
return false;
|
||||
if (leftNameRoot == rightNameRoot && unprefixed(leftName) == unprefixed(rightName) && (vendorPrefixed(leftName) ^ vendorPrefixed(rightName)))
|
||||
return false;
|
||||
if (leftNameRoot == 'border' && BORDER_PROPERTIES.test(rightNameRoot) && (leftName == 'border' || leftName == rightNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName))))
|
||||
return false;
|
||||
if (rightNameRoot == 'border' && BORDER_PROPERTIES.test(leftNameRoot) && (rightName == 'border' || rightName == leftNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName))))
|
||||
return false;
|
||||
if (leftNameRoot == 'border' && rightNameRoot == 'border' && leftName != rightName && (isSideBorder(leftName) && isStyleBorder(rightName) || isStyleBorder(leftName) && isSideBorder(rightName)))
|
||||
return false;
|
||||
if (leftNameRoot != rightNameRoot)
|
||||
return true;
|
||||
if (leftName == rightName && leftNameRoot == rightNameRoot && (leftValue == rightValue || withDifferentVendorPrefix(leftValue, rightValue)))
|
||||
return true;
|
||||
if (leftName != rightName && leftNameRoot == rightNameRoot && leftName != leftNameRoot && rightName != rightNameRoot)
|
||||
return true;
|
||||
if (leftName != rightName && leftNameRoot == rightNameRoot && leftValue == rightValue)
|
||||
return true;
|
||||
if (rightInSpecificSelector && leftInSpecificSelector && !inheritable(leftNameRoot) && !inheritable(rightNameRoot) && !rulesOverlap(rightSelector, leftSelector, false))
|
||||
return true;
|
||||
if (!specificitiesOverlap(leftSelector, rightSelector, cache))
|
||||
return true;
|
||||
if (leftName == 'font' && rightName == 'line-height' || rightName == 'font' && leftName == 'line-height') { return false; }
|
||||
if (FLEX_PROPERTIES.test(leftName) && FLEX_PROPERTIES.test(rightName)) { return false; }
|
||||
if (leftNameRoot == rightNameRoot
|
||||
&& unprefixed(leftName) == unprefixed(rightName)
|
||||
&& (vendorPrefixed(leftName) ^ vendorPrefixed(rightName))) { return false; }
|
||||
if (leftNameRoot == 'border' && BORDER_PROPERTIES.test(rightNameRoot) && (leftName == 'border' || leftName == rightNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName)))) { return false; }
|
||||
if (rightNameRoot == 'border' && BORDER_PROPERTIES.test(leftNameRoot) && (rightName == 'border' || rightName == leftNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName)))) { return false; }
|
||||
if (leftNameRoot == 'border' && rightNameRoot == 'border' && leftName != rightName && (isSideBorder(leftName) && isStyleBorder(rightName) || isStyleBorder(leftName) && isSideBorder(rightName))) { return false; }
|
||||
if (leftNameRoot != rightNameRoot) { return true; }
|
||||
if (leftName == rightName
|
||||
&& leftNameRoot == rightNameRoot
|
||||
&& (leftValue == rightValue || withDifferentVendorPrefix(leftValue, rightValue))) { return true; }
|
||||
if (leftName != rightName
|
||||
&& leftNameRoot == rightNameRoot
|
||||
&& leftName != leftNameRoot
|
||||
&& rightName != rightNameRoot) { return true; }
|
||||
if (leftName != rightName
|
||||
&& leftNameRoot == rightNameRoot
|
||||
&& leftValue == rightValue) { return true; }
|
||||
if (rightInSpecificSelector
|
||||
&& leftInSpecificSelector
|
||||
&& !inheritable(leftNameRoot)
|
||||
&& !inheritable(rightNameRoot)
|
||||
&& !rulesOverlap(rightSelector, leftSelector, false)) { return true; }
|
||||
if (!specificitiesOverlap(leftSelector, rightSelector, cache)) { return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function vendorPrefixed(name) {
|
||||
return /^\-(?:moz|webkit|ms|o)\-/.test(name);
|
||||
return /^-(?:moz|webkit|ms|o)-/.test(name);
|
||||
}
|
||||
|
||||
function unprefixed(name) {
|
||||
return name.replace(/^\-(?:moz|webkit|ms|o)\-/, '');
|
||||
return name.replace(/^-(?:moz|webkit|ms|o)-/, '');
|
||||
}
|
||||
|
||||
function sameBorderComponent(name1, name2) {
|
||||
|
3
node_modules/clean-css/lib/optimizer/level-2/restore-with-components.js
generated
vendored
3
node_modules/clean-css/lib/optimizer/level-2/restore-with-components.js
generated
vendored
@@ -5,9 +5,8 @@ function restoreWithComponents(property) {
|
||||
|
||||
if (descriptor && descriptor.shorthand) {
|
||||
return descriptor.restore(property, configuration);
|
||||
} else {
|
||||
return property.value;
|
||||
}
|
||||
return property.value;
|
||||
}
|
||||
|
||||
module.exports = restoreWithComponents;
|
||||
|
69
node_modules/clean-css/lib/optimizer/level-2/restructure.js
generated
vendored
69
node_modules/clean-css/lib/optimizer/level-2/restructure.js
generated
vendored
@@ -87,18 +87,25 @@ function restructure(tokens, context) {
|
||||
var mergeableTokens = [];
|
||||
|
||||
for (var i = sourceTokens.length - 1; i >= 0; i--) {
|
||||
if (!isMergeable(serializeRules(sourceTokens[i][1]), mergeablePseudoClasses, mergeablePseudoElements, multiplePseudoMerging)) {
|
||||
if (!isMergeable(
|
||||
serializeRules(sourceTokens[i][1]),
|
||||
mergeablePseudoClasses,
|
||||
mergeablePseudoElements,
|
||||
multiplePseudoMerging
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mergeableTokens.unshift(sourceTokens[i]);
|
||||
if (sourceTokens[i][2].length > 0 && uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1)
|
||||
if (sourceTokens[i][2].length > 0
|
||||
&& uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1) {
|
||||
uniqueTokensWithBody.push(sourceTokens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return uniqueTokensWithBody.length > 1 ?
|
||||
mergeableTokens :
|
||||
[];
|
||||
return uniqueTokensWithBody.length > 1
|
||||
? mergeableTokens
|
||||
: [];
|
||||
}
|
||||
|
||||
function shortenIfPossible(position, movedProperty) {
|
||||
@@ -110,15 +117,13 @@ function restructure(tokens, context) {
|
||||
var qualifiedTokens = [];
|
||||
|
||||
var mergeableTokens = tokensToMerge(movableTokens[key]);
|
||||
if (mergeableTokens.length < 2)
|
||||
return;
|
||||
if (mergeableTokens.length < 2) { return; }
|
||||
|
||||
var allFits = findAllFits(mergeableTokens, valueSize, 1);
|
||||
var bestFit = allFits[0];
|
||||
if (bestFit[1] > 0)
|
||||
return sendToMultiPropertyMoveCache(position, movedProperty, allFits);
|
||||
if (bestFit[1] > 0) { return sendToMultiPropertyMoveCache(position, movedProperty, allFits); }
|
||||
|
||||
for (var i = bestFit[0].length - 1; i >=0; i--) {
|
||||
for (var i = bestFit[0].length - 1; i >= 0; i--) {
|
||||
allSelectors = bestFit[0][i][1].concat(allSelectors);
|
||||
qualifiedTokens.unshift(bestFit[0][i]);
|
||||
}
|
||||
@@ -142,7 +147,9 @@ function restructure(tokens, context) {
|
||||
for (var i = tokensVariant.length - 1; i >= 0; i--) {
|
||||
var subVariant = Array.prototype.slice.call(tokensVariant, 0);
|
||||
subVariant.splice(i, 1);
|
||||
differenceVariants = differenceVariants.concat(allCombinations(subVariant, propertySize, propertiesCount, level - 1));
|
||||
differenceVariants = differenceVariants.concat(
|
||||
allCombinations(subVariant, propertySize, propertiesCount, level - 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +159,9 @@ function restructure(tokens, context) {
|
||||
function sizeDifference(tokensVariant, propertySize, propertiesCount) {
|
||||
var allSelectorsSize = 0;
|
||||
for (var i = tokensVariant.length - 1; i >= 0; i--) {
|
||||
allSelectorsSize += tokensVariant[i][2].length > propertiesCount ? serializeRules(tokensVariant[i][1]).length : -1;
|
||||
allSelectorsSize += tokensVariant[i][2].length > propertiesCount
|
||||
? serializeRules(tokensVariant[i][1]).length
|
||||
: -1;
|
||||
}
|
||||
return allSelectorsSize - (tokensVariant.length - 1) * propertySize + 1;
|
||||
}
|
||||
@@ -194,8 +203,7 @@ function restructure(tokens, context) {
|
||||
var toMove = movableTokens[key];
|
||||
|
||||
if (toMove && toMove.length > 1) {
|
||||
if (!shortenMultiMovesIfPossible(position, movedProperty))
|
||||
shortenIfPossible(position, movedProperty);
|
||||
if (!shortenMultiMovesIfPossible(position, movedProperty)) { shortenIfPossible(position, movedProperty); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,23 +214,20 @@ function restructure(tokens, context) {
|
||||
var j, k;
|
||||
|
||||
var mergeableTokens = tokensToMerge(movableTokens[key]);
|
||||
if (mergeableTokens.length < 2)
|
||||
return;
|
||||
if (mergeableTokens.length < 2) { return; }
|
||||
|
||||
movableLoop:
|
||||
for (var value in movableTokens) {
|
||||
var tokensList = movableTokens[value];
|
||||
|
||||
for (j = mergeableTokens.length - 1; j >= 0; j--) {
|
||||
if (tokensList.indexOf(mergeableTokens[j]) == -1)
|
||||
continue movableLoop;
|
||||
if (tokensList.indexOf(mergeableTokens[j]) == -1) { continue movableLoop; }
|
||||
}
|
||||
|
||||
candidates.push(value);
|
||||
}
|
||||
|
||||
if (candidates.length < 2)
|
||||
return false;
|
||||
if (candidates.length < 2) { return false; }
|
||||
|
||||
for (j = candidates.length - 1; j >= 0; j--) {
|
||||
for (k = movedProperties.length - 1; k >= 0; k--) {
|
||||
@@ -251,8 +256,7 @@ function restructure(tokens, context) {
|
||||
|
||||
var mergeableTokens = propertiesAndMergableTokens[0][1];
|
||||
var bestFit = findAllFits(mergeableTokens, valueSize, properties.length)[0];
|
||||
if (bestFit[1] > 0)
|
||||
return false;
|
||||
if (bestFit[1] > 0) { return false; }
|
||||
|
||||
var allSelectors = [];
|
||||
var qualifiedTokens = [];
|
||||
@@ -270,8 +274,7 @@ function restructure(tokens, context) {
|
||||
|
||||
delete movableTokens[property[4]];
|
||||
|
||||
if (index > -1 && movedToBeDropped.indexOf(index) == -1)
|
||||
movedToBeDropped.push(index);
|
||||
if (index > -1 && movedToBeDropped.indexOf(index) == -1) { movedToBeDropped.push(index); }
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -280,8 +283,7 @@ function restructure(tokens, context) {
|
||||
function boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) {
|
||||
var propertyName = property[0];
|
||||
var movedPropertyName = movedProperty[0];
|
||||
if (propertyName != movedPropertyName)
|
||||
return false;
|
||||
if (propertyName != movedPropertyName) { return false; }
|
||||
|
||||
var key = movedProperty[4];
|
||||
var toMove = movableTokens[key];
|
||||
@@ -325,9 +327,12 @@ function restructure(tokens, context) {
|
||||
for (k = 0; k < movedCount; k++) {
|
||||
var movedProperty = movedProperties[k];
|
||||
|
||||
if (movedToBeDropped.indexOf(k) == -1 && (!canReorderSingle(property, movedProperty, specificityCache) && !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) ||
|
||||
movableTokens[movedProperty[4]] && movableTokens[movedProperty[4]].length === mergeLimit)) {
|
||||
dropPropertiesAt(i + 1, movedProperty, token);
|
||||
if (movedToBeDropped.indexOf(k) == -1 && (
|
||||
!canReorderSingle(property, movedProperty, specificityCache)
|
||||
&& !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token)
|
||||
|| movableTokens[movedProperty[4]] && movableTokens[movedProperty[4]].length === mergeLimit)
|
||||
) {
|
||||
dropPropertiesAt(i + 1, movedProperty);
|
||||
|
||||
if (movedToBeDropped.indexOf(k) == -1) {
|
||||
movedToBeDropped.push(k);
|
||||
@@ -344,8 +349,7 @@ function restructure(tokens, context) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isRule || unmovableInCurrentToken.indexOf(j) > -1)
|
||||
continue;
|
||||
if (!isRule || unmovableInCurrentToken.indexOf(j) > -1) { continue; }
|
||||
|
||||
var key = property[4];
|
||||
|
||||
@@ -377,8 +381,7 @@ function restructure(tokens, context) {
|
||||
for (; position < tokens.length - 1; position++) {
|
||||
var isImportRule = tokens[position][0] === Token.AT_RULE && tokens[position][1].indexOf('@import') === 0;
|
||||
var isComment = tokens[position][0] === Token.COMMENT;
|
||||
if (!(isImportRule || isComment))
|
||||
break;
|
||||
if (!(isImportRule || isComment)) { break; }
|
||||
}
|
||||
|
||||
for (i = 0; i < movedProperties.length; i++) {
|
||||
|
2
node_modules/clean-css/lib/optimizer/level-2/rules-overlap.js
generated
vendored
2
node_modules/clean-css/lib/optimizer/level-2/rules-overlap.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
var MODIFIER_PATTERN = /\-\-.+$/;
|
||||
var MODIFIER_PATTERN = /--.+$/;
|
||||
|
||||
function rulesOverlap(rule1, rule2, bemMode) {
|
||||
var scope1;
|
||||
|
4
node_modules/clean-css/lib/optimizer/level-2/specificities-overlap.js
generated
vendored
4
node_modules/clean-css/lib/optimizer/level-2/specificities-overlap.js
generated
vendored
@@ -12,7 +12,9 @@ function specificitiesOverlap(selector1, selector2, cache) {
|
||||
for (j = 0, m = selector2.length; j < m; j++) {
|
||||
specificity2 = findSpecificity(selector2[j][1], cache);
|
||||
|
||||
if (specificity1[0] === specificity2[0] && specificity1[1] === specificity2[1] && specificity1[2] === specificity2[2]) {
|
||||
if (specificity1[0] === specificity2[0]
|
||||
&& specificity1[1] === specificity2[1]
|
||||
&& specificity1[2] === specificity2[2]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
2
node_modules/clean-css/lib/optimizer/level-2/specificity.js
generated
vendored
2
node_modules/clean-css/lib/optimizer/level-2/specificity.js
generated
vendored
@@ -11,7 +11,7 @@ var Selector = {
|
||||
|
||||
var LETTER_PATTERN = /[a-zA-Z]/;
|
||||
var NOT_PREFIX = ':not(';
|
||||
var SEPARATOR_PATTERN = /[\s,\(>~\+]/;
|
||||
var SEPARATOR_PATTERN = /[\s,(>~+]/;
|
||||
|
||||
function specificity(selector) {
|
||||
var result = [0, 0, 0];
|
||||
|
Reference in New Issue
Block a user