postcss-reduce-initial
Advanced tools
Comparing version
@@ -22,4 +22,6 @@ "use strict"; | ||
const initial = 'initial'; | ||
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 | ||
const defaultIgnoreProps = ['writing-mode']; | ||
var _default = (0, _postcss.plugin)('postcss-reduce-initial', () => { | ||
@@ -36,3 +38,8 @@ return (css, result) => { | ||
const lowerCasedProp = decl.prop.toLowerCase(); | ||
const ignoreProp = defaultIgnoreProps.concat(resultOpts.ignore || []); | ||
if (ignoreProp.includes(lowerCasedProp)) { | ||
return; | ||
} | ||
if (initialSupport && (0, _has.default)(_toInitial.default, lowerCasedProp) && decl.value.toLowerCase() === _toInitial.default[lowerCasedProp]) { | ||
@@ -39,0 +46,0 @@ decl.value = initial; |
{ | ||
"name": "postcss-reduce-initial", | ||
"version": "4.0.0-nightly.2020.7.31", | ||
"version": "4.0.0-nightly.2020.8.1", | ||
"description": "Reduce initial definitions to the actual initial value, where possible.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# [postcss][postcss]-reduce-initial | ||
> Reduce `initial` definitions to the *actual* initial value, where possible. | ||
> Reduce `initial` definitions to the _actual_ initial value, where possible. | ||
## Install | ||
@@ -14,3 +13,2 @@ | ||
## Examples | ||
@@ -30,3 +28,3 @@ | ||
h1 { | ||
min-width: initial; | ||
min-width: initial; | ||
} | ||
@@ -39,7 +37,6 @@ ``` | ||
h1 { | ||
min-width: 0; | ||
min-width: 0; | ||
} | ||
``` | ||
### Convert values back to `initial` | ||
@@ -54,3 +51,3 @@ | ||
h1 { | ||
transform-box: border-box; | ||
transform-box: border-box; | ||
} | ||
@@ -63,3 +60,3 @@ ``` | ||
h1 { | ||
transform-box: initial; | ||
transform-box: initial; | ||
} | ||
@@ -71,3 +68,16 @@ ``` | ||
## API | ||
### reduceInitial([options]) | ||
#### options | ||
##### ignore | ||
Type: `Array<String>` | ||
Default: `undefined` | ||
It contains the Array of properties that will be ignored while reducing its value to initial. | ||
Example : `{ ignore : ["min-height"] }` | ||
## Usage | ||
@@ -78,3 +88,2 @@ | ||
## Contributors | ||
@@ -84,3 +93,2 @@ | ||
## License | ||
@@ -90,4 +98,4 @@ | ||
[Template:CSSData]: https://developer.mozilla.org/en-US/docs/Template:CSSData | ||
[CC-BY-SA 2.5]: http://creativecommons.org/licenses/by-sa/2.5/ | ||
[template:cssdata]: https://developer.mozilla.org/en-US/docs/Template:CSSData | ||
[cc-by-sa 2.5]: http://creativecommons.org/licenses/by-sa/2.5/ | ||
@@ -94,0 +102,0 @@ MIT © [Ben Briggs](http://beneb.info) |
14955
3.98%357
1.42%96
9.09%