postcss-nested 5.0.5 → 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,10 +59,12 @@ html {
59
59
 
60
60
  Related plugins:
61
61
 
62
+ * Use [`postcss-atroot`] for `@at-root` at-rule to move nested child
63
+ to the CSS root.
62
64
  * Use [`postcss-current-selector`] **after** this plugin if you want
63
- to use current selector in properties or variables values.
65
+ to use current selector in properties or variables values.
64
66
  * Use [`postcss-nested-ancestors`] **before** this plugin if you want
65
- to reference any ancestor element directly in your selectors with `^&`.
67
+ to reference any ancestor element directly in your selectors with `^&`.
66
68
 
67
69
  Alternatives:
68
70
 
@@ -75,6 +77,7 @@ Alternatives:
75
77
  alt="Sponsored by Evil Martians" width="236" height="54">
76
78
  </a>
77
79
 
80
+ [`postcss-atroot`]: https://github.com/OEvgeny/postcss-atroot
78
81
  [`postcss-current-selector`]: https://github.com/komlev/postcss-current-selector
79
82
  [`postcss-nested-ancestors`]: https://github.com/toomuchdesign/postcss-nested-ancestors
80
83
  [`postcss-nested-props`]: https://github.com/jedmao/postcss-nested-props
package/index.d.ts CHANGED
@@ -1,30 +1,34 @@
1
- // Original definitions (@types/postcss-nested) by Maxim Vorontsov <https://github.com/VorontsovMaxim>
1
+ // Original definitions (@types/postcss-nested)
2
+ // by Maxim Vorontsov <https://github.com/VorontsovMaxim>
2
3
 
3
- import { PluginCreator } from 'postcss';
4
+ import { PluginCreator } from 'postcss'
4
5
 
5
6
  declare namespace nested {
6
7
  interface Options {
7
8
  /**
8
- * By default, plugin will bubble only @media and @supports at-rules.
9
+ * By default, plugin will bubble only `@media` and `@supports` at-rules.
9
10
  * You can add your custom at-rules to this list by this option.
10
11
  */
11
- bubble?: string[];
12
+ bubble?: string[]
12
13
 
13
14
  /**
14
- * By default, plugin will unwrap only @font-face, @keyframes and @document at-rules.
15
- * You can add your custom at-rules to this list by this option.
15
+ * By default, plugin will unwrap only `@font-face`, `@keyframes`,
16
+ * and `@document` at-rules. You can add your custom at-rules
17
+ * to this list by this option.
16
18
  */
17
- unwrap?: string[];
19
+ unwrap?: string[]
18
20
 
19
21
  /**
20
- * By default, plugin will strip out any empty selector generated by intermediate nesting
21
- * levels. You can set this option to true to preserve them.
22
+ * By default, plugin will strip out any empty selector generated
23
+ * by intermediate nesting levels. You can set this option to `true`
24
+ * to preserve them.
22
25
  */
23
- preserveEmpty?: boolean;
26
+ preserveEmpty?: boolean
24
27
  }
25
28
 
26
- type Nested = PluginCreator<Options>;
29
+ type Nested = PluginCreator<Options>
27
30
  }
28
31
 
29
- declare const nested: nested.Nested;
30
- export = nested;
32
+ declare const nested: nested.Nested
33
+
34
+ export = nested
package/index.js CHANGED
@@ -66,26 +66,32 @@ function pickComment (comment, after) {
66
66
  }
67
67
  }
68
68
 
69
- function atruleChilds (rule, atrule, bubbling) {
70
- let children = []
71
- atrule.each(child => {
72
- if (child.type === 'comment') {
73
- children.push(child)
74
- } else if (child.type === 'decl') {
75
- children.push(child)
76
- } else if (child.type === 'rule' && bubbling) {
77
- child.selectors = selectors(rule, child)
78
- } else if (child.type === 'atrule') {
79
- atruleChilds(rule, child, bubbling)
80
- }
81
- })
82
- if (bubbling) {
83
- if (children.length) {
84
- let clone = rule.clone({ nodes: [] })
85
- for (let child of children) {
86
- clone.append(child)
69
+ function createFnAtruleChilds (bubble) {
70
+ return function atruleChilds (rule, atrule, bubbling) {
71
+ let children = []
72
+ atrule.each(child => {
73
+ if (child.type === 'comment') {
74
+ children.push(child)
75
+ } else if (child.type === 'decl') {
76
+ children.push(child)
77
+ } else if (child.type === 'rule' && bubbling) {
78
+ child.selectors = selectors(rule, child)
79
+ } else if (child.type === 'atrule') {
80
+ if (child.nodes && bubble[child.name]) {
81
+ atruleChilds(rule, child, true)
82
+ } else {
83
+ children.push(child)
84
+ }
85
+ }
86
+ })
87
+ if (bubbling) {
88
+ if (children.length) {
89
+ let clone = rule.clone({ nodes: [] })
90
+ for (let child of children) {
91
+ clone.append(child)
92
+ }
93
+ atrule.prepend(clone)
87
94
  }
88
- atrule.prepend(clone)
89
95
  }
90
96
  }
91
97
  }
@@ -120,6 +126,7 @@ function atruleNames (defaults, custom) {
120
126
 
121
127
  module.exports = (opts = {}) => {
122
128
  let bubble = atruleNames(['media', 'supports'], opts.bubble)
129
+ let atruleChilds = createFnAtruleChilds(bubble)
123
130
  let unwrap = atruleNames(
124
131
  [
125
132
  'document',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-nested",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "description": "PostCSS plugin to unwrap nested rules like how Sass does it",
5
5
  "keywords": [
6
6
  "postcss",
@@ -13,16 +13,16 @@
13
13
  "license": "MIT",
14
14
  "repository": "postcss/postcss-nested",
15
15
  "engines": {
16
- "node": ">=10.0"
16
+ "node": ">=12.0"
17
17
  },
18
18
  "funding": {
19
19
  "type": "opencollective",
20
20
  "url": "https://opencollective.com/postcss/"
21
21
  },
22
22
  "peerDependencies": {
23
- "postcss": "^8.1.13"
23
+ "postcss": "^8.2.14"
24
24
  },
25
25
  "dependencies": {
26
- "postcss-selector-parser": "^6.0.4"
26
+ "postcss-selector-parser": "^6.0.6"
27
27
  }
28
28
  }
package/CHANGELOG.md DELETED
@@ -1,110 +0,0 @@
1
- # Change Log
2
- This project adheres to [Semantic Versioning](http://semver.org/).
3
-
4
- ## 5.0.5
5
- * Fixed `,` at the tail (by Jesse de Boer).
6
-
7
- ## 5.0.4
8
- * Fixed nested `&` at the tail (by Raphael Luba).
9
- * Fixed docs (by Samuel Charpentier).
10
-
11
- ## 5.0.3
12
- * Fixed compability with Autoprefixer by adding `@-webkit-keyframes` support.
13
-
14
- ## 5.0.2
15
- * Fixed compatibility with `postcss-mixins` by moving to visitor API.
16
-
17
- ## 5.0.1
18
- * Fixed PostCSS 8.1 compatibility.
19
- * Added funding links.
20
-
21
- ## 5.0
22
- * Moved to PostCSS 8.
23
- * Moved `postcss` to `peerDependencies`.
24
-
25
- ## 4.2.3
26
- * Fixed declarations after nested rule and before at-rule (by Rodion Demikhov).
27
-
28
- ## 4.2.2
29
- * Fixed wrong specificity order of declarations (by Rodion Demikhov).
30
-
31
- ## 4.2.1
32
- * Fix TypeScript definitions (by Avi Vahl).
33
-
34
- ## 4.2
35
- * Add `@at-root` support (by Jason Quense).
36
-
37
- ## 4.1.2
38
- * Improve error messsage on broken selector
39
-
40
- ## 4.1.1
41
- * Add `&(:hover)` support (by Ben Delarre).
42
-
43
- ## 4.1
44
- * Add `unwrap` option.
45
-
46
- ## 4.0
47
- * Use PostCSS 7 (by Aleks Hudochenkov).
48
- * Remove Node.js 4 support.
49
-
50
- ## 3.0
51
- * Add `@font-face` to bubbling at-rules (by Valeriy Komlev).
52
- * Add special logic for `@font-face` bubbling (by Phanindra Pydisetty).
53
- * Use PostCSS selector parser 3.0.
54
-
55
- ## 2.1.2
56
- * Fix replacing multiple `&`.
57
-
58
- ## 2.1.1
59
- * Fix `:not(&)` support.
60
-
61
- ## 2.1
62
- * Add `preserveEmpty` option (by Federico Zivolo).
63
-
64
- ## 2.0.4
65
- * Fix finding `&` in some selectors (by Stepan Mikhaylyuk).
66
-
67
- ## 2.0.3
68
- * Doesn’t replace `&` inside string (by Paul Kiddle).
69
-
70
- ## 2.0.2
71
- * Fix comments moving regression.
72
-
73
- ## 2.0.1
74
- * Fix rules order regression (by Dmitry Vibe).
75
-
76
- ## 2.0
77
- * Use PostCSS 6 API.
78
-
79
- ## 1.0.1
80
- * Clean up npm package.
81
-
82
- ## 1.0
83
- * Use PostCSS 5.0 API.
84
- * Do not add spaces to selector in compressed CSS.
85
- * Move nodes with its comment above.
86
-
87
- ## 0.3.2
88
- * Fix `@supports` at-rule support (by Ben Briggs).
89
-
90
- ## 0.3.1
91
- * Pass PostCSS Plugin Guidelines.
92
-
93
- ## 0.3
94
- * Do not unwrap custom at-rules.
95
- * Add `bubble` option to unwrap some custom at-rules.
96
- * Support PostCSS 4.1 API.
97
- * Fix last semicolon after unwrapping.
98
-
99
- ## 0.2.2
100
- * Module returns function to have common PostCSS API.
101
-
102
- ## 0.2.1
103
- * Add comma support to selectors unwrap.
104
-
105
- ## 0.2
106
- * Use PostCSS 4.0.
107
- * Fix indent, when move rules to other parent.
108
-
109
- ## 0.1
110
- * Initial release.