postcss-minify-gradients 1.0.1 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # 1.0.5
2
+
3
+ * Resolves a crash on empty `linear-gradient()` functions.
4
+
5
+ # 1.0.4
6
+
7
+ * Resolves an issue where `0` was being removed from intermediate colour stops
8
+ if preceding colour stops contained `calc()` (thanks to @jaybekster).
9
+
10
+ # 1.0.3
11
+
12
+ * Resolves an issue where `0` was being incorrectly stripped from the final
13
+ colour stop value.
14
+
15
+ # 1.0.2
16
+
17
+ * Resolves an issue where the module would incorrectly parse floating
18
+ point numbers.
19
+
1
20
  # 1.0.1
2
21
 
3
22
  * Reduce function iterations (thanks to @TrySound).
package/README.md CHANGED
@@ -41,10 +41,17 @@ See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
41
41
  examples for your environment.
42
42
 
43
43
 
44
- ## Contributing
44
+ ## Contributors
45
45
 
46
- Pull requests are welcome. If you add functionality, then please add unit tests
47
- to cover it.
46
+ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
47
+
48
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
49
+ | [<img src="https://avatars.githubusercontent.com/u/1282980?v=3" width="100px;"/><br /><sub>Ben Briggs</sub>](http://beneb.info)<br />[💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-minify-gradients/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/5635476?v=3" width="100px;"/><br /><sub>Bogdan Chadkin</sub>](https://github.com/TrySound)<br />[💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=TrySound) | [<img src="https://avatars.githubusercontent.com/u/1448788?v=3" width="100px;"/><br /><sub></sub>](https://github.com/huan086)<br />[🐛](https://github.com/ben-eb/postcss-minify-gradients/issues?q=author%3Ahuan086) | [<img src="https://avatars.githubusercontent.com/u/2485494?v=3" width="100px;"/><br /><sub>Mikhail</sub>](https://github.com/jaybekster)<br />[🐛](https://github.com/ben-eb/postcss-minify-gradients/issues?q=author%3Ajaybekster) [💻](https://github.com/ben-eb/postcss-minify-gradients/commits?author=jaybekster) [⚠️](https://github.com/ben-eb/postcss-minify-gradients/commits?author=jaybekster) |
50
+ | :---: | :---: | :---: | :---: |
51
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
52
+
53
+ This project follows the [all-contributors] specification. Contributions of
54
+ any kind welcome!
48
55
 
49
56
 
50
57
  ## License
@@ -52,6 +59,7 @@ to cover it.
52
59
  MIT © [Ben Briggs](http://beneb.info)
53
60
 
54
61
 
62
+ [all-contributors]: https://github.com/kentcdodds/all-contributors
55
63
  [ci]: https://travis-ci.org/ben-eb/postcss-minify-gradients
56
64
  [deps]: https://gemnasium.com/ben-eb/postcss-minify-gradients
57
65
  [npm]: http://badge.fury.io/js/postcss-minify-gradients
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- });
3
+ exports.__esModule = true;
6
4
 
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
5
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
8
6
 
9
7
  var _postcss = require('postcss');
10
8
 
@@ -14,6 +12,8 @@ var _postcssValueParser = require('postcss-value-parser');
14
12
 
15
13
  var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
16
14
 
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
17
  var angles = {
18
18
  top: '0deg',
19
19
  right: '90deg',
@@ -33,33 +33,39 @@ function getArguments(node) {
33
33
  }
34
34
 
35
35
  function isLessThan(a, b) {
36
- return a.unit === b.unit && parseInt(a.number, 10) >= parseInt(b.number, 10);
36
+ return a.unit === b.unit && parseFloat(a.number) >= parseFloat(b.number);
37
37
  }
38
38
 
39
39
  function optimise(decl) {
40
- if (! ~decl.value.indexOf('gradient')) {
40
+ if (!~decl.value.indexOf('gradient')) {
41
41
  return;
42
42
  }
43
- decl.value = (0, _postcssValueParser2['default'])(decl.value).walk(function (node) {
43
+ decl.value = (0, _postcssValueParser2.default)(decl.value).walk(function (node) {
44
44
  if (node.type !== 'function') {
45
45
  return false;
46
46
  }
47
47
  if (node.value === 'linear-gradient' || node.value === 'repeating-linear-gradient' || node.value === '-webkit-linear-gradient' || node.value === '-webkit-repeating-linear-gradient') {
48
- var _ret = (function () {
48
+ var _ret = function () {
49
+ if (!node.nodes.length) {
50
+ return {
51
+ v: false
52
+ };
53
+ }
49
54
  var args = getArguments(node);
50
55
  if (node.nodes[0].value === 'to' && args[0].length === 3) {
51
56
  node.nodes = node.nodes.slice(2);
52
57
  node.nodes[0].value = angles[node.nodes[0].value];
53
58
  }
54
- var lastStop = undefined;
59
+ var lastStop = null;
55
60
  args.forEach(function (arg, index) {
56
61
  if (!arg[2]) {
57
62
  return;
58
63
  }
64
+ var isFinalStop = index === args.length - 1;
59
65
  var thisStop = (0, _postcssValueParser.unit)(arg[2].value);
60
- if (!lastStop) {
66
+ if (lastStop === null) {
61
67
  lastStop = thisStop;
62
- if (lastStop && lastStop.number === '0' && lastStop.unit !== 'deg') {
68
+ if (!isFinalStop && lastStop && lastStop.number === '0' && lastStop.unit !== 'deg') {
63
69
  arg[1].value = arg[2].value = '';
64
70
  }
65
71
  return;
@@ -68,21 +74,26 @@ function optimise(decl) {
68
74
  arg[2].value = 0;
69
75
  }
70
76
  lastStop = thisStop;
71
- if (index === args.length - 1 && arg[2].value === '100%') {
77
+ if (isFinalStop && arg[2].value === '100%') {
72
78
  arg[1].value = arg[2].value = '';
73
79
  }
74
80
  });
75
81
  return {
76
82
  v: false
77
83
  };
78
- })();
84
+ }();
79
85
 
80
- if (typeof _ret === 'object') return _ret.v;
86
+ if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
81
87
  }
82
88
  if (node.value === 'radial-gradient' || node.value === 'repeating-radial-gradient' || node.value === '-webkit-radial-gradient' || node.value === '-webkit-repeating-radial-gradient') {
83
- var _ret2 = (function () {
89
+ var _ret2 = function () {
90
+ if (!node.nodes.length) {
91
+ return {
92
+ v: false
93
+ };
94
+ }
84
95
  var args = getArguments(node);
85
- var lastStop = undefined;
96
+ var lastStop = void 0;
86
97
  args.forEach(function (arg) {
87
98
  if (!arg[2]) {
88
99
  return;
@@ -100,14 +111,14 @@ function optimise(decl) {
100
111
  return {
101
112
  v: false
102
113
  };
103
- })();
114
+ }();
104
115
 
105
- if (typeof _ret2 === 'object') return _ret2.v;
116
+ if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v;
106
117
  }
107
118
  }).toString();
108
119
  }
109
120
 
110
- exports['default'] = _postcss2['default'].plugin('postcss-minify-gradients', function () {
121
+ exports.default = _postcss2.default.plugin('postcss-minify-gradients', function () {
111
122
  return function (css) {
112
123
  return css.walkDecls(optimise);
113
124
  };
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "postcss-minify-gradients",
3
- "version": "1.0.1",
3
+ "version": "1.0.5",
4
4
  "description": "Minify gradient parameters with PostCSS.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "lint": "eslint src",
8
- "prepublish": "babel src --out-dir dist --ignore /__tests__/",
9
- "test": "npm run lint && babel-tape-runner \"src/**/__tests__/*.js\" | tap-spec"
7
+ "contributorAdd": "all-contributors add",
8
+ "contributorGenerate": "all-contributors generate",
9
+ "pretest": "eslint src",
10
+ "prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
11
+ "test": "ava src/__tests__",
12
+ "test-012": "ava src/__tests__"
10
13
  },
11
14
  "files": [
12
15
  "LICENSE-MIT",
@@ -19,11 +22,20 @@
19
22
  ],
20
23
  "license": "MIT",
21
24
  "devDependencies": {
22
- "babel": "^5.8.23",
23
- "babel-tape-runner": "1.2.0",
24
- "eslint": "^1.10.3",
25
- "tap-spec": "^4.1.1",
26
- "tape": "^4.2.2"
25
+ "all-contributors-cli": "^3.0.5",
26
+ "ava": "^0.16.0",
27
+ "babel-cli": "^6.3.17",
28
+ "babel-core": "^6.3.26",
29
+ "babel-plugin-add-module-exports": "^0.2.1",
30
+ "babel-preset-es2015": "^6.3.13",
31
+ "babel-preset-es2015-loose": "^7.0.0",
32
+ "babel-preset-stage-0": "^6.3.13",
33
+ "babel-register": "^6.9.0",
34
+ "del-cli": "^0.2.0",
35
+ "eslint": "^3.0.0",
36
+ "eslint-config-cssnano": "^3.0.0",
37
+ "eslint-plugin-babel": "^3.3.0",
38
+ "eslint-plugin-import": "^2.0.1"
27
39
  },
28
40
  "homepage": "https://github.com/ben-eb/postcss-minify-gradients",
29
41
  "author": {
@@ -34,6 +46,12 @@
34
46
  "repository": "ben-eb/postcss-minify-gradients",
35
47
  "dependencies": {
36
48
  "postcss": "^5.0.12",
37
- "postcss-value-parser": "^3.1.3"
49
+ "postcss-value-parser": "^3.3.0"
50
+ },
51
+ "ava": {
52
+ "require": "babel-register"
53
+ },
54
+ "eslintConfig": {
55
+ "extends": "cssnano"
38
56
  }
39
57
  }