format: prettify entire project
This commit is contained in:
58
node_modules/clean-css/lib/optimizer/wrap-for-optimizing.js
generated
vendored
58
node_modules/clean-css/lib/optimizer/wrap-for-optimizing.js
generated
vendored
@ -14,7 +14,7 @@ var Match = {
|
||||
IMPORTANT_WORD_PATTERN: new RegExp('important$', 'i'),
|
||||
SUFFIX_BANG_PATTERN: /!$/,
|
||||
UNDERSCORE: '_',
|
||||
VARIABLE_REFERENCE_PATTERN: /var\(--.+\)$/
|
||||
VARIABLE_REFERENCE_PATTERN: /var\(--.+\)$/,
|
||||
};
|
||||
|
||||
function wrapAll(properties, includeVariable, skipProperties) {
|
||||
@ -78,7 +78,10 @@ function isMultiplex(property) {
|
||||
for (i = 3, l = property.length; i < l; i++) {
|
||||
value = property[i];
|
||||
|
||||
if (value[0] == Token.PROPERTY_VALUE && (value[1] == Marker.COMMA || value[1] == Marker.FORWARD_SLASH)) {
|
||||
if (
|
||||
value[0] == Token.PROPERTY_VALUE &&
|
||||
(value[1] == Marker.COMMA || value[1] == Marker.FORWARD_SLASH)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -95,13 +98,30 @@ function hackFrom(property) {
|
||||
match = [Hack.UNDERSCORE];
|
||||
} else if (name[0] == Match.ASTERISK) {
|
||||
match = [Hack.ASTERISK];
|
||||
} else if (lastValue[1][0] == Match.BANG && !lastValue[1].match(Match.IMPORTANT_WORD_PATTERN)) {
|
||||
} else if (
|
||||
lastValue[1][0] == Match.BANG &&
|
||||
!lastValue[1].match(Match.IMPORTANT_WORD_PATTERN)
|
||||
) {
|
||||
match = [Hack.BANG];
|
||||
} else if (lastValue[1].indexOf(Match.BANG) > 0 && !lastValue[1].match(Match.IMPORTANT_WORD_PATTERN) && Match.BANG_SUFFIX_PATTERN.test(lastValue[1])) {
|
||||
} else if (
|
||||
lastValue[1].indexOf(Match.BANG) > 0 &&
|
||||
!lastValue[1].match(Match.IMPORTANT_WORD_PATTERN) &&
|
||||
Match.BANG_SUFFIX_PATTERN.test(lastValue[1])
|
||||
) {
|
||||
match = [Hack.BANG];
|
||||
} else if (lastValue[1].indexOf(Match.BACKSLASH) > 0 && lastValue[1].indexOf(Match.BACKSLASH) == lastValue[1].length - Match.BACKSLASH.length - 1) {
|
||||
match = [Hack.BACKSLASH, lastValue[1].substring(lastValue[1].indexOf(Match.BACKSLASH) + 1)];
|
||||
} else if (lastValue[1].indexOf(Match.BACKSLASH) === 0 && lastValue[1].length == 2) {
|
||||
} else if (
|
||||
lastValue[1].indexOf(Match.BACKSLASH) > 0 &&
|
||||
lastValue[1].indexOf(Match.BACKSLASH) ==
|
||||
lastValue[1].length - Match.BACKSLASH.length - 1
|
||||
) {
|
||||
match = [
|
||||
Hack.BACKSLASH,
|
||||
lastValue[1].substring(lastValue[1].indexOf(Match.BACKSLASH) + 1),
|
||||
];
|
||||
} else if (
|
||||
lastValue[1].indexOf(Match.BACKSLASH) === 0 &&
|
||||
lastValue[1].length == 2
|
||||
) {
|
||||
match = [Hack.BACKSLASH, lastValue[1].substring(1)];
|
||||
}
|
||||
|
||||
@ -109,13 +129,15 @@ function hackFrom(property) {
|
||||
}
|
||||
|
||||
function isImportant(property) {
|
||||
if (property.length < 3)
|
||||
return false;
|
||||
if (property.length < 3) return false;
|
||||
|
||||
var lastValue = property[property.length - 1];
|
||||
if (Match.IMPORTANT_TOKEN_PATTERN.test(lastValue[1])) {
|
||||
return true;
|
||||
} else if (Match.IMPORTANT_WORD_PATTERN.test(lastValue[1]) && Match.SUFFIX_BANG_PATTERN.test(property[property.length - 2][1])) {
|
||||
} else if (
|
||||
Match.IMPORTANT_WORD_PATTERN.test(lastValue[1]) &&
|
||||
Match.SUFFIX_BANG_PATTERN.test(property[property.length - 2][1])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -130,7 +152,10 @@ function stripImportant(property) {
|
||||
lastValue[1] = lastValue[1].replace(Match.IMPORTANT_TOKEN_PATTERN, '');
|
||||
} else {
|
||||
lastValue[1] = lastValue[1].replace(Match.IMPORTANT_WORD_PATTERN, '');
|
||||
oneButLastValue[1] = oneButLastValue[1].replace(Match.SUFFIX_BANG_PATTERN, '');
|
||||
oneButLastValue[1] = oneButLastValue[1].replace(
|
||||
Match.SUFFIX_BANG_PATTERN,
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
if (lastValue[1].length === 0) {
|
||||
@ -149,7 +174,12 @@ function stripPrefixHack(property) {
|
||||
function stripSuffixHack(property, hackFrom) {
|
||||
var lastValue = property[property.length - 1];
|
||||
lastValue[1] = lastValue[1]
|
||||
.substring(0, lastValue[1].indexOf(hackFrom[0] == Hack.BACKSLASH ? Match.BACKSLASH : Match.BANG))
|
||||
.substring(
|
||||
0,
|
||||
lastValue[1].indexOf(
|
||||
hackFrom[0] == Hack.BACKSLASH ? Match.BACKSLASH : Match.BANG
|
||||
)
|
||||
)
|
||||
.trim();
|
||||
|
||||
if (lastValue[1].length === 0) {
|
||||
@ -181,11 +211,11 @@ function wrapSingle(property) {
|
||||
position: 0,
|
||||
shorthand: false,
|
||||
unused: false,
|
||||
value: property.slice(2)
|
||||
value: property.slice(2),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
all: wrapAll,
|
||||
single: wrapSingle
|
||||
single: wrapSingle,
|
||||
};
|
||||
|
Reference in New Issue
Block a user