format: prettify entire project
This commit is contained in:
5
node_modules/clean-css/lib/optimizer/level-2/properties/every-values-pair.js
generated
vendored
5
node_modules/clean-css/lib/optimizer/level-2/properties/every-values-pair.js
generated
vendored
@ -10,8 +10,9 @@ function everyValuesPair(fn, left, right) {
|
||||
var position;
|
||||
|
||||
for (position = 0; position < total; position++) {
|
||||
leftValue = left.value[position] && left.value[position][1] || leftValue;
|
||||
rightValue = right.value[position] && right.value[position][1] || rightValue;
|
||||
leftValue = (left.value[position] && left.value[position][1]) || leftValue;
|
||||
rightValue =
|
||||
(right.value[position] && right.value[position][1]) || rightValue;
|
||||
|
||||
if (leftValue == Marker.COMMA || rightValue == Marker.COMMA) {
|
||||
continue;
|
||||
|
5
node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js
generated
vendored
5
node_modules/clean-css/lib/optimizer/level-2/properties/find-component-in.js
generated
vendored
@ -3,7 +3,10 @@ var compactable = require('../compactable');
|
||||
function findComponentIn(shorthand, longhand) {
|
||||
var comparator = nameComparator(longhand);
|
||||
|
||||
return findInDirectComponents(shorthand, comparator) || findInSubComponents(shorthand, comparator);
|
||||
return (
|
||||
findInDirectComponents(shorthand, comparator) ||
|
||||
findInSubComponents(shorthand, comparator)
|
||||
);
|
||||
}
|
||||
|
||||
function nameComparator(to) {
|
||||
|
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;
|
||||
|
21
node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js
generated
vendored
21
node_modules/clean-css/lib/optimizer/level-2/properties/is-component-of.js
generated
vendored
@ -1,22 +1,27 @@
|
||||
var compactable = require('../compactable');
|
||||
|
||||
function isComponentOf(property1, property2, shallow) {
|
||||
return isDirectComponentOf(property1, property2) ||
|
||||
!shallow && !!compactable[property1.name].shorthandComponents && isSubComponentOf(property1, property2);
|
||||
return (
|
||||
isDirectComponentOf(property1, property2) ||
|
||||
(!shallow &&
|
||||
!!compactable[property1.name].shorthandComponents &&
|
||||
isSubComponentOf(property1, property2))
|
||||
);
|
||||
}
|
||||
|
||||
function isDirectComponentOf(property1, property2) {
|
||||
var descriptor = compactable[property1.name];
|
||||
|
||||
return 'components' in descriptor && descriptor.components.indexOf(property2.name) > -1;
|
||||
return (
|
||||
'components' in descriptor &&
|
||||
descriptor.components.indexOf(property2.name) > -1
|
||||
);
|
||||
}
|
||||
|
||||
function isSubComponentOf(property1, property2) {
|
||||
return property1
|
||||
.components
|
||||
.some(function (component) {
|
||||
return isDirectComponentOf(component, property2);
|
||||
});
|
||||
return property1.components.some(function (component) {
|
||||
return isDirectComponentOf(component, property2);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = isComponentOf;
|
||||
|
100
node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js
generated
vendored
100
node_modules/clean-css/lib/optimizer/level-2/properties/merge-into-shorthands.js
generated
vendored
@ -69,12 +69,18 @@ function invalidateOrCompact(properties, position, candidates, validator) {
|
||||
|
||||
shorthandDescriptor = compactable[shorthandName];
|
||||
candidateComponents = candidates[shorthandName];
|
||||
if (invalidatedBy && invalidates(candidates, shorthandName, invalidatedBy)) {
|
||||
if (
|
||||
invalidatedBy &&
|
||||
invalidates(candidates, shorthandName, invalidatedBy)
|
||||
) {
|
||||
delete candidates[shorthandName];
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shorthandDescriptor.components.length > Object.keys(candidateComponents).length) {
|
||||
if (
|
||||
shorthandDescriptor.components.length >
|
||||
Object.keys(candidateComponents).length
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -91,9 +97,19 @@ function invalidateOrCompact(properties, position, candidates, validator) {
|
||||
}
|
||||
|
||||
if (mixedInherit(candidateComponents)) {
|
||||
replaceWithInheritBestFit(properties, candidateComponents, shorthandName, validator);
|
||||
replaceWithInheritBestFit(
|
||||
properties,
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
);
|
||||
} else {
|
||||
replaceWithShorthand(properties, candidateComponents, shorthandName, validator);
|
||||
replaceWithShorthand(
|
||||
properties,
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +119,10 @@ function invalidates(candidates, shorthandName, invalidatedBy) {
|
||||
var invalidatedByDescriptor = compactable[invalidatedBy.name];
|
||||
var componentName;
|
||||
|
||||
if ('overridesShorthands' in shorthandDescriptor && shorthandDescriptor.overridesShorthands.indexOf(invalidatedBy.name) > -1) {
|
||||
if (
|
||||
'overridesShorthands' in shorthandDescriptor &&
|
||||
shorthandDescriptor.overridesShorthands.indexOf(invalidatedBy.name) > -1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -123,7 +142,10 @@ function mixedImportance(components) {
|
||||
var componentName;
|
||||
|
||||
for (componentName in components) {
|
||||
if (undefined !== important && components[componentName].important != important) {
|
||||
if (
|
||||
undefined !== important &&
|
||||
components[componentName].important != important
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,7 +160,7 @@ function overridable(components, shorthandName, validator) {
|
||||
var newValuePlaceholder = [
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, shorthandName],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue],
|
||||
];
|
||||
var newProperty = wrapSingle(newValuePlaceholder);
|
||||
var component;
|
||||
@ -151,7 +173,13 @@ function overridable(components, shorthandName, validator) {
|
||||
component = components[descriptor.components[i]];
|
||||
mayOverride = compactable[component.name].canOverride;
|
||||
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), newProperty.components[i], component)) {
|
||||
if (
|
||||
!everyValuesPair(
|
||||
mayOverride.bind(null, validator),
|
||||
newProperty.components[i],
|
||||
component
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -175,7 +203,10 @@ function mergeable(components) {
|
||||
continue;
|
||||
}
|
||||
|
||||
restoreFromOptimizing([component.all[component.position]], restoreWithComponents);
|
||||
restoreFromOptimizing(
|
||||
[component.all[component.position]],
|
||||
restoreWithComponents
|
||||
);
|
||||
values = descriptor.restore(component, compactable);
|
||||
|
||||
currentCount = values.length;
|
||||
@ -208,13 +239,29 @@ function mixedInherit(components) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function replaceWithInheritBestFit(properties, candidateComponents, shorthandName, validator) {
|
||||
var viaLonghands = buildSequenceWithInheritLonghands(candidateComponents, shorthandName, validator);
|
||||
var viaShorthand = buildSequenceWithInheritShorthand(candidateComponents, shorthandName, validator);
|
||||
function replaceWithInheritBestFit(
|
||||
properties,
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
) {
|
||||
var viaLonghands = buildSequenceWithInheritLonghands(
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
);
|
||||
var viaShorthand = buildSequenceWithInheritShorthand(
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
);
|
||||
var longhandTokensSequence = viaLonghands[0];
|
||||
var shorthandTokensSequence = viaShorthand[0];
|
||||
var isLonghandsShorter = serializeBody(longhandTokensSequence).length < serializeBody(shorthandTokensSequence).length;
|
||||
var newTokensSequence = isLonghandsShorter ? longhandTokensSequence : shorthandTokensSequence;
|
||||
var isLonghandsShorter =
|
||||
serializeBody(longhandTokensSequence).length <
|
||||
serializeBody(shorthandTokensSequence).length;
|
||||
var newTokensSequence =
|
||||
isLonghandsShorter ? longhandTokensSequence : shorthandTokensSequence;
|
||||
var newProperty = isLonghandsShorter ? viaLonghands[1] : viaShorthand[1];
|
||||
var newComponents = isLonghandsShorter ? viaLonghands[2] : viaShorthand[2];
|
||||
var all = candidateComponents[Object.keys(candidateComponents)[0]].all;
|
||||
@ -248,7 +295,11 @@ function replaceWithInheritBestFit(properties, candidateComponents, shorthandNam
|
||||
}
|
||||
}
|
||||
|
||||
function buildSequenceWithInheritLonghands(components, shorthandName, validator) {
|
||||
function buildSequenceWithInheritLonghands(
|
||||
components,
|
||||
shorthandName,
|
||||
validator
|
||||
) {
|
||||
var tokensSequence = [];
|
||||
var inheritComponents = {};
|
||||
var nonInheritComponents = {};
|
||||
@ -256,7 +307,7 @@ function buildSequenceWithInheritLonghands(components, shorthandName, validator)
|
||||
var shorthandToken = [
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, shorthandName],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue],
|
||||
];
|
||||
var newProperty = wrapSingle(shorthandToken);
|
||||
var component;
|
||||
@ -345,7 +396,11 @@ function metadataSorter(metadata1, metadata2) {
|
||||
}
|
||||
}
|
||||
|
||||
function buildSequenceWithInheritShorthand(components, shorthandName, validator) {
|
||||
function buildSequenceWithInheritShorthand(
|
||||
components,
|
||||
shorthandName,
|
||||
validator
|
||||
) {
|
||||
var tokensSequence = [];
|
||||
var inheritComponents = {};
|
||||
var nonInheritComponents = {};
|
||||
@ -353,7 +408,7 @@ function buildSequenceWithInheritShorthand(components, shorthandName, validator)
|
||||
var shorthandToken = [
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, shorthandName],
|
||||
[Token.PROPERTY_VALUE, 'inherit']
|
||||
[Token.PROPERTY_VALUE, 'inherit'],
|
||||
];
|
||||
var newProperty = wrapSingle(shorthandToken);
|
||||
var component;
|
||||
@ -399,14 +454,19 @@ function findTokenIn(tokens, componentName) {
|
||||
}
|
||||
}
|
||||
|
||||
function replaceWithShorthand(properties, candidateComponents, shorthandName, validator) {
|
||||
function replaceWithShorthand(
|
||||
properties,
|
||||
candidateComponents,
|
||||
shorthandName,
|
||||
validator
|
||||
) {
|
||||
var descriptor = compactable[shorthandName];
|
||||
var nameMetadata;
|
||||
var valueMetadata;
|
||||
var newValuePlaceholder = [
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, shorthandName],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue],
|
||||
];
|
||||
var all;
|
||||
|
||||
|
23
node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js
generated
vendored
23
node_modules/clean-css/lib/optimizer/level-2/properties/optimize.js
generated
vendored
@ -8,11 +8,16 @@ var wrapForOptimizing = require('../../wrap-for-optimizing').all;
|
||||
var removeUnused = require('../../remove-unused');
|
||||
var restoreFromOptimizing = require('../../restore-from-optimizing');
|
||||
|
||||
var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
|
||||
var OptimizationLevel =
|
||||
require('../../../options/optimization-level').OptimizationLevel;
|
||||
|
||||
function optimizeProperties(properties, withOverriding, withMerging, context) {
|
||||
var levelOptions = context.options.level[OptimizationLevel.Two];
|
||||
var _properties = wrapForOptimizing(properties, false, levelOptions.skipProperties);
|
||||
var _properties = wrapForOptimizing(
|
||||
properties,
|
||||
false,
|
||||
levelOptions.skipProperties
|
||||
);
|
||||
var _property;
|
||||
var i, l;
|
||||
|
||||
@ -21,7 +26,12 @@ function optimizeProperties(properties, withOverriding, withMerging, context) {
|
||||
for (i = 0, l = _properties.length; i < l; i++) {
|
||||
_property = _properties[i];
|
||||
if (_property.block) {
|
||||
optimizeProperties(_property.value[0][1], withOverriding, withMerging, context);
|
||||
optimizeProperties(
|
||||
_property.value[0][1],
|
||||
withOverriding,
|
||||
withMerging,
|
||||
context
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +40,12 @@ function optimizeProperties(properties, withOverriding, withMerging, context) {
|
||||
}
|
||||
|
||||
if (withOverriding && levelOptions.overrideProperties) {
|
||||
overrideProperties(_properties, withMerging, context.options.compatibility, context.validator);
|
||||
overrideProperties(
|
||||
_properties,
|
||||
withMerging,
|
||||
context.options.compatibility,
|
||||
context.validator
|
||||
);
|
||||
}
|
||||
|
||||
restoreFromOptimizing(_properties, restoreWithComponents);
|
||||
|
245
node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js
generated
vendored
245
node_modules/clean-css/lib/optimizer/level-2/properties/override-properties.js
generated
vendored
@ -22,12 +22,15 @@ function wouldBreakCompatibility(property, validator) {
|
||||
for (var i = 0; i < property.components.length; i++) {
|
||||
var component = property.components[i];
|
||||
var descriptor = compactable[component.name];
|
||||
var canOverride = descriptor && descriptor.canOverride || canOverride.sameValue;
|
||||
var canOverride =
|
||||
(descriptor && descriptor.canOverride) || canOverride.sameValue;
|
||||
|
||||
var _component = shallowClone(component);
|
||||
_component.value = [[Token.PROPERTY_VALUE, descriptor.defaultValue]];
|
||||
|
||||
if (!everyValuesPair(canOverride.bind(null, validator), _component, component)) {
|
||||
if (
|
||||
!everyValuesPair(canOverride.bind(null, validator), _component, component)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -54,12 +57,9 @@ function overrideSimple(property, by) {
|
||||
}
|
||||
|
||||
function override(property, by) {
|
||||
if (by.multiplex)
|
||||
overrideByMultiplex(property, by);
|
||||
else if (property.multiplex)
|
||||
overrideIntoMultiplex(property, by);
|
||||
else
|
||||
overrideSimple(property, by);
|
||||
if (by.multiplex) overrideByMultiplex(property, by);
|
||||
else if (property.multiplex) overrideIntoMultiplex(property, by);
|
||||
else overrideSimple(property, by);
|
||||
}
|
||||
|
||||
function overrideShorthand(property, by) {
|
||||
@ -96,9 +96,11 @@ function turnShorthandValueIntoMultiplex(property, size) {
|
||||
function turnLonghandValueIntoMultiplex(property, size) {
|
||||
var descriptor = compactable[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;
|
||||
@ -108,10 +110,14 @@ function turnLonghandValueIntoMultiplex(property, size) {
|
||||
|
||||
if (Array.isArray(withValue)) {
|
||||
for (j = 0; j < m; j++) {
|
||||
property.value.push(withRealValue ? withValue[j] : [Token.PROPERTY_VALUE, withValue[j]]);
|
||||
property.value.push(
|
||||
withRealValue ? withValue[j] : [Token.PROPERTY_VALUE, withValue[j]]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
property.value.push(withRealValue ? withValue : [Token.PROPERTY_VALUE, withValue]);
|
||||
property.value.push(
|
||||
withRealValue ? withValue : [Token.PROPERTY_VALUE, withValue]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,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;
|
||||
@ -130,7 +135,7 @@ function multiplexSize(component) {
|
||||
function lengthOf(property) {
|
||||
var fakeAsArray = [
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, property.name]
|
||||
[Token.PROPERTY_NAME, property.name],
|
||||
].concat(property.value);
|
||||
return serializeProperty([fakeAsArray], 0).length;
|
||||
}
|
||||
@ -142,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;
|
||||
@ -153,7 +156,10 @@ 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])) {
|
||||
if (
|
||||
!anyValue(validator.isUrl, shorthand.components[i]) &&
|
||||
anyValue(validator.isFunction, shorthand.components[i])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -163,18 +169,19 @@ 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)
|
||||
if (
|
||||
(!left.multiplex && !right.multiplex) ||
|
||||
(left.multiplex && right.multiplex)
|
||||
)
|
||||
return false;
|
||||
|
||||
var multiplex = left.multiplex ? left : right;
|
||||
@ -210,19 +217,20 @@ function isCompactable(property) {
|
||||
}
|
||||
|
||||
function noneOverrideHack(left, right) {
|
||||
return !left.multiplex &&
|
||||
return (
|
||||
!left.multiplex &&
|
||||
(left.name == 'background' || left.name == 'background-image') &&
|
||||
right.multiplex &&
|
||||
(right.name == 'background' || right.name == 'background-image') &&
|
||||
anyLayerIsNone(right.value);
|
||||
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;
|
||||
@ -253,55 +261,54 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
var overridable;
|
||||
var i, j, k;
|
||||
|
||||
propertyLoop:
|
||||
for (i = properties.length - 1; i >= 0; i--) {
|
||||
propertyLoop: 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 = compactable[right.name].canOverride;
|
||||
|
||||
traverseLoop:
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
traverseLoop: 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.unused || right.unused)
|
||||
continue;
|
||||
if (left.unused || right.unused) continue;
|
||||
|
||||
if (left.hack && !right.hack && !right.important || !left.hack && !left.important && right.hack)
|
||||
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] || (left.hack[1] && left.hack[1] != right.hack[1])))
|
||||
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))
|
||||
if (
|
||||
!anyValue(validator.isFunction, left) &&
|
||||
overridingFunction(right, validator)
|
||||
)
|
||||
continue;
|
||||
|
||||
if (!isMergeableShorthand(right)) {
|
||||
@ -311,10 +318,15 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
|
||||
component = findComponentIn(right, left);
|
||||
mayOverride = compactable[left.name].canOverride;
|
||||
if (everyValuesPair(mayOverride.bind(null, validator), left, component)) {
|
||||
if (
|
||||
everyValuesPair(mayOverride.bind(null, validator), left, component)
|
||||
) {
|
||||
left.unused = true;
|
||||
}
|
||||
} else if (right.shorthand && overridesNonComponentShorthand(right, left)) {
|
||||
} else if (
|
||||
right.shorthand &&
|
||||
overridesNonComponentShorthand(right, left)
|
||||
) {
|
||||
// `right` is a shorthand while `left` can be overriden by it, think `border` and `border-top`
|
||||
if (!right.important && left.important) {
|
||||
continue;
|
||||
@ -324,29 +336,40 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!anyValue(validator.isFunction, left) && overridingFunction(right, validator)) {
|
||||
if (
|
||||
!anyValue(validator.isFunction, left) &&
|
||||
overridingFunction(right, 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];
|
||||
overridingComponent = findComponentIn(right, overriddenComponent);
|
||||
mayOverride = compactable[overriddenComponent.name].canOverride;
|
||||
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), left, overridingComponent)) {
|
||||
if (
|
||||
!everyValuesPair(
|
||||
mayOverride.bind(null, validator),
|
||||
left,
|
||||
overridingComponent
|
||||
)
|
||||
) {
|
||||
continue traverseLoop;
|
||||
}
|
||||
}
|
||||
|
||||
left.unused = true;
|
||||
} else if (withMerging && left.shorthand && !right.shorthand && isComponentOf(left, right, 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;
|
||||
@ -354,34 +377,41 @@ 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;
|
||||
|
||||
component = findComponentIn(left, right);
|
||||
if (everyValuesPair(mayOverride.bind(null, validator), component, 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 nonMergeableValue = compactable[right.name].nonMergeableValue === right.value[0][1];
|
||||
(!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 =
|
||||
compactable[right.name].nonMergeableValue === right.value[0][1];
|
||||
|
||||
if (disabledBackgroundMerging || nonMergeableValue)
|
||||
if (disabledBackgroundMerging || nonMergeableValue) continue;
|
||||
|
||||
if (
|
||||
!compatibility.properties.merging &&
|
||||
wouldBreakCompatibility(left, validator)
|
||||
)
|
||||
continue;
|
||||
|
||||
if (!compatibility.properties.merging && wouldBreakCompatibility(left, validator))
|
||||
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));
|
||||
@ -389,11 +419,15 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
override(component, right);
|
||||
left.dirty = true;
|
||||
}
|
||||
} else if (withMerging && left.shorthand && right.shorthand && left.name == right.name) {
|
||||
} 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;
|
||||
@ -415,21 +449,33 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
var rightComponent = right.components[k];
|
||||
|
||||
mayOverride = compactable[leftComponent.name].canOverride;
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), leftComponent, rightComponent))
|
||||
if (
|
||||
!everyValuesPair(
|
||||
mayOverride.bind(null, validator),
|
||||
leftComponent,
|
||||
rightComponent
|
||||
)
|
||||
)
|
||||
continue propertyLoop;
|
||||
}
|
||||
|
||||
overrideShorthand(left, right);
|
||||
left.dirty = true;
|
||||
} else if (withMerging && left.shorthand && right.shorthand && isComponentOf(left, right)) {
|
||||
} 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 = compactable[right.name].canOverride;
|
||||
if (!everyValuesPair(mayOverride.bind(null, validator), component, right))
|
||||
if (
|
||||
!everyValuesPair(mayOverride.bind(null, validator), component, right)
|
||||
)
|
||||
continue;
|
||||
|
||||
if (left.important && !right.important) {
|
||||
@ -438,8 +484,7 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
}
|
||||
|
||||
var rightRestored = compactable[right.name].restore(right, compactable);
|
||||
if (rightRestored.length > 1)
|
||||
continue;
|
||||
if (rightRestored.length > 1) continue;
|
||||
|
||||
component = findComponentIn(left, right);
|
||||
override(component, right);
|
||||
@ -454,11 +499,21 @@ function overrideProperties(properties, withMerging, compatibility, validator) {
|
||||
overridingComponent = right.components[k];
|
||||
mayOverride = compactable[overridingComponent.name].canOverride;
|
||||
|
||||
overridable = overridable && everyValuesPair(mayOverride.bind(null, validator), overriddenComponent, overridingComponent);
|
||||
overridable =
|
||||
overridable &&
|
||||
everyValuesPair(
|
||||
mayOverride.bind(null, validator),
|
||||
overriddenComponent,
|
||||
overridingComponent
|
||||
);
|
||||
}
|
||||
} else {
|
||||
mayOverride = compactable[right.name].canOverride;
|
||||
overridable = everyValuesPair(mayOverride.bind(null, validator), left, right);
|
||||
overridable = everyValuesPair(
|
||||
mayOverride.bind(null, validator),
|
||||
left,
|
||||
right
|
||||
);
|
||||
}
|
||||
|
||||
if (left.important && !right.important && overridable) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
var compactable = require('../compactable');
|
||||
|
||||
function overridesNonComponentShorthand(property1, property2) {
|
||||
return property1.name in compactable &&
|
||||
return (
|
||||
property1.name in compactable &&
|
||||
'overridesShorthands' in compactable[property1.name] &&
|
||||
compactable[property1.name].overridesShorthands.indexOf(property2.name) > -1;
|
||||
compactable[property1.name].overridesShorthands.indexOf(property2.name) > -1
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = overridesNonComponentShorthand;
|
||||
|
15
node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js
generated
vendored
15
node_modules/clean-css/lib/optimizer/level-2/properties/populate-components.js
generated
vendored
@ -14,12 +14,20 @@ function populateComponents(properties, validator, warnings) {
|
||||
property.dirty = true;
|
||||
|
||||
try {
|
||||
property.components = descriptor.breakUp(property, compactable, validator);
|
||||
property.components = descriptor.breakUp(
|
||||
property,
|
||||
compactable,
|
||||
validator
|
||||
);
|
||||
|
||||
if (descriptor.shorthandComponents) {
|
||||
for (j = 0, m = property.components.length; j < m; j++) {
|
||||
component = property.components[j];
|
||||
component.components = compactable[component.name].breakUp(component, compactable, validator);
|
||||
component.components = compactable[component.name].breakUp(
|
||||
component,
|
||||
compactable,
|
||||
validator
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@ -33,8 +41,7 @@ function populateComponents(properties, validator, warnings) {
|
||||
|
||||
if (property.components.length > 0)
|
||||
property.multiplex = property.components[0].multiplex;
|
||||
else
|
||||
property.unused = true;
|
||||
else property.unused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
node_modules/clean-css/lib/optimizer/level-2/properties/understandable.js
generated
vendored
5
node_modules/clean-css/lib/optimizer/level-2/properties/understandable.js
generated
vendored
@ -5,7 +5,10 @@ function understandable(validator, value1, value2, _position, isPaired) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isPaired && validator.isVariable(value1) !== validator.isVariable(value2)) {
|
||||
if (
|
||||
isPaired &&
|
||||
validator.isVariable(value1) !== validator.isVariable(value2)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
2
node_modules/clean-css/lib/optimizer/level-2/properties/vendor-prefixes.js
generated
vendored
2
node_modules/clean-css/lib/optimizer/level-2/properties/vendor-prefixes.js
generated
vendored
@ -19,5 +19,5 @@ function same(value1, value2) {
|
||||
|
||||
module.exports = {
|
||||
unique: unique,
|
||||
same: same
|
||||
same: same,
|
||||
};
|
||||
|
Reference in New Issue
Block a user