aboutsummaryrefslogtreecommitdiff
path: root/node_modules/clean-css/lib/optimizer/level-1
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-24 15:10:37 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-24 15:11:17 +0200
commit7a3df06eb573d36142bd1a8e03c5ce8752d300b3 (patch)
tree70bfaea8884c374876f607774850a3a51c0cb381 /node_modules/clean-css/lib/optimizer/level-1
parentaca1143cb9eed16cf37f04e475e4257418dd18ac (diff)
fix build issues and add typedoc
Diffstat (limited to 'node_modules/clean-css/lib/optimizer/level-1')
-rw-r--r--node_modules/clean-css/lib/optimizer/level-1/optimize.js67
-rw-r--r--node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js12
2 files changed, 7 insertions, 72 deletions
diff --git a/node_modules/clean-css/lib/optimizer/level-1/optimize.js b/node_modules/clean-css/lib/optimizer/level-1/optimize.js
index e7a9bbb47..5a6da47c0 100644
--- a/node_modules/clean-css/lib/optimizer/level-1/optimize.js
+++ b/node_modules/clean-css/lib/optimizer/level-1/optimize.js
@@ -26,10 +26,6 @@ var CHARSET_REGEXP = new RegExp('^' + CHARSET_TOKEN, 'i');
var DEFAULT_ROUNDING_PRECISION = require('../../options/rounding-precision').DEFAULT;
-var FONT_NUMERAL_WEIGHTS = ['100', '200', '300', '400', '500', '600', '700', '800', '900'];
-var FONT_NAME_WEIGHTS = ['normal', 'bold', 'bolder', 'lighter'];
-var FONT_NAME_WEIGHTS_WITHOUT_NORMAL = ['bold', 'bolder', 'lighter'];
-
var WHOLE_PIXEL_VALUE = /(?:^|\s|\()(-?\d+)px/;
var TIME_VALUE = /^(\-?[\d\.]+)(m?s)$/;
@@ -159,63 +155,6 @@ function optimizeFilter(property) {
.replace(/ ?= ?/g, '=');
}
-function optimizeFont(property, options) {
- var values = property.value;
- var hasNumeral = FONT_NUMERAL_WEIGHTS.indexOf(values[0][1]) > -1 ||
- values[1] && FONT_NUMERAL_WEIGHTS.indexOf(values[1][1]) > -1 ||
- values[2] && FONT_NUMERAL_WEIGHTS.indexOf(values[2][1]) > -1;
- var canOptimizeFontWeight = options.level[OptimizationLevel.One].optimizeFontWeight;
- var normalCount = 0;
- var toOptimize;
-
- if (!canOptimizeFontWeight) {
- return;
- }
-
- if (hasNumeral) {
- return;
- }
-
- if (values[1] && values[1][1] == '/') {
- return;
- }
-
- if (values[0][1] == 'normal') {
- normalCount++;
- }
-
- if (values[1] && values[1][1] == 'normal') {
- normalCount++;
- }
-
- if (values[2] && values[2][1] == 'normal') {
- normalCount++;
- }
-
- if (normalCount > 1) {
- return;
- }
-
- if (FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[0][1]) > -1) {
- toOptimize = 0;
- } else if (values[1] && FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[1][1]) > -1) {
- toOptimize = 1;
- } else if (values[2] && FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[2][1]) > -1) {
- toOptimize = 2;
- } else if (FONT_NAME_WEIGHTS.indexOf(values[0][1]) > -1) {
- toOptimize = 0;
- } else if (values[1] && FONT_NAME_WEIGHTS.indexOf(values[1][1]) > -1) {
- toOptimize = 1;
- } else if (values[2] && FONT_NAME_WEIGHTS.indexOf(values[2][1]) > -1) {
- toOptimize = 2;
- }
-
- if (toOptimize !== undefined && canOptimizeFontWeight) {
- optimizeFontWeight(property, toOptimize);
- property.dirty = true;
- }
-}
-
function optimizeFontWeight(property, atIndex) {
var value = property.value[atIndex][1];
@@ -483,7 +422,7 @@ function optimizeBody(properties, context) {
break;
}
- if (valueIsUrl && !context.validator.isValidUrl(value)) {
+ if (valueIsUrl && !context.validator.isUrl(value)) {
property.unused = true;
context.warnings.push('Broken URL \'' + value + '\' at ' + formatPosition(property.value[j][2][0]) + '. Ignoring.');
break;
@@ -543,8 +482,6 @@ function optimizeBody(properties, context) {
optimizeBorderRadius(property);
} else if (name == 'filter'&& levelOptions.optimizeFilter && options.compatibility.properties.ieFilters) {
optimizeFilter(property);
- } else if (name == 'font' && levelOptions.optimizeFont) {
- optimizeFont(property, options);
} else if (name == 'font-weight' && levelOptions.optimizeFontWeight) {
optimizeFontWeight(property, 0);
} else if (name == 'outline' && levelOptions.optimizeOutline) {
@@ -717,7 +654,7 @@ function level1Optimize(tokens, context) {
break;
}
- if (token[1].length === 0 || (token[2] && token[2].length === 0)) {
+ if (levelOptions.removeEmpty && (token[1].length === 0 || (token[2] && token[2].length === 0))) {
tokens.splice(i, 1);
i--;
l--;
diff --git a/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js b/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js
index 2f179e6ef..5b261dfb0 100644
--- a/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js
+++ b/node_modules/clean-css/lib/optimizer/level-1/sort-selectors.js
@@ -9,17 +9,15 @@ function standardSorter(scope1, scope2) {
}
function sortSelectors(selectors, method) {
- var sorter;
-
switch (method) {
case 'natural':
- sorter = naturalSorter;
- break;
+ return selectors.sort(naturalSorter);
case 'standard':
- sorter = standardSorter;
+ return selectors.sort(standardSorter);
+ case 'none':
+ case false:
+ return selectors;
}
-
- return selectors.sort(sorter);
}
module.exports = sortSelectors;