Socket
Socket
Sign inDemoInstall

postcss-nested

Package Overview
Dependencies
13
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.1.1

3

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.1.1
* Fix `:not(&)` support.
## 2.1

@@ -5,0 +8,0 @@ * Add `preserveEmpty` option (by Federico Zivolo).

35

index.js
var postcss = require('postcss');
var parser = require('postcss-selector-parser');
function concatNested(selector, parent) {
function replace(nodes, parent) {
var replaced = false;
var nestingNodes = selector.nodes.filter(node => node.type === 'nesting');
nestingNodes.forEach(ampersand => {
ampersand.replaceWith(parent.clone());
replaced = true;
nodes.forEach(function (i) {
if (i.type === 'nesting') {
i.replaceWith(parent.clone());
replaced = true;
} else if (i.nodes) {
replaced = replaced || replace(i.nodes, parent);
}
});
if (!replaced) {
selector.prepend(parser.combinator({ value: ' ' }));
selector.prepend(parent.clone());
}
return selector;
return replaced;
}
function selectors(parent, node) {
function selectors(parent, child) {
var result = [];
parent.selectors.forEach(function (i) {
var parsed = parser().process(i).res.first;
var parentNode = parser().process(i).res.first;
node.selectors.forEach(function (j) {
result.push(concatNested(parser().process(j).res.first, parsed));
child.selectors.forEach(function (j) {
var node = parser().process(j).res.first;
var replaced = replace(node.nodes, parentNode);
if (!replaced) {
node.prepend(parser.combinator({ value: ' ' }));
node.prepend(parentNode.clone());
}
result.push(node.toString());
});

@@ -28,0 +31,0 @@ });

{
"name": "postcss-nested",
"version": "2.1.0",
"version": "2.1.1",
"description": "PostCSS plugin to unwrap nested rules like how Sass does it.",

@@ -16,7 +16,7 @@ "keywords": [

"dependencies": {
"postcss": "^6.0.8",
"postcss": "^6.0.9",
"postcss-selector-parser": "^2.2.3"
},
"devDependencies": {
"eslint": "^4.3.0",
"eslint": "^4.4.1",
"eslint-config-postcss": "^2.0.2",

@@ -23,0 +23,0 @@ "jest": "^20.0.4"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc