postcss 8.4.33 → 8.4.35

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/lib/at-rule.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import Container, { ContainerProps } from './container.js'
1
+ import Container, {
2
+ ContainerProps,
3
+ ContainerWithChildren
4
+ } from './container.js'
2
5
 
3
6
  declare namespace AtRule {
4
7
  export interface AtRuleRaws extends Record<string, unknown> {
@@ -81,11 +84,30 @@ declare class AtRule_ extends Container {
81
84
  *
82
85
  * ```js
83
86
  * const root = postcss.parse('@media print {}')
84
- * media.name //=> 'media'
85
87
  * const media = root.first
88
+ * media.name //=> 'media'
86
89
  * ```
87
90
  */
88
91
  name: string
92
+ /**
93
+ * An array containing the layer’s children.
94
+ *
95
+ * ```js
96
+ * const root = postcss.parse('@layer example { a { color: black } }')
97
+ * const layer = root.first
98
+ * layer.nodes.length //=> 1
99
+ * layer.nodes[0].selector //=> 'a'
100
+ * ```
101
+ *
102
+ * Can be `undefinded` if the at-rule has no body.
103
+ *
104
+ * ```js
105
+ * const root = postcss.parse('@layer a, b, c;')
106
+ * const layer = root.first
107
+ * layer.nodes //=> undefined
108
+ * ```
109
+ */
110
+ nodes: Container['nodes']
89
111
  /**
90
112
  * The at-rule’s parameters, the values that follow the at-rule’s name
91
113
  * but precede any `{}` block.
@@ -97,7 +119,7 @@ declare class AtRule_ extends Container {
97
119
  * ```
98
120
  */
99
121
  params: string
100
- parent: Container | undefined
122
+ parent: ContainerWithChildren | undefined
101
123
 
102
124
  raws: AtRule.AtRuleRaws
103
125
 
@@ -5,6 +5,12 @@ import Node, { ChildNode, ChildProps, NodeProps } from './node.js'
5
5
  import Rule from './rule.js'
6
6
 
7
7
  declare namespace Container {
8
+ export class ContainerWithChildren<
9
+ Child extends Node = ChildNode
10
+ > extends Container_<Child> {
11
+ nodes: Child[]
12
+ }
13
+
8
14
  export interface ValueOptions {
9
15
  /**
10
16
  * String that’s used to narrow down values and speed up the regexp search.
@@ -43,7 +49,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
43
49
  * root.nodes[0].nodes[0].prop //=> 'color'
44
50
  * ```
45
51
  */
46
- nodes: Child[]
52
+ nodes: Child[] | undefined
47
53
 
48
54
  /**
49
55
  * Inserts new nodes to the end of the container.
@@ -66,7 +72,15 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
66
72
  * @return This node for methods chain.
67
73
  */
68
74
  append(
69
- ...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
75
+ ...nodes: (
76
+ | ChildProps
77
+ | ChildProps[]
78
+ | Node
79
+ | Node[]
80
+ | string
81
+ | string[]
82
+ | undefined
83
+ )[]
70
84
  ): this
71
85
 
72
86
  assign(overrides: Container.ContainerProps | object): this
@@ -146,7 +160,14 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
146
160
  */
147
161
  insertAfter(
148
162
  oldNode: Child | number,
149
- newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
163
+ newNode:
164
+ | Child
165
+ | Child[]
166
+ | ChildProps
167
+ | ChildProps[]
168
+ | string
169
+ | string[]
170
+ | undefined
150
171
  ): this
151
172
  /**
152
173
  * Insert new node before old node within the container.
@@ -161,7 +182,14 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
161
182
  */
162
183
  insertBefore(
163
184
  oldNode: Child | number,
164
- newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
185
+ newNode:
186
+ | Child
187
+ | Child[]
188
+ | ChildProps
189
+ | ChildProps[]
190
+ | string
191
+ | string[]
192
+ | undefined
165
193
  ): this
166
194
 
167
195
  /**
@@ -202,7 +230,15 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
202
230
  * @return This node for methods chain.
203
231
  */
204
232
  prepend(
205
- ...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
233
+ ...nodes: (
234
+ | ChildProps
235
+ | ChildProps[]
236
+ | Node
237
+ | Node[]
238
+ | string
239
+ | string[]
240
+ | undefined
241
+ )[]
206
242
  ): this
207
243
  /**
208
244
  * Add child to the end of the node.
@@ -447,6 +483,8 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
447
483
  get last(): Child | undefined
448
484
  }
449
485
 
450
- declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}
486
+ declare class Container<
487
+ Child extends Node = ChildNode
488
+ > extends Container_<Child> {}
451
489
 
452
490
  export = Container
package/lib/container.js CHANGED
@@ -173,6 +173,8 @@ class Container extends Node {
173
173
  normalize(nodes, sample) {
174
174
  if (typeof nodes === 'string') {
175
175
  nodes = cleanSource(parse(nodes).nodes)
176
+ } else if (typeof nodes === 'undefined') {
177
+ nodes = []
176
178
  } else if (Array.isArray(nodes)) {
177
179
  nodes = nodes.slice(0)
178
180
  for (let i of nodes) {
@@ -1,4 +1,4 @@
1
- import Container from './container.js'
1
+ import { ContainerWithChildren } from './container.js'
2
2
  import Node from './node.js'
3
3
 
4
4
  declare namespace Declaration {
@@ -79,7 +79,7 @@ declare class Declaration_ extends Node {
79
79
  */
80
80
  important: boolean
81
81
 
82
- parent: Container | undefined
82
+ parent: ContainerWithChildren | undefined
83
83
 
84
84
  /**
85
85
  * The property name for a CSS declaration.
package/lib/document.d.ts CHANGED
@@ -35,6 +35,7 @@ declare namespace Document {
35
35
  * ```
36
36
  */
37
37
  declare class Document_ extends Container<Root> {
38
+ nodes: Root[]
38
39
  parent: undefined
39
40
  type: 'document'
40
41
 
@@ -52,7 +52,7 @@ class MapGenerator {
52
52
  if (this.mapOpts.sourcesContent === false) {
53
53
  map = new SourceMapConsumer(prev.text)
54
54
  if (map.sourcesContent) {
55
- map.sourcesContent = map.sourcesContent.map(() => null)
55
+ map.sourcesContent = null
56
56
  }
57
57
  } else {
58
58
  map = prev.consumer()
@@ -38,8 +38,8 @@ class NoWorkResult {
38
38
  this.result.map = generatedMap
39
39
  }
40
40
  } else {
41
- map.clearAnnotation();
42
- this.result.css = map.css;
41
+ map.clearAnnotation()
42
+ this.result.css = map.css
43
43
  }
44
44
  }
45
45
 
package/lib/node.d.ts CHANGED
@@ -246,7 +246,7 @@ declare abstract class Node_ {
246
246
  * @param newNode New node.
247
247
  * @return This node for methods chain.
248
248
  */
249
- after(newNode: Node | Node.ChildProps | Node[] | string): this
249
+ after(newNode: Node | Node.ChildProps | Node[] | string | undefined): this
250
250
 
251
251
  /**
252
252
  * It assigns properties to an existing node instance.
@@ -273,7 +273,7 @@ declare abstract class Node_ {
273
273
  * @param newNode New node.
274
274
  * @return This node for methods chain.
275
275
  */
276
- before(newNode: Node | Node.ChildProps | Node[] | string): this
276
+ before(newNode: Node | Node.ChildProps | Node[] | string | undefined): this
277
277
 
278
278
  /**
279
279
  * Clear the code style properties for the node and its children.
@@ -531,6 +531,6 @@ declare abstract class Node_ {
531
531
  warn(result: Result, message: string, options?: WarningOptions): Warning
532
532
  }
533
533
 
534
- declare class Node extends Node_ { }
534
+ declare class Node extends Node_ {}
535
535
 
536
536
  export = Node
package/lib/parser.js CHANGED
@@ -28,7 +28,6 @@ class Parser {
28
28
  this.current = this.root
29
29
  this.spaces = ''
30
30
  this.semicolon = false
31
- this.customProperty = false
32
31
 
33
32
  this.createTokenizer()
34
33
  this.root.source = { input, start: { column: 1, line: 1, offset: 0 } }
package/lib/processor.js CHANGED
@@ -7,7 +7,7 @@ let Root = require('./root')
7
7
 
8
8
  class Processor {
9
9
  constructor(plugins = []) {
10
- this.version = '8.4.33'
10
+ this.version = '8.4.35'
11
11
  this.plugins = this.normalize(plugins)
12
12
  }
13
13
 
package/lib/root.d.ts CHANGED
@@ -54,6 +54,7 @@ declare namespace Root {
54
54
  * ```
55
55
  */
56
56
  declare class Root_ extends Container {
57
+ nodes: NonNullable<Container['nodes']>
57
58
  parent: Document | undefined
58
59
  raws: Root.RootRaws
59
60
  type: 'root'
package/lib/rule.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import Container, { ContainerProps } from './container.js'
1
+ import Container, {
2
+ ContainerProps,
3
+ ContainerWithChildren
4
+ } from './container.js'
2
5
 
3
6
  declare namespace Rule {
4
7
  export interface RuleRaws extends Record<string, unknown> {
@@ -69,7 +72,8 @@ declare namespace Rule {
69
72
  * ```
70
73
  */
71
74
  declare class Rule_ extends Container {
72
- parent: Container | undefined
75
+ nodes: NonNullable<Container['nodes']>
76
+ parent: ContainerWithChildren | undefined
73
77
  raws: Rule.RuleRaws
74
78
  /**
75
79
  * The rule’s full selector represented as a string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss",
3
- "version": "8.4.33",
3
+ "version": "8.4.35",
4
4
  "description": "Tool for transforming styles with JS plugins",
5
5
  "engines": {
6
6
  "node": "^10 || ^12 || >=14"