postcss-nested
Advanced tools
Comparing version 2.1.2 to 3.0.0
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 3.0 | ||
* Add `@font-face` to bubbling at-rules (by Valeriy Komlev). | ||
* Add special logic for `@font-face` bubbling (by Phanindra Pydisetty). | ||
* Use PostCSS selector parser 3.0. | ||
## 2.1.2 | ||
@@ -5,0 +10,0 @@ * Fix replacing multiple `&`. |
23
index.js
var postcss = require('postcss'); | ||
var parser = require('postcss-selector-parser'); | ||
function parse(str) { | ||
var nodes; | ||
var saver = parser(function (parsed) { | ||
nodes = parsed; | ||
}); | ||
saver.processSync(str); | ||
return nodes.at(0); | ||
} | ||
function replace(nodes, parent) { | ||
var replaced = false; | ||
nodes.forEach(function (i) { | ||
nodes.each(function (i) { | ||
if (i.type === 'nesting') { | ||
@@ -11,3 +20,3 @@ i.replaceWith(parent.clone()); | ||
} else if (i.nodes) { | ||
if (replace(i.nodes, parent)) { | ||
if (replace(i, parent)) { | ||
replaced = true; | ||
@@ -23,7 +32,7 @@ } | ||
parent.selectors.forEach(function (i) { | ||
var parentNode = parser().process(i).res.first; | ||
var parentNode = parse(i); | ||
child.selectors.forEach(function (j) { | ||
var node = parser().process(j).res.first; | ||
var replaced = replace(node.nodes, parentNode); | ||
var node = parse(j); | ||
var replaced = replace(node, parentNode); | ||
if (!replaced) { | ||
@@ -61,2 +70,4 @@ node.prepend(parser.combinator({ value: ' ' })); | ||
}); | ||
if ( atrule.name === 'font-face' ) return; | ||
if ( children.length ) { | ||
@@ -98,3 +109,3 @@ var clone = rule.clone({ nodes: [] }); | ||
module.exports = postcss.plugin('postcss-nested', function (opts) { | ||
var bubble = ['media', 'supports', 'document']; | ||
var bubble = ['media', 'supports', 'document', 'font-face']; | ||
if ( opts && opts.bubble ) { | ||
@@ -101,0 +112,0 @@ bubble = bubble.concat(opts.bubble.map(function (i) { |
{ | ||
"name": "postcss-nested", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "PostCSS plugin to unwrap nested rules like how Sass does it.", | ||
@@ -16,9 +16,10 @@ "keywords": [ | ||
"dependencies": { | ||
"postcss": "^6.0.9", | ||
"postcss-selector-parser": "^2.2.3" | ||
"postcss": "^6.0.14", | ||
"postcss-selector-parser": "^3.1.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.4.1", | ||
"eslint": "^4.13.0", | ||
"eslint-ci": "^0.1.1", | ||
"eslint-config-postcss": "^2.0.2", | ||
"jest": "^20.0.4" | ||
"jest": "^21.2.1" | ||
}, | ||
@@ -33,3 +34,3 @@ "jest": { | ||
"scripts": { | ||
"test": "jest --coverage && eslint *.js" | ||
"test": "jest --coverage && eslint-ci *.js" | ||
}, | ||
@@ -36,0 +37,0 @@ "eslintConfig": { |
@@ -77,3 +77,3 @@ # PostCSS Nested [![Build Status][ci-img]][ci] | ||
By default, plugin will unwrap only `@media`, `@supports` and `@document` | ||
By default, plugin will unwrap only `@media`, `@supports`, `@font-face` and `@document | ||
at-rules. You can add your custom at-rules to this list by `bubble` option: | ||
@@ -80,0 +80,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9526
114
4
+ Addeddot-prop@5.3.0(transitive)
+ Addedis-obj@2.0.0(transitive)
+ Addedpostcss-selector-parser@3.1.2(transitive)
- Removedflatten@1.0.3(transitive)
- Removedpostcss-selector-parser@2.2.3(transitive)
Updatedpostcss@^6.0.14