Socket
Socket
Sign inDemoInstall

postcss-reduce-initial

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-reduce-initial - npm Package Compare versions

Comparing version 1.0.1 to 4.0.0-nightly.2020.1.9

data/fromInitial.json

67

dist/index.js

@@ -1,25 +0,58 @@

'use strict';
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _postcss = require('postcss');
var _postcss = require("postcss");
var _values = require('../data/values.json');
var _has = _interopRequireDefault(require("has"));
var _values2 = _interopRequireDefault(_values);
var _browserslist = _interopRequireDefault(require("browserslist"));
var _caniuseApi = require("caniuse-api");
var _fromInitial = _interopRequireDefault(require("../data/fromInitial.json"));
var _toInitial = _interopRequireDefault(require("../data/toInitial.json"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _postcss.plugin)('postcss-reduce-initial', function () {
return function (css) {
css.walkDecls(function (decl) {
if (decl.value !== 'initial') {
return;
}
if (_values2.default[decl.prop]) {
decl.value = _values2.default[decl.prop];
}
});
};
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', () => {
return (css, result) => {
const resultOpts = result.opts || {};
const browsers = (0, _browserslist.default)(null, {
stats: resultOpts.stats,
path: __dirname,
env: resultOpts.env
});
const initialSupport = (0, _caniuseApi.isSupported)('css-initial-value', browsers);
css.walkDecls(decl => {
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]) {
decl.value = initial;
return;
}
if (decl.value.toLowerCase() !== initial || !_fromInitial.default[lowerCasedProp]) {
return;
}
decl.value = _fromInitial.default[lowerCasedProp];
});
};
});
module.exports = exports['default'];
exports.default = _default;
module.exports = exports.default;
{
"name": "postcss-reduce-initial",
"version": "1.0.1",
"version": "4.0.0-nightly.2020.1.9",
"description": "Reduce initial definitions to the actual initial value, where possible.",

@@ -12,9 +12,6 @@ "main": "dist/index.js",

"scripts": {
"acquire": "node ./dist/acquire.js > ./data/values.json",
"contributorAdd": "all-contributors add",
"contributorGenerate": "all-contributors generate",
"pretest": "eslint src",
"prepublish": "del-cli dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/",
"test": "ava",
"test-012": "ava"
"acquire": "babel-node ./src/acquire.js",
"prebuild": "",
"build": "cross-env BABEL_ENV=publish babel src --config-file ../../babel.config.js --out-dir dist --ignore '**/__tests__/,src/acquire.js'",
"prepublish": ""
},

@@ -27,22 +24,3 @@ "keywords": [

"license": "MIT",
"devDependencies": {
"all-contributors-cli": "^3.0.5",
"ava": "^0.17.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.9.0",
"del-cli": "^0.2.0",
"eslint": "^3.0.0",
"eslint-config-cssnano": "^3.0.0",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^2.0.1",
"got": "^6.3.0",
"html2plaintext": "^1.0.1",
"is-html": "^1.0.0"
},
"homepage": "https://github.com/ben-eb/postcss-reduce-initial",
"homepage": "https://github.com/cssnano/cssnano",
"author": {

@@ -53,12 +31,15 @@ "name": "Ben Briggs",

},
"repository": "ben-eb/postcss-reduce-initial",
"repository": "cssnano/cssnano",
"dependencies": {
"postcss": "^5.0.4"
"browserslist": "^4.5.6",
"caniuse-api": "^3.0.0",
"has": "^1.0.3",
"postcss": "^7.0.16"
},
"ava": {
"require": "babel-register"
"bugs": {
"url": "https://github.com/cssnano/cssnano/issues"
},
"eslintConfig": {
"extends": "cssnano"
"engines": {
"node": ">=10.13.0"
}
}
}

@@ -1,6 +0,5 @@

# [postcss][postcss]-reduce-initial [![Build Status](https://travis-ci.org/ben-eb/postcss-reduce-initial.svg?branch=master)][ci] [![NPM version](https://badge.fury.io/js/postcss-reduce-initial.svg)][npm] [![Dependency Status](https://gemnasium.com/ben-eb/postcss-reduce-initial.svg)][deps]
# [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,30 +13,66 @@

## Examples
## Example
See the [data](data) for more conversions. This data is courtesy
of Mozilla.
This module will replace the `initial` CSS keyword with the *actual* value,
when this value is smaller than the `initial` definition itself. For example,
the initial value for the `min-width` property is `0`; therefore, these two
definitions are equivalent;
### Convert `initial` values
### Input
When the `initial` keyword is longer than the property value, it will
be converted:
#### Input
```css
h1 {
min-width: initial;
min-width: initial;
}
```
### Output
#### Output
```css
h1 {
min-width: 0;
min-width: 0;
}
```
See the [data](data/values.json) for more conversions. This data is courtesy
of Mozilla.
### Convert values back to `initial`
When the `initial` value is smaller than the property value, it will
be converted:
#### Input
```css
h1 {
transform-box: border-box;
}
```
#### Output
```css
h1 {
transform-box: initial;
}
```
This conversion is only applied when you supply a browsers list that all support
the `initial` keyword; it's worth noting that Internet Explorer has no support.
## 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

@@ -48,16 +83,6 @@

## Contributors
Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<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-reduce-initial/commits?author=ben-eb) [📖](https://github.com/ben-eb/postcss-reduce-initial/commits?author=ben-eb) 👀 [⚠️](https://github.com/ben-eb/postcss-reduce-initial/commits?author=ben-eb) | [<img src="https://avatars.githubusercontent.com/u/551712?v=3" width="100px;"/><br /><sub>Chris Walker</sub>](http://thechriswalker.github.com/)<br />[🐛](https://github.com/ben-eb/postcss-reduce-initial/issues?q=author%3Athechriswalker) [💻](https://github.com/ben-eb/postcss-reduce-initial/commits?author=thechriswalker) |
| :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors] specification. Contributions of
any kind welcome!
## License

@@ -67,12 +92,7 @@

[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/
MIT © [Ben Briggs](http://beneb.info)
[all-contributors]: https://github.com/kentcdodds/all-contributors
[ci]: https://travis-ci.org/ben-eb/postcss-reduce-initial
[deps]: https://gemnasium.com/ben-eb/postcss-reduce-initial
[npm]: http://badge.fury.io/js/postcss-reduce-initial
[postcss]: https://github.com/postcss/postcss
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc