postcss-nested
Advanced tools
Comparing version 6.0.1 to 6.2.0
36
index.js
@@ -1,2 +0,2 @@ | ||
const { Rule, AtRule } = require('postcss') | ||
const { AtRule, Rule } = require('postcss') | ||
let parser = require('postcss-selector-parser') | ||
@@ -121,4 +121,4 @@ | ||
let parent = new Rule({ | ||
selector, | ||
nodes: [] | ||
nodes: [], | ||
selector | ||
}) | ||
@@ -147,3 +147,3 @@ parent.append(declarations) | ||
if (!braceBlock) { | ||
return { type: 'basic', selector: params } | ||
return { selector: params, type: 'basic' } | ||
} | ||
@@ -170,4 +170,4 @@ let bits = braceBlock[1].match(/^(with(?:out)?):(.+)$/) | ||
return { | ||
type: 'withrules', | ||
escapes | ||
escapes, | ||
type: 'withrules' | ||
} | ||
@@ -256,3 +256,3 @@ } | ||
let { params } = rule | ||
let { type, selector, escapes } = parseRootRuleParams(params) | ||
let { escapes, selector, type } = parseRootRuleParams(params) | ||
if (type === 'unknown') { | ||
@@ -264,3 +264,3 @@ throw rule.error( | ||
if (type === 'basic' && selector) { | ||
let selectorBlock = new Rule({ selector, nodes: rule.nodes }) | ||
let selectorBlock = new Rule({ nodes: rule.nodes, selector }) | ||
rule.removeAll() | ||
@@ -277,3 +277,3 @@ rule.append(selectorBlock) | ||
let bubble = atruleNames( | ||
['media', 'supports', 'layer', 'container'], | ||
['media', 'supports', 'layer', 'container', 'starting-style'], | ||
opts.bubble | ||
@@ -296,4 +296,2 @@ ) | ||
return { | ||
postcssPlugin: 'postcss-nested', | ||
Once(root) { | ||
@@ -306,2 +304,11 @@ root.walkAtRules(rootRuleName, node => { | ||
postcssPlugin: 'postcss-nested', | ||
RootExit(root) { | ||
if (root[hasRootRule]) { | ||
root.walkAtRules(rootRuleName, unwrapRootRule) | ||
root[hasRootRule] = false | ||
} | ||
}, | ||
Rule(rule) { | ||
@@ -359,9 +366,2 @@ let unwrapped = false | ||
} | ||
}, | ||
RootExit(root) { | ||
if (root[hasRootRule]) { | ||
root.walkAtRules(rootRuleName, unwrapRootRule) | ||
root[hasRootRule] = false | ||
} | ||
} | ||
@@ -368,0 +368,0 @@ } |
{ | ||
"name": "postcss-nested", | ||
"version": "6.0.1", | ||
"version": "6.2.0", | ||
"description": "PostCSS plugin to unwrap nested rules like how Sass does it", | ||
@@ -18,6 +18,12 @@ "keywords": [ | ||
}, | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/postcss/" | ||
}, | ||
"funding": [ | ||
{ | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/postcss/" | ||
}, | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/ai" | ||
} | ||
], | ||
"peerDependencies": { | ||
@@ -27,4 +33,4 @@ "postcss": "^8.2.14" | ||
"dependencies": { | ||
"postcss-selector-parser": "^6.0.11" | ||
"postcss-selector-parser": "^6.1.1" | ||
} | ||
} |
@@ -11,14 +11,14 @@ # PostCSS Nested | ||
.phone { | ||
&_title { | ||
width: 500px; | ||
@media (max-width: 500px) { | ||
width: auto; | ||
} | ||
body.is_dark & { | ||
color: white; | ||
} | ||
&_title { | ||
width: 500px; | ||
@media (max-width: 500px) { | ||
width: auto; | ||
} | ||
img { | ||
display: block; | ||
body.is_dark & { | ||
color: white; | ||
} | ||
} | ||
img { | ||
display: block; | ||
} | ||
} | ||
@@ -30,3 +30,3 @@ | ||
@at-root html { | ||
--font: 16px | ||
--font: 16px; | ||
} | ||
@@ -40,14 +40,14 @@ } | ||
.phone_title { | ||
width: 500px; | ||
width: 500px; | ||
} | ||
@media (max-width: 500px) { | ||
.phone_title { | ||
width: auto; | ||
} | ||
.phone_title { | ||
width: auto; | ||
} | ||
} | ||
body.is_dark .phone_title { | ||
color: white; | ||
color: white; | ||
} | ||
.phone img { | ||
display: block; | ||
display: block; | ||
} | ||
@@ -59,3 +59,3 @@ | ||
html { | ||
--font: 16px | ||
--font: 16px; | ||
} | ||
@@ -66,5 +66,5 @@ ``` | ||
* Use [`postcss-current-selector`] **after** this plugin if you want | ||
- 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 | ||
- Use [`postcss-nested-ancestors`] **before** this plugin if you want | ||
to reference any ancestor element directly in your selectors with `^&`. | ||
@@ -74,4 +74,4 @@ | ||
* See also [`postcss-nesting`], which implements [CSSWG draft]. | ||
* [`postcss-nested-props`] for nested properties like `font-size`. | ||
- See also [`postcss-nesting`], which implements [CSSWG draft]. | ||
- [`postcss-nested-props`] for nested properties like `font-size`. | ||
@@ -85,9 +85,8 @@ <a href="https://evilmartians.com/?utm_source=postcss-nested"> | ||
[`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/csstools/postcss-plugins/tree/main/plugins/postcss-nesting | ||
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/ | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props | ||
[`postcss-nesting`]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting | ||
[CSSWG draft]: https://drafts.csswg.org/css-nesting-1/ | ||
[PostCSS]: https://github.com/postcss/postcss | ||
## Docs | ||
Read full docs **[here](https://github.com/postcss/postcss-nested#readme)**. |
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
13962
86