postcss-nested
Advanced tools
Comparing version 4.1.2 to 4.2.0
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 4.2 | ||
* Add `@at-root` support (by Jason Quense). | ||
## 4.1.2 | ||
@@ -5,0 +8,0 @@ * Improve error messsage on broken selector |
20
index.js
@@ -73,3 +73,3 @@ var postcss = require('postcss') | ||
children.push(child) | ||
} if (child.type === 'decl') { | ||
} else if (child.type === 'decl') { | ||
children.push(child) | ||
@@ -96,2 +96,3 @@ } else if (child.type === 'rule' && bubbling) { | ||
var after = rule | ||
rule.each(function (child) { | ||
@@ -105,4 +106,19 @@ if (child.type === 'rule') { | ||
} else if (child.type === 'atrule') { | ||
if (bubble[child.name]) { | ||
if (child.name === 'at-root') { | ||
unwrapped = true | ||
atruleChilds(rule, child, false) | ||
var nodes = child.nodes | ||
if (child.params) { | ||
nodes = postcss.rule({ | ||
selector: child.params, | ||
nodes: nodes | ||
}) | ||
} | ||
after.after(nodes) | ||
after = nodes | ||
child.remove() | ||
} else if (bubble[child.name]) { | ||
unwrapped = true | ||
atruleChilds(rule, child, true) | ||
@@ -109,0 +125,0 @@ after = pickComment(child.prev(), after) |
{ | ||
"name": "postcss-nested", | ||
"version": "4.1.2", | ||
"version": "4.2.0", | ||
"description": "PostCSS plugin to unwrap nested rules like how Sass does it", | ||
@@ -16,5 +16,5 @@ "keywords": [ | ||
"dependencies": { | ||
"postcss": "^7.0.14", | ||
"postcss-selector-parser": "^5.0.0" | ||
"postcss": "^7.0.21", | ||
"postcss-selector-parser": "^6.0.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# PostCSS Nested [![Build Status][ci-img]][ci] | ||
# PostCSS Nested | ||
@@ -24,2 +24,11 @@ <img align="right" width="135" height="95" | ||
} | ||
.title { | ||
font-size: var(--font); | ||
@at-root html { | ||
--font: 16px | ||
} | ||
} | ||
} | ||
``` | ||
@@ -44,11 +53,23 @@ | ||
} | ||
.title { | ||
font-size: var(--font); | ||
} | ||
html { | ||
--font: 16px | ||
} | ||
``` | ||
Use [postcss-current-selector] **after** this plugin if you want to use current selector in properties or variables values. | ||
Related plugins: | ||
Use [postcss-nested-ancestors] **before** this plugin if you want to reference any ancestor element directly in your selectors with `^&`. | ||
* Use [`postcss-current-selector`] **after** this plugin if you want | ||
to use current selector in properties or variables values. | ||
* Use [`postcss-nested-ancestors`] **before** this plugin if you want | ||
to reference any ancestor element directly in your selectors with `^&`. | ||
See also [postcss-nesting], which implements [Tab Atkin's proposed syntax](https://tabatkins.github.io/specs/css-nesting/) (requires the `&` and introduces `@nest`). | ||
Alternatives: | ||
There is also [postcss-nested-props] for nested properties like `font-size`. | ||
* See also [`postcss-nesting`], which implements [CSSWG draft] | ||
(requires the `&` and introduces `@nest`). | ||
* [`postcss-nested-props`] for nested properties like `font-size`. | ||
@@ -59,9 +80,8 @@ <a href="https://evilmartians.com/?utm_source=postcss-nested"> | ||
[postcss-current-selector]: https://github.com/komlev/postcss-current-selector | ||
[postcss-nested-ancestors]: https://github.com/toomuchdesign/postcss-nested-ancestors | ||
[postcss-nested-props]: https://github.com/jedmao/postcss-nested-props | ||
[postcss-nesting]: https://github.com/jonathantneal/postcss-nesting | ||
[`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector | ||
[`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors | ||
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props | ||
[`postcss-nesting`]: https://github.com/jonathantneal/postcss-nesting | ||
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/ | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[ci-img]: https://travis-ci.org/postcss/postcss-nested.svg | ||
[ci]: https://travis-ci.org/postcss/postcss-nested | ||
@@ -68,0 +88,0 @@ ## Usage |
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
10823
6
165
172
+ Addedcssesc@3.0.0(transitive)
+ Addedpostcss-selector-parser@6.1.2(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedcssesc@2.0.0(transitive)
- Removedindexes-of@1.0.1(transitive)
- Removedpostcss-selector-parser@5.0.0(transitive)
- Removeduniq@1.0.1(transitive)
Updatedpostcss@^7.0.21