postcss-reduce-initial 4.0.3 → 5.0.0

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 ADDED
@@ -0,0 +1,71 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [5.0.0](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.2...postcss-reduce-initial@5.0.0) (2021-04-06)
7
+
8
+ **Note:** Version bump only for package postcss-reduce-initial
9
+
10
+
11
+
12
+
13
+
14
+ # [5.0.0-rc.2](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.1...postcss-reduce-initial@5.0.0-rc.2) (2021-03-15)
15
+
16
+ **Note:** Version bump only for package postcss-reduce-initial
17
+
18
+
19
+
20
+
21
+
22
+ # [5.0.0-rc.1](https://github.com/cssnano/cssnano/compare/postcss-reduce-initial@5.0.0-rc.0...postcss-reduce-initial@5.0.0-rc.1) (2021-03-04)
23
+
24
+ **Note:** Version bump only for package postcss-reduce-initial
25
+
26
+
27
+
28
+
29
+
30
+ # 5.0.0-rc.0 (2021-02-19)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * min-width/height issue ([#852](https://github.com/cssnano/cssnano/issues/852)) ([f6e767b](https://github.com/cssnano/cssnano/commit/f6e767b7ba672c5c1b4a1350f23b4b65a4851f96))
36
+
37
+
38
+ ### chore
39
+
40
+ * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
41
+
42
+
43
+ ### Features
44
+
45
+ * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
46
+ * **postcss-reduce-initial:** added ignore options ([#929](https://github.com/cssnano/cssnano/issues/929)) ([2e63fe5](https://github.com/cssnano/cssnano/commit/2e63fe55b8059fc14d78aa11920d7ebf9a3682a1))
47
+
48
+
49
+ ### BREAKING CHANGES
50
+
51
+ * minimum supported `postcss` version is `8.2.1`
52
+ * minimum require version of node is 10.13
53
+
54
+
55
+
56
+ ## 4.1.9 (2019-02-12)
57
+
58
+
59
+ ### Bug Fixes
60
+
61
+ * **postcss-reduce-initial:** handle uppercase value toInitial ([#685](https://github.com/cssnano/cssnano/issues/685)) ([0e7beb3](https://github.com/cssnano/cssnano/commit/0e7beb3508fa8f85db67e3464bf8b8941bb6ca12))
62
+ * change mask-repeat initial value on repeat ([#679](https://github.com/cssnano/cssnano/issues/679)) ([cebd6d5](https://github.com/cssnano/cssnano/commit/cebd6d5b789a9c700f92dc8b40cdd8ef9545441a))
63
+
64
+
65
+
66
+ ## 4.1.1 (2018-09-24)
67
+
68
+
69
+ ### Bug Fixes
70
+
71
+ * **postcss-merge-longhand:** not mangle border output ([#555](https://github.com/cssnano/cssnano/issues/555)) ([9a70605](https://github.com/cssnano/cssnano/commit/9a706050b621e7795a9bf74eb7110b5c81804ffe)), closes [#553](https://github.com/cssnano/cssnano/issues/553) [#554](https://github.com/cssnano/cssnano/issues/554)
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # [postcss][postcss]-reduce-initial
2
2
 
3
- > Reduce `initial` definitions to the *actual* initial value, where possible.
4
-
3
+ > Reduce `initial` definitions to the _actual_ initial value, where possible.
5
4
 
6
5
  ## Install
7
6
 
@@ -11,7 +10,6 @@ With [npm](https://npmjs.org/package/postcss-reduce-initial) do:
11
10
  npm install postcss-reduce-initial --save
12
11
  ```
13
12
 
14
-
15
13
  ## Examples
16
14
 
17
15
  See the [data](data) for more conversions. This data is courtesy
@@ -26,7 +24,7 @@ be converted:
26
24
 
27
25
  ```css
28
26
  h1 {
29
- min-width: initial;
27
+ min-width: initial;
30
28
  }
31
29
  ```
32
30
 
@@ -34,11 +32,10 @@ h1 {
34
32
 
35
33
  ```css
36
34
  h1 {
37
- min-width: 0;
35
+ min-width: 0;
38
36
  }
39
37
  ```
40
38
 
41
-
42
39
  ### Convert values back to `initial`
43
40
 
44
41
  When the `initial` value is smaller than the property value, it will
@@ -48,7 +45,7 @@ be converted:
48
45
 
49
46
  ```css
50
47
  h1 {
51
- transform-box: border-box;
48
+ transform-box: border-box;
52
49
  }
53
50
  ```
54
51
 
@@ -56,31 +53,42 @@ h1 {
56
53
 
57
54
  ```css
58
55
  h1 {
59
- transform-box: initial;
56
+ transform-box: initial;
60
57
  }
61
58
  ```
62
59
 
63
60
  This conversion is only applied when you supply a browsers list that all support
64
61
  the `initial` keyword; it's worth noting that Internet Explorer has no support.
65
62
 
63
+ ## API
64
+
65
+ ### reduceInitial([options])
66
+
67
+ #### options
68
+
69
+ ##### ignore
70
+
71
+ Type: `Array<String>`
72
+ Default: `undefined`
73
+
74
+ It contains the Array of properties that will be ignored while reducing its value to initial.
75
+ Example : `{ ignore : ["min-height"] }`
66
76
 
67
77
  ## Usage
68
78
 
69
79
  See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
70
80
  examples for your environment.
71
81
 
72
-
73
82
  ## Contributors
74
83
 
75
84
  See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
76
85
 
77
-
78
86
  ## License
79
87
 
80
88
  [Template:CSSData] by Mozilla Contributors is licensed under [CC-BY-SA 2.5].
81
89
 
82
- [Template:CSSData]: https://developer.mozilla.org/en-US/docs/Template:CSSData
83
- [CC-BY-SA 2.5]: http://creativecommons.org/licenses/by-sa/2.5/
90
+ [template:cssdata]: https://developer.mozilla.org/en-US/docs/Template:CSSData
91
+ [cc-by-sa 2.5]: http://creativecommons.org/licenses/by-sa/2.5/
84
92
 
85
93
  MIT © [Ben Briggs](http://beneb.info)
86
94
 
@@ -167,9 +167,9 @@
167
167
  "max-lines": "none",
168
168
  "max-width": "none",
169
169
  "min-block-size": "0",
170
- "min-height": "0",
170
+ "min-height": "auto",
171
171
  "min-inline-size": "0",
172
- "min-width": "0",
172
+ "min-width": "auto",
173
173
  "mix-blend-mode": "normal",
174
174
  "object-fit": "fill",
175
175
  "offset-anchor": "auto",
package/dist/index.js CHANGED
@@ -1,58 +1,66 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
+ exports.default = void 0;
6
7
 
7
- var _postcss = require('postcss');
8
+ var _browserslist = _interopRequireDefault(require("browserslist"));
8
9
 
9
- var _has = require('has');
10
+ var _caniuseApi = require("caniuse-api");
10
11
 
11
- var _has2 = _interopRequireDefault(_has);
12
+ var _fromInitial = _interopRequireDefault(require("../data/fromInitial.json"));
12
13
 
13
- var _browserslist = require('browserslist');
14
-
15
- var _browserslist2 = _interopRequireDefault(_browserslist);
16
-
17
- var _caniuseApi = require('caniuse-api');
18
-
19
- var _fromInitial = require('../data/fromInitial.json');
20
-
21
- var _fromInitial2 = _interopRequireDefault(_fromInitial);
22
-
23
- var _toInitial = require('../data/toInitial.json');
24
-
25
- var _toInitial2 = _interopRequireDefault(_toInitial);
14
+ var _toInitial = _interopRequireDefault(require("../data/toInitial.json"));
26
15
 
27
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
17
 
29
- const initial = 'initial';
30
-
31
- exports.default = (0, _postcss.plugin)('postcss-reduce-initial', () => {
32
- return (css, result) => {
33
- const resultOpts = result.opts || {};
34
- const browsers = (0, _browserslist2.default)(null, {
35
- stats: resultOpts.stats,
36
- path: __dirname,
37
- env: resultOpts.env
38
- });
39
-
40
- const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
41
-
42
- css.walkDecls(decl => {
18
+ const initial = 'initial'; // In most of the browser including chrome the initial for `writing-mode` is not `horizontal-tb`. Ref https://github.com/cssnano/cssnano/pull/905
19
+
20
+ const defaultIgnoreProps = ['writing-mode'];
21
+
22
+ function pluginCreator() {
23
+ return {
24
+ postcssPlugin: 'postcss-reduce-initial',
25
+
26
+ prepare(result) {
27
+ const resultOpts = result.opts || {};
28
+ const browsers = (0, _browserslist.default)(null, {
29
+ stats: resultOpts.stats,
30
+ path: __dirname,
31
+ env: resultOpts.env
32
+ });
33
+ const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
34
+ return {
35
+ OnceExit(css) {
36
+ css.walkDecls(decl => {
43
37
  const lowerCasedProp = decl.prop.toLowerCase();
38
+ const ignoreProp = defaultIgnoreProps.concat(resultOpts.ignore || []);
44
39
 
45
- if (initialSupport && (0, _has2.default)(_toInitial2.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial2.default[lowerCasedProp]) {
46
- decl.value = initial;
47
- return;
40
+ if (ignoreProp.includes(lowerCasedProp)) {
41
+ return;
48
42
  }
49
43
 
50
- if (decl.value.toLowerCase() !== initial || !_fromInitial2.default[lowerCasedProp]) {
51
- return;
44
+ if (initialSupport && Object.prototype.hasOwnProperty.call(_toInitial.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial.default[lowerCasedProp]) {
45
+ decl.value = initial;
46
+ return;
52
47
  }
53
48
 
54
- decl.value = _fromInitial2.default[lowerCasedProp];
55
- });
56
- };
57
- });
58
- module.exports = exports['default'];
49
+ if (decl.value.toLowerCase() !== initial || !_fromInitial.default[lowerCasedProp]) {
50
+ return;
51
+ }
52
+
53
+ decl.value = _fromInitial.default[lowerCasedProp];
54
+ });
55
+ }
56
+
57
+ };
58
+ }
59
+
60
+ };
61
+ }
62
+
63
+ pluginCreator.postcss = true;
64
+ var _default = pluginCreator;
65
+ exports.default = _default;
66
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-reduce-initial",
3
- "version": "4.0.3",
3
+ "version": "5.0.0",
4
4
  "description": "Reduce initial definitions to the actual initial value, where possible.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -9,8 +9,10 @@
9
9
  "LICENSE-MIT"
10
10
  ],
11
11
  "scripts": {
12
- "acquire": "babel-node ./src/acquire.js",
13
- "prepublish": "cross-env BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/,src/acquire.js"
12
+ "acquire": "node ./src/acquire.mjs",
13
+ "prebuild": "del-cli dist",
14
+ "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore '**/__tests__/,src/acquire.mjs'",
15
+ "prepublish": "yarn build"
14
16
  },
15
17
  "keywords": [
16
18
  "css",
@@ -18,13 +20,6 @@
18
20
  "postcss-plugin"
19
21
  ],
20
22
  "license": "MIT",
21
- "devDependencies": {
22
- "babel-cli": "^6.0.0",
23
- "cross-env": "^5.0.0",
24
- "got": "^8.0.0",
25
- "html2plaintext": "^2.0.0",
26
- "write-file": "^1.0.0"
27
- },
28
23
  "homepage": "https://github.com/cssnano/cssnano",
29
24
  "author": {
30
25
  "name": "Ben Briggs",
@@ -33,15 +28,20 @@
33
28
  },
34
29
  "repository": "cssnano/cssnano",
35
30
  "dependencies": {
36
- "browserslist": "^4.0.0",
37
- "caniuse-api": "^3.0.0",
38
- "has": "^1.0.0",
39
- "postcss": "^7.0.0"
31
+ "browserslist": "^4.16.0",
32
+ "caniuse-api": "^3.0.0"
40
33
  },
41
34
  "bugs": {
42
35
  "url": "https://github.com/cssnano/cssnano/issues"
43
36
  },
44
37
  "engines": {
45
- "node": ">=6.9.0"
46
- }
38
+ "node": "^10 || ^12 || >=14.0"
39
+ },
40
+ "devDependencies": {
41
+ "postcss": "^8.2.1"
42
+ },
43
+ "peerDependencies": {
44
+ "postcss": "^8.2.1"
45
+ },
46
+ "gitHead": "0e2c3bf5835bafcdc8783bef66f730a24194c8f3"
47
47
  }