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.1.1 to 2.1.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 2.1.2
* Performance improvements; no compatibility checking for simple selectors,
cached compatibility lookups, and early exit on compatibility mismatches
(thanks to @akx).
# 2.1.1

@@ -2,0 +8,0 @@

37

dist/index.js

@@ -5,4 +5,2 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _browserslist = require('browserslist');

@@ -69,3 +67,3 @@

function canMerge(ruleA, ruleB, browsers) {
function canMerge(ruleA, ruleB, browsers, compatibilityCache) {
var a = ruleA.selectors;

@@ -76,3 +74,3 @@ var b = ruleB.selectors;

if (!(0, _ensureCompatibility2.default)(selectors, browsers)) {
if (!(0, _ensureCompatibility2.default)(selectors, browsers, compatibilityCache)) {
return false;

@@ -220,3 +218,3 @@ }

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

@@ -226,3 +224,3 @@ return function (rule) {

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

@@ -248,17 +246,11 @@ return;

if (cache.selector === rule.selector) {
var _ret = function () {
var cached = getDecls(cache);
rule.walk(function (decl) {
if (~cached.indexOf(String(decl))) {
return decl.remove();
}
decl.moveTo(cache);
});
rule.remove();
return {
v: void 0
};
}();
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
var cached = getDecls(cache);
rule.walk(function (decl) {
if (~cached.indexOf(String(decl))) {
return decl.remove();
}
decl.moveTo(cache);
});
rule.remove();
return;
}

@@ -280,5 +272,6 @@ // Partial merge: check if the rule contains a subset of the last; if

});
css.walkRules(selectorMerger(browsers));
var compatibilityCache = {};
css.walkRules(selectorMerger(browsers, compatibilityCache));
};
});
module.exports = exports['default'];

@@ -15,2 +15,4 @@ 'use strict';

var simpleSelectorRe = /^#?[-._a-z0-9 ]+$/i;
var cssSel2 = 'css-sel2';

@@ -73,3 +75,3 @@ var cssSel3 = 'css-sel3';

function ensureCompatibility(selectors, browsers) {
function ensureCompatibility(selectors, browsers, compatibilityCache) {
// Should not merge mixins

@@ -80,2 +82,8 @@ if (selectors.some(isCssMixin)) {

return selectors.every(function (selector) {
if (simpleSelectorRe.test(selector)) {
return true;
}
if (compatibilityCache && selector in compatibilityCache) {
return compatibilityCache[selector];
}
var compatible = true;

@@ -123,6 +131,14 @@ (0, _postcssSelectorParser2.default)(function (ast) {

}
if (!compatible) {
// If this node was not compatible,
// break out early from walking the rest
return false;
}
});
}).process(selector);
if (compatibilityCache) {
compatibilityCache[selector] = compatible;
}
return compatible;
});
}
{
"name": "postcss-merge-rules",
"version": "2.1.1",
"version": "2.1.2",
"description": "Merge CSS rules with PostCSS.",

@@ -5,0 +5,0 @@ "main": "dist/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