Socket
Socket
Sign inDemoInstall

postcss-merge-rules

Package Overview
Dependencies
Maintainers
8
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-merge-rules - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

7

package.json
{
"name": "postcss-merge-rules",
"version": "5.1.1",
"version": "5.1.2",
"description": "Merge CSS rules with PostCSS.",

@@ -41,8 +41,7 @@ "types": "types/index.d.ts",

"postcss": "^8.2.15",
"postcss-discard-comments": "^5.1.0"
"postcss-discard-comments": "^5.1.2"
},
"peerDependencies": {
"postcss": "^8.2.15"
},
"readme": "# [postcss][postcss]-merge-rules\n\n> Merge CSS rules with PostCSS.\n\n## Install\n\nWith [npm](https://npmjs.org/package/postcss-merge-rules) do:\n\n```\nnpm install postcss-merge-rules --save\n```\n\n## Examples\n\nThis module will attempt to merge *adjacent* CSS rules:\n\n### By declarations\n\n#### Input\n\n```css\na {\n color: blue;\n font-weight: bold\n}\n\np {\n color: blue;\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na,p {\n color: blue;\n font-weight: bold\n}\n```\n\n### By selectors\n\n#### Input\n\n```css\na {\n color: blue\n}\n\na {\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na {\n color: blue;\n font-weight: bold\n}\n```\n\n### By partial declarations\n\n#### Input\n\n```css\na {\n font-weight: bold\n}\n\np {\n color: blue;\n font-weight: bold\n}\n```\n\n#### Output\n\n```css\na,p {\n font-weight: bold\n}\n\np {\n color: blue\n}\n```\n\n## Usage\n\nSee the [PostCSS documentation](https://github.com/postcss/postcss#usage) for\nexamples for your environment.\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n\n## License\n\nMIT © [Ben Briggs](http://beneb.info)\n\n[postcss]: https://github.com/postcss/postcss\n"
}
}

@@ -39,3 +39,3 @@ 'use strict';

return a.filter((c) => {
const index = ~indexOfDeclaration(b, c);
const index = indexOfDeclaration(b, c) !== -1;
return not ? !index : index;

@@ -78,4 +78,10 @@ });

);
const { name } = /** @type {any} */ (ruleA).parent;
if (parent && name && name.includes('keyframes')) {
if (
parent &&
ruleA.parent &&
ruleA.parent.type === 'atrule' &&
/** @type {import('postcss').AtRule} */ (ruleA.parent).name.includes(
'keyframes'
)
) {
return false;

@@ -87,2 +93,9 @@ }

/**
* @param {import('postcss').ChildNode} node
* @return {node is import('postcss').Declaration}
*/
function isDeclaration(node) {
return node.type === 'decl';
}
/**
* @param {import('postcss').Rule} rule

@@ -92,5 +105,3 @@ * @return {import('postcss').Declaration[]}

function getDecls(rule) {
return /** @type {import('postcss').Declaration[]} */ (
rule.nodes.filter((node) => node.type === 'decl')
);
return rule.nodes.filter(isDeclaration);
}

@@ -297,3 +308,3 @@

return (decl) => {
if (~indexOfDeclaration(intersection, decl)) {
if (indexOfDeclaration(intersection, decl) !== -1) {
callback.call(this, decl);

@@ -367,13 +378,8 @@ }

const cached = getDecls(cache);
rule.walk((decl) => {
if (
~indexOfDeclaration(
cached,
/** @type {import('postcss').Declaration} */ (decl)
)
) {
decl.remove();
rule.walk((node) => {
if (node.type === 'decl' && indexOfDeclaration(cached, node) !== -1) {
node.remove();
return;
}
/** @type {import('postcss').Rule} */ (cache).append(decl);
/** @type {import('postcss').Rule} */ (cache).append(node);
});

@@ -380,0 +386,0 @@ rule.remove();

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