postcss-convert-values 5.0.0-rc.1 → 5.0.2

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/dist/index.js CHANGED
@@ -11,11 +11,15 @@ var _convert = _interopRequireDefault(require("./lib/convert"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
 
16
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
 
18
- const LENGTH_UNITS = ['em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', 'cm', 'mm', 'q', 'in', 'pt', 'pc', 'px'];
18
+ const LENGTH_UNITS = ['em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', 'cm', 'mm', 'q', 'in', 'pt', 'pc', 'px']; // These properties only accept percentages, so no point in trying to transform
19
+
20
+ const notALength = new Set(['descent-override', 'ascent-override', 'font-stretch', 'size-adjust', 'line-gap-override']); // Can't change the unit on these properties when they're 0
21
+
22
+ const keepWhenZero = new Set(['stroke-dashoffset', 'stroke-width', 'line-height']);
19
23
  /*
20
24
  * Numbers without digits after the dot are technically invalid,
21
25
  * but in that case css-value-parser returns the dot as part of the unit,
@@ -66,18 +70,18 @@ function clampOpacity(node) {
66
70
  }
67
71
  }
68
72
 
69
- function shouldKeepUnit(decl) {
73
+ function shouldKeepZeroUnit(decl) {
70
74
  const {
71
75
  parent
72
76
  } = decl;
73
77
  const lowerCasedProp = decl.prop.toLowerCase();
74
- return ~decl.value.indexOf('%') && (lowerCasedProp === 'max-height' || lowerCasedProp === 'height') || parent.parent && parent.parent.name && parent.parent.name.toLowerCase() === 'keyframes' && lowerCasedProp === 'stroke-dasharray' || lowerCasedProp === 'stroke-dashoffset' || lowerCasedProp === 'stroke-width' || lowerCasedProp === 'line-height';
78
+ return ~decl.value.indexOf('%') && (lowerCasedProp === 'max-height' || lowerCasedProp === 'height') || parent.parent && parent.parent.name && parent.parent.name.toLowerCase() === 'keyframes' && lowerCasedProp === 'stroke-dasharray' || keepWhenZero.has(lowerCasedProp);
75
79
  }
76
80
 
77
81
  function transform(opts, decl) {
78
82
  const lowerCasedProp = decl.prop.toLowerCase();
79
83
 
80
- if (~lowerCasedProp.indexOf('flex') || lowerCasedProp.indexOf('--') === 0) {
84
+ if (~lowerCasedProp.indexOf('flex') || lowerCasedProp.indexOf('--') === 0 || notALength.has(lowerCasedProp)) {
81
85
  return;
82
86
  }
83
87
 
@@ -85,7 +89,7 @@ function transform(opts, decl) {
85
89
  const lowerCasedValue = node.value.toLowerCase();
86
90
 
87
91
  if (node.type === 'word') {
88
- parseWord(node, opts, shouldKeepUnit(decl));
92
+ parseWord(node, opts, shouldKeepZeroUnit(decl));
89
93
 
90
94
  if (lowerCasedProp === 'opacity' || lowerCasedProp === 'shape-image-threshold') {
91
95
  clampOpacity(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-convert-values",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.2",
4
4
  "description": "Convert values with PostCSS (e.g. ms -> s)",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -8,9 +8,9 @@
8
8
  "dist"
9
9
  ],
10
10
  "scripts": {
11
- "prebuild": "del-cli dist",
12
- "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore \"**/__tests__/\"",
13
- "prepublish": "yarn build"
11
+ "prebuild": "rimraf dist",
12
+ "build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.json --out-dir dist --ignore \"**/__tests__/\"",
13
+ "prepare": "yarn build"
14
14
  },
15
15
  "keywords": [
16
16
  "css",
@@ -36,10 +36,10 @@
36
36
  "node": "^10 || ^12 || >=14.0"
37
37
  },
38
38
  "devDependencies": {
39
- "postcss": "^8.2.1"
39
+ "postcss": "^8.2.15"
40
40
  },
41
41
  "peerDependencies": {
42
- "postcss": "^8.2.1"
42
+ "postcss": "^8.2.15"
43
43
  },
44
- "gitHead": "114efb0092fff944dd4c8a28d184add24d8fde3e"
44
+ "gitHead": "2d84646671c7075f8dae35de310351aac3436bc0"
45
45
  }
package/CHANGELOG.md DELETED
@@ -1,47 +0,0 @@
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-rc.1](https://github.com/cssnano/cssnano/compare/postcss-convert-values@5.0.0-rc.0...postcss-convert-values@5.0.0-rc.1) (2021-03-04)
7
-
8
- **Note:** Version bump only for package postcss-convert-values
9
-
10
-
11
-
12
-
13
-
14
- # 5.0.0-rc.0 (2021-02-19)
15
-
16
-
17
- ### Bug Fixes
18
-
19
- * Keep math functions together ([#895](https://github.com/cssnano/cssnano/issues/895)) ([4ddf843](https://github.com/cssnano/cssnano/commit/4ddf843ca5dc64059f488113224e76165211a669))
20
- * preservation of opacities defined as percentages ([#881](https://github.com/cssnano/cssnano/issues/881)) ([fd7b878](https://github.com/cssnano/cssnano/commit/fd7b878e72ed9bd20c145c9e2daa7b5d48cb1117))
21
- * units being removed in math functions ([#894](https://github.com/cssnano/cssnano/issues/894)) ([1ccbd5b](https://github.com/cssnano/cssnano/commit/1ccbd5b29e1b2121efaf7b24a69aa782848966dc))
22
- * **postcss-convert-values:** prevent zero units from being dropped in line-height. ([#801](https://github.com/cssnano/cssnano/issues/801)) ([d781855](https://github.com/cssnano/cssnano/commit/d78185567ae5ebcde0469cf0e55145a7a3130d3e))
23
-
24
-
25
- ### chore
26
-
27
- * minimum require version of node is 10.13 ([#871](https://github.com/cssnano/cssnano/issues/871)) ([28bda24](https://github.com/cssnano/cssnano/commit/28bda243e32ce3ba89b3c358a5f78727b3732f11))
28
-
29
-
30
- ### Features
31
-
32
- * migarete to PostCSS 8 ([#975](https://github.com/cssnano/cssnano/issues/975)) ([40b82dc](https://github.com/cssnano/cssnano/commit/40b82dca7f53ac02cd4fe62846dec79b898ccb49))
33
-
34
-
35
- ### BREAKING CHANGES
36
-
37
- * minimum supported `postcss` version is `8.2.1`
38
- * minimum require version of node is 10.13
39
-
40
-
41
-
42
- ## 4.1.1 (2018-09-24)
43
-
44
-
45
- ### Bug Fixes
46
-
47
- * **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)