postcss-minify-gradients
Advanced tools
Comparing version 4.0.0-rc.2 to 4.0.0
@@ -25,3 +25,3 @@ 'use strict'; | ||
var angles = { | ||
const angles = { | ||
top: '0deg', | ||
@@ -38,25 +38,26 @@ right: '90deg', | ||
function optimise(decl) { | ||
if (!~decl.value.indexOf('gradient')) { | ||
if (!~decl.value.toLowerCase().indexOf('gradient')) { | ||
return; | ||
} | ||
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) { | ||
decl.value = (0, _postcssValueParser2.default)(decl.value).walk(node => { | ||
if (node.type !== 'function' || !node.nodes.length) { | ||
return false; | ||
} | ||
if (node.value === 'linear-gradient' || node.value === 'repeating-linear-gradient' || node.value === '-webkit-linear-gradient' || node.value === '-webkit-repeating-linear-gradient') { | ||
var args = (0, _cssnanoUtilGetArguments2.default)(node); | ||
if (node.nodes[0].value === 'to' && args[0].length === 3) { | ||
const lowerCasedValue = node.value.toLowerCase(); | ||
if (lowerCasedValue === 'linear-gradient' || lowerCasedValue === 'repeating-linear-gradient' || lowerCasedValue === '-webkit-linear-gradient' || lowerCasedValue === '-webkit-repeating-linear-gradient') { | ||
let args = (0, _cssnanoUtilGetArguments2.default)(node); | ||
if (node.nodes[0].value.toLowerCase() === 'to' && args[0].length === 3) { | ||
node.nodes = node.nodes.slice(2); | ||
node.nodes[0].value = angles[node.nodes[0].value]; | ||
node.nodes[0].value = angles[node.nodes[0].value.toLowerCase()]; | ||
} | ||
var lastStop = null; | ||
args.forEach(function (arg, index) { | ||
let lastStop = null; | ||
args.forEach((arg, index) => { | ||
if (!arg[2]) { | ||
return; | ||
} | ||
var isFinalStop = index === args.length - 1; | ||
var thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
let isFinalStop = index === args.length - 1; | ||
let thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
if (lastStop === null) { | ||
lastStop = thisStop; | ||
if (!isFinalStop && lastStop && lastStop.number === '0' && lastStop.unit !== 'deg') { | ||
if (!isFinalStop && lastStop && lastStop.number === '0' && lastStop.unit.toLowerCase() !== 'deg') { | ||
arg[1].value = arg[2].value = ''; | ||
@@ -76,30 +77,28 @@ } | ||
} | ||
if (node.value === 'radial-gradient' || node.value === 'repeating-radial-gradient') { | ||
var _args = (0, _cssnanoUtilGetArguments2.default)(node); | ||
var _lastStop = void 0; | ||
var hasAt = _args[0].find(function (n) { | ||
return n.value === 'at'; | ||
}); | ||
_args.forEach(function (arg, index) { | ||
if (lowerCasedValue === 'radial-gradient' || lowerCasedValue === 'repeating-radial-gradient') { | ||
let args = (0, _cssnanoUtilGetArguments2.default)(node); | ||
let lastStop; | ||
const hasAt = args[0].find(n => n.value.toLowerCase() === 'at'); | ||
args.forEach((arg, index) => { | ||
if (!arg[2] || !index && hasAt) { | ||
return; | ||
} | ||
var thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
if (!_lastStop) { | ||
_lastStop = thisStop; | ||
let thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
if (!lastStop) { | ||
lastStop = thisStop; | ||
return; | ||
} | ||
if (isLessThan(_lastStop, thisStop)) { | ||
if (isLessThan(lastStop, thisStop)) { | ||
arg[2].value = 0; | ||
} | ||
_lastStop = thisStop; | ||
lastStop = thisStop; | ||
}); | ||
return false; | ||
} | ||
if (node.value === '-webkit-radial-gradient' || node.value === '-webkit-repeating-radial-gradient') { | ||
var _args2 = (0, _cssnanoUtilGetArguments2.default)(node); | ||
var _lastStop2 = void 0; | ||
_args2.forEach(function (arg) { | ||
var color = void 0; | ||
var stop = void 0; | ||
if (lowerCasedValue === '-webkit-radial-gradient' || lowerCasedValue === '-webkit-repeating-radial-gradient') { | ||
let args = (0, _cssnanoUtilGetArguments2.default)(node); | ||
let lastStop; | ||
args.forEach(arg => { | ||
let color; | ||
let stop; | ||
if (arg[2] !== undefined) { | ||
@@ -122,3 +121,3 @@ if (arg[0].type === 'function') { | ||
} | ||
var colorStop = stop || stop === 0 ? (0, _isColorStop2.default)(color, stop) : (0, _isColorStop2.default)(color); | ||
const colorStop = stop || stop === 0 ? (0, _isColorStop2.default)(color, stop) : (0, _isColorStop2.default)(color); | ||
@@ -128,11 +127,11 @@ if (!colorStop || !arg[2]) { | ||
} | ||
var thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
if (!_lastStop2) { | ||
_lastStop2 = thisStop; | ||
let thisStop = (0, _postcssValueParser.unit)(arg[2].value); | ||
if (!lastStop) { | ||
lastStop = thisStop; | ||
return; | ||
} | ||
if (isLessThan(_lastStop2, thisStop)) { | ||
if (isLessThan(lastStop, thisStop)) { | ||
arg[2].value = 0; | ||
} | ||
_lastStop2 = thisStop; | ||
lastStop = thisStop; | ||
}); | ||
@@ -144,7 +143,5 @@ return false; | ||
exports.default = _postcss2.default.plugin('postcss-minify-gradients', function () { | ||
return function (css) { | ||
return css.walkDecls(optimise); | ||
}; | ||
exports.default = _postcss2.default.plugin('postcss-minify-gradients', () => { | ||
return css => css.walkDecls(optimise); | ||
}); | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss-minify-gradients", | ||
"version": "4.0.0-rc.2", | ||
"version": "4.0.0", | ||
"description": "Minify gradient parameters with PostCSS.", | ||
@@ -21,5 +21,5 @@ "main": "dist/index.js", | ||
"babel-cli": "^6.0.0", | ||
"cross-env": "^3.0.0" | ||
"cross-env": "^5.0.0" | ||
}, | ||
"homepage": "https://github.com/ben-eb/cssnano", | ||
"homepage": "https://github.com/cssnano/cssnano", | ||
"author": { | ||
@@ -30,6 +30,6 @@ "name": "Ben Briggs", | ||
}, | ||
"repository": "ben-eb/cssnano", | ||
"repository": "cssnano/cssnano", | ||
"dependencies": { | ||
"cssnano-util-get-arguments": "^4.0.0-rc.2", | ||
"is-color-stop": "^1.1.0", | ||
"cssnano-util-get-arguments": "^4.0.0", | ||
"is-color-stop": "^1.0.0", | ||
"postcss": "^6.0.0", | ||
@@ -39,7 +39,7 @@ "postcss-value-parser": "^3.0.0" | ||
"bugs": { | ||
"url": "https://github.com/ben-eb/cssnano/issues" | ||
"url": "https://github.com/cssnano/cssnano/issues" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=6.9.0" | ||
} | ||
} |
@@ -46,3 +46,3 @@ # [postcss][postcss]-minify-gradients | ||
See [CONTRIBUTORS.md](https://github.com/ben-eb/cssnano/blob/master/CONTRIBUTORS.md). | ||
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md). | ||
@@ -49,0 +49,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
125
1
Updatedis-color-stop@^1.0.0