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

postcss-merge-rules

Package Overview
Dependencies
Maintainers
1
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 1.0.0 to 1.1.0

5

CHANGELOG.md

@@ -0,3 +1,8 @@

# 1.1.0
* Less eager moving of properties, to avoid cases where moving a longhand
property would allow a shorthand property to override it.
# 1.0.0
* Initial release.

43

index.js

@@ -14,2 +14,8 @@ 'use strict';

function different (a, b) {
return a.filter(function (c) {
return !~b.indexOf(c);
});
}
function filterPrefixes (selector) {

@@ -89,18 +95,29 @@ return intersect(prefixes, selector);

if (shouldMerge) {
var difference = different(ruleDecls, cacheDecls);
difference = difference.map(function (d) {
return d.split(':')[0].split('-')[0];
});
var recievingBlock = cache.cloneAfter({
selector: joinSelectors(cache, rule),
nodes: []
nodes: [],
before: ''
});
cache.eachInside(function (decl) {
if (~intersection.indexOf('' + decl)) {
decl.moveTo(recievingBlock);
}
});
rule.eachInside(function (decl) {
if (~intersection.indexOf('' + decl)) {
decl.removeSelf();
}
});
// Clean up the original declarations if we removed their rules
[rule, cache].forEach(function (r) {
var moveDecl = function (callback) {
return function (decl) {
var intersects = ~intersection.indexOf('' + decl);
var baseProperty = decl.prop.split('-')[0];
var canMove = !~difference.indexOf(baseProperty);
if (intersects && (canMove || baseProperty === 'text')) {
callback.call(this, decl);
}
};
};
cache.eachInside(moveDecl(function (decl) {
decl.moveTo(recievingBlock);
}));
rule.eachInside(moveDecl(function (decl) {
decl.removeSelf();
}));
// Clean up any rules that have no declarations left
[rule, recievingBlock, cache].forEach(function (r) {
if (!r.nodes.length) {

@@ -107,0 +124,0 @@ r.removeSelf();

{
"name": "postcss-merge-rules",
"version": "1.0.0",
"version": "1.1.0",
"description": "Merge CSS rules 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