Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-discard-empty

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-discard-empty - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

5

CHANGELOG.md

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

# 1.1.2
* Increased performance by iterating the AST in a single pass.
(thanks @andyjansson)
# 1.1.1

@@ -2,0 +7,0 @@

32

index.js
'use strict';
var postcss = require('postcss');
function remove (callback) {
return function (node) {
callback.call(this, node) && node.removeSelf();
};
function discardEmpty(node) {
if (node.nodes) { node.each(discardEmpty); }
if (
(node.type === 'decl' && !node.value) ||
(node.type === 'rule' && !node.selector || (node.nodes && !node.nodes.length)) ||
(node.type === 'atrule' && ((!node.nodes && !node.params) || (!node.params && !node.nodes.length)))
) {
node.removeSelf();
}
}
module.exports = postcss.plugin('postcss-discard-empty', function () {
return function (css) {
css.eachDecl(remove(function (decl) {
return !decl.value;
}));
css.eachRule(remove(function (rule) {
return !rule.selector.length || !rule.nodes.length;
}));
css.eachAtRule(remove(function (rule) {
if (rule.nodes) {
return !rule.nodes.length;
}
return !rule.params;
}));
};
return function (css) {
css.each(discardEmpty);
};
});
{
"name": "postcss-discard-empty",
"version": "1.1.1",
"version": "1.1.2",
"description": "Discard empty rules and values with PostCSS.",

@@ -5,0 +5,0 @@ "main": "index.js",

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