mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-04 04:40:05 +02:00
update packages to latest version
This commit is contained in:
44
node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js
generated
vendored
44
node_modules/clean-css/lib/optimizer/level-1/tidy-rules.js
generated
vendored
@@ -9,7 +9,7 @@ var DOUBLE_QUOTE_PATTERN = /="([a-zA-Z][a-zA-Z\d\-_]+)"(\s|\])/g;
|
||||
var HTML_COMMENT_PATTERN = /^(?:(?:<!--|-->)\s*)+/;
|
||||
var SINGLE_QUOTE_CASE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'([iI])/g;
|
||||
var SINGLE_QUOTE_PATTERN = /='([a-zA-Z][a-zA-Z\d\-_]+)'(\s|\])/g;
|
||||
var RELATION_PATTERN = /[>\+~]/;
|
||||
var RELATION_PATTERN = /[>+~]/;
|
||||
var WHITESPACE_PATTERN = /\s/;
|
||||
|
||||
var ASTERISK_PLUS_HTML_HACK = '*+html ';
|
||||
@@ -42,7 +42,12 @@ function hasInvalidCharacters(value) {
|
||||
// continue as always
|
||||
} else if (character == Marker.SINGLE_QUOTE || character == Marker.DOUBLE_QUOTE) {
|
||||
isQuote = !isQuote;
|
||||
} else if (!isQuote && (character == Marker.CLOSE_CURLY_BRACKET || character == Marker.EXCLAMATION || character == LESS_THAN || character == Marker.SEMICOLON)) {
|
||||
} else if (!isQuote
|
||||
&& (character == Marker.CLOSE_CURLY_BRACKET
|
||||
|| character == Marker.EXCLAMATION
|
||||
|| character == LESS_THAN
|
||||
|| character == Marker.SEMICOLON)
|
||||
) {
|
||||
isInvalid = true;
|
||||
break;
|
||||
} else if (!isQuote && i === 0 && RELATION_PATTERN.test(character)) {
|
||||
@@ -86,9 +91,10 @@ function removeWhitespace(value, format) {
|
||||
isQuoted = isSingleQuoted || isDoubleQuoted;
|
||||
isRelation = !isAttribute && !isEscaped && roundBracketLevel === 0 && RELATION_PATTERN.test(character);
|
||||
isWhitespace = WHITESPACE_PATTERN.test(character);
|
||||
isSpaceAwarePseudoClass = roundBracketLevel == 1 && character == Marker.CLOSE_ROUND_BRACKET ?
|
||||
false :
|
||||
isSpaceAwarePseudoClass || (roundBracketLevel === 0 && character == Marker.COLON && isPseudoClassWithSelectors(value, i));
|
||||
isSpaceAwarePseudoClass = roundBracketLevel == 1 && character == Marker.CLOSE_ROUND_BRACKET
|
||||
? false
|
||||
: isSpaceAwarePseudoClass
|
||||
|| (roundBracketLevel === 0 && character == Marker.COLON && isPseudoClassWithSelectors(value, i));
|
||||
|
||||
if (wasEscaped && isQuoted && isNewLineWin) {
|
||||
// swallow escaped new windows lines in comments
|
||||
@@ -157,9 +163,9 @@ function removeWhitespace(value, format) {
|
||||
wasComma = character == Marker.COMMA;
|
||||
}
|
||||
|
||||
return withCaseAttribute ?
|
||||
stripped.join('').replace(CASE_RESTORE_PATTERN, '$1 $2]') :
|
||||
stripped.join('');
|
||||
return withCaseAttribute
|
||||
? stripped.join('').replace(CASE_RESTORE_PATTERN, '$1 $2]')
|
||||
: stripped.join('');
|
||||
}
|
||||
|
||||
function isPseudoClassWithSelectors(value, colonPosition) {
|
||||
@@ -180,6 +186,22 @@ function removeQuotes(value) {
|
||||
.replace(DOUBLE_QUOTE_PATTERN, '=$1$2');
|
||||
}
|
||||
|
||||
function replacePseudoClasses(value) {
|
||||
return value
|
||||
.replace('nth-child(1)', 'first-child')
|
||||
.replace('nth-of-type(1)', 'first-of-type')
|
||||
.replace('nth-of-type(even)', 'nth-of-type(2n)')
|
||||
.replace('nth-child(even)', 'nth-child(2n)')
|
||||
.replace('nth-of-type(2n+1)', 'nth-of-type(odd)')
|
||||
.replace('nth-child(2n+1)', 'nth-child(odd)')
|
||||
.replace('nth-last-child(1)', 'last-child')
|
||||
.replace('nth-last-of-type(1)', 'last-of-type')
|
||||
.replace('nth-last-of-type(even)', 'nth-last-of-type(2n)')
|
||||
.replace('nth-last-child(even)', 'nth-last-child(2n)')
|
||||
.replace('nth-last-of-type(2n+1)', 'nth-last-of-type(odd)')
|
||||
.replace('nth-last-child(2n+1)', 'nth-last-child(odd)');
|
||||
}
|
||||
|
||||
function tidyRules(rules, removeUnsupported, adjacentSpace, format, warnings) {
|
||||
var list = [];
|
||||
var repeated = [];
|
||||
@@ -217,14 +239,16 @@ function tidyRules(rules, removeUnsupported, adjacentSpace, format, warnings) {
|
||||
|
||||
if (reduced.indexOf('*') > -1) {
|
||||
reduced = reduced
|
||||
.replace(/\*([:#\.\[])/g, '$1')
|
||||
.replace(/^(\:first\-child)?\+html/, '*$1+html');
|
||||
.replace(/\*([:#.[])/g, '$1')
|
||||
.replace(/^(:first-child)?\+html/, '*$1+html');
|
||||
}
|
||||
|
||||
if (repeated.indexOf(reduced) > -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
reduced = replacePseudoClasses(reduced);
|
||||
|
||||
rule[1] = reduced;
|
||||
repeated.push(reduced);
|
||||
list.push(rule);
|
||||
|
Reference in New Issue
Block a user