Socket
Socket
Sign inDemoInstall

postcss-nesting

Package Overview
Dependencies
1
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.2.0

lib/get-closest-rule.js

16

CHANGELOG.md
# Changes to PostCSS Nesting
### 4.2.0 (September 18, 2017)
- Added: Reduced splitting of rules
### 4.1.0 (August 19, 2017)
- Improve complex selector validity testing
- Use mutation-safe walk method
- A special thanks to @JLHwung for these improvements
- Added: Mutation-safe walk method
- Improved: Complex selector validity testing
- Thanks: A special thanks to @JLHwung for these improvements
### 4.0.1 (May 22, 2017)
- Improve selector validity testing
- Improved: Selector validity testing
### 4.0.0 (May 20, 2017)
- Transform only compliant nesting
- Preserve more raws formatting
- Changed: Transform only compliant nesting
- Added: Preserve more raws formatting

@@ -18,0 +22,0 @@ ### 3.0.0 (May 8, 2017)

@@ -11,9 +11,11 @@ // tooling

// insert an empty parent clone after the parent
const emptyParentClone = cleanNode(node.parent.clone()).removeAll();
const afterParent = cleanNode(node.parent.clone()).removeAll();
node.parent.after(emptyParentClone);
node.parent.after(afterParent);
// append the affected nodes to the empty parent clone
emptyParentClone.append(affectedNodes);
afterParent.append(affectedNodes);
return afterParent;
}
};
// tooling
const cleanNode = require('./clean-node');
const comma = require('postcss').list.comma;
const getClosestRule = require('./get-closest-rule');
const mergeSelectors = require('./merge-selectors');

@@ -14,8 +15,11 @@ const postcss = require('postcss');

// affected nodes after the current node moved into a cloned parent node
transformAfterNodes(node);
const afterParent = transformAfterNodes(node);
// get the closest rule
const selectorParent = getClosestRule(node);
// clone of the atrule as a rule
const rule = postcss.rule({
// merge selectors
selectors: mergeSelectors(node.parent.selectors, node.params),
selectors: mergeSelectors(selectorParent && selectorParent.selectors || '', node.params),
source: node.source

@@ -41,2 +45,18 @@ });

// if the next sibling shares the same selector
if (afterParent && afterParent.selector === rule.selector) {
rule.append(afterParent.nodes);
afterParent.remove();
}
// if the previous sibling shares the same selector
if (parent.parent && parent.next() === rule && parent.selector === rule.selector) {
parent.append(rule.nodes);
rule.remove();
return parent;
}
return rule;

@@ -43,0 +63,0 @@ };

{
"name": "postcss-nesting",
"version": "4.1.0",
"version": "4.2.0",
"description": "Nest style and media rules inside each another, following the CSS Nesting Module Level 3 specification",

@@ -26,8 +26,8 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>",

"dependencies": {
"postcss": "^6.0.1"
"postcss": "^6.0.11"
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint": "^4.7.0",
"eslint-config-dev": "^2.0.0",
"postcss-tape": "^2.0.1",
"postcss-tape": "^2.1.0",
"pre-commit": "^1.2.2"

@@ -34,0 +34,0 @@ },

# PostCSS Nesting [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
[![CSS Standard Status][css-img]][css-url]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Licensing][lic-img]][lic-url]
[![Changelog][log-img]][log-url]
[![Gitter Chat][git-img]][git-url]
[PostCSS Nesting] lets you nest style rules inside each other, following the
[CSS Nesting Module Level 3] specification.
[CSS Nesting] specification.

@@ -115,18 +115,17 @@ ```css

[npm-url]: https://www.npmjs.com/package/postcss-nesting
[npm-img]: https://img.shields.io/npm/v/postcss-nesting.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-nesting
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-nesting.svg
[css-img]: https://jonathantneal.github.io/css-db/badge/css-nesting.svg
[css-url]: https://jonathantneal.github.io/css-db/#css-nesting
[git-url]: https://gitter.im/postcss/postcss
[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg
[lic-url]: LICENSE.md
[lic-img]: https://img.shields.io/npm/l/postcss-nesting.svg
[log-url]: CHANGELOG.md
[log-img]: https://img.shields.io/badge/changelog-md-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg
[npm-url]: https://www.npmjs.com/package/postcss-nesting
[npm-img]: https://img.shields.io/npm/v/postcss-nesting.svg
[PostCSS Nesting]: https://github.com/jonathantneal/postcss-nesting
[PostCSS]: https://github.com/postcss/postcss
[CSS Nesting]: http://tabatkins.github.io/specs/css-nesting/
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[CSS Nesting Module Level 3]: http://tabatkins.github.io/specs/css-nesting/
[PostCSS]: https://github.com/postcss/postcss
[PostCSS Nesting]: https://github.com/jonathantneal/postcss-nesting
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc