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

postcss-merge-rules

Package Overview
Dependencies
Maintainers
2
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 2.0.11 to 2.1.0

dist/lib/ensureCompatibility.js

9

CHANGELOG.md

@@ -0,1 +1,10 @@

# 2.1.0
* Rules are now merged based on supported browsers, which uses `browserslist`
& `caniuse-api`. The browsers should be supplied by the standard means of
[configuring `browserslist`][browserslist], either using config files or
via environment variables.
[browserslist]: https://github.com/ai/browserslist#config-file
# 2.0.11

@@ -2,0 +11,0 @@

39

dist/index.js

@@ -7,2 +7,6 @@ 'use strict';

var _browserslist = require('browserslist');
var _browserslist2 = _interopRequireDefault(_browserslist);
var _postcss = require('postcss');

@@ -20,6 +24,8 @@

var _ensureCompatibility = require('./lib/ensureCompatibility');
var _ensureCompatibility2 = _interopRequireDefault(_ensureCompatibility);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var list = _postcss2.default.list;
var prefixes = _vendors2.default.map(function (v) {

@@ -64,6 +70,12 @@ return '-' + v + '-';

function canMerge(ruleA, ruleB) {
var a = list.comma(ruleA.selector);
var b = list.comma(ruleB.selector);
function canMerge(ruleA, ruleB, browsers) {
var a = ruleA.selectors;
var b = ruleB.selectors;
var selectors = a.concat(b);
if (!(0, _ensureCompatibility2.default)(selectors, browsers)) {
return false;
}
var parent = sameParent(ruleA, ruleB);

@@ -75,3 +87,3 @@ var name = ruleA.parent.name;

}
return parent && (a.concat(b).every(noVendor) || sameVendor(a, b));
return parent && (selectors.every(noVendor) || sameVendor(a, b));
}

@@ -209,3 +221,3 @@

function selectorMerger() {
function selectorMerger(browsers) {
var cache = null;

@@ -215,3 +227,3 @@ return function (rule) {

// safe to merge both declarations before continuing
if (!cache || !canMerge(rule, cache)) {
if (!cache || !canMerge(rule, cache, browsers)) {
cache = rule;

@@ -260,6 +272,13 @@ return;

exports.default = _postcss2.default.plugin('postcss-merge-rules', function () {
return function (css) {
return css.walkRules(selectorMerger());
return function (css, result) {
var opts = result.opts;
var browsers = (0, _browserslist2.default)(null, {
stats: opts && opts.stats,
path: opts && opts.from,
env: opts && opts.env
});
css.walkRules(selectorMerger(browsers));
};
});
module.exports = exports['default'];
{
"name": "postcss-merge-rules",
"version": "2.0.11",
"version": "2.1.0",
"description": "Merge CSS rules with PostCSS.",

@@ -34,2 +34,3 @@ "main": "dist/index.js",

"babel-register": "^6.9.0",
"browserslist": "^1.5.2",
"cross-env": "^2.0.1",

@@ -53,3 +54,5 @@ "del-cli": "^0.2.0",

"dependencies": {
"caniuse-api": "^1.5.2",
"postcss": "^5.0.4",
"postcss-selector-parser": "^2.2.2",
"vendors": "^1.0.0"

@@ -66,3 +69,17 @@ },

"instrument": false
},
"browserslist": {
"chrome58": [
"Chrome 58"
],
"edge15": [
"Edge 15"
],
"ie6": [
"IE 6"
],
"ie7": [
"IE 7"
]
}
}
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