Skip to content

Commit a55c3e2

Browse files
committed
Fix container clone
1 parent 9b05f58 commit a55c3e2

1 file changed

Lines changed: 41 additions & 38 deletions

File tree

lib/container.d.ts

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ declare namespace Container {
3232
* Note that all containers can store any content. If you write a rule inside
3333
* a rule, PostCSS will parse it.
3434
*/
35-
declare abstract class Container_<
36-
Child extends Node = ChildNode
37-
> extends Node {
35+
declare abstract class Container_<Child extends Node = ChildNode> extends Node {
3836
/**
3937
* An array containing the container’s children.
4038
*
@@ -71,6 +69,13 @@ declare abstract class Container_<
7169
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
7270
): this
7371

72+
assign(overrides: Container.ContainerProps | object): this
73+
74+
clone(overrides?: Partial<Container.ContainerProps>): Container
75+
76+
cloneAfter(overrides?: Partial<Container.ContainerProps>): Container
77+
78+
cloneBefore(overrides?: Partial<Container.ContainerProps>): Container
7479
/**
7580
* Iterates through the container’s immediate children,
7681
* calling `callback` for each child.
@@ -122,7 +127,6 @@ declare abstract class Container_<
122127
every(
123128
condition: (node: Child, index: number, nodes: Child[]) => boolean
124129
): boolean
125-
126130
/**
127131
* The container’s first child.
128132
*
@@ -155,6 +159,23 @@ declare abstract class Container_<
155159
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
156160
): this
157161

162+
/**
163+
* Traverses the container’s descendant nodes, calling callback
164+
* for each comment node.
165+
*
166+
* Like `Container#each`, this method is safe
167+
* to use if you are mutating arrays during iteration.
168+
*
169+
* ```js
170+
* root.walkComments(comment => {
171+
* comment.remove()
172+
* })
173+
* ```
174+
*
175+
* @param callback Iterator receives each node and index.
176+
* @return Returns `false` if iteration was broke.
177+
*/
178+
158179
/**
159180
* Insert new node before old node within the container.
160181
*
@@ -202,6 +223,7 @@ declare abstract class Container_<
202223
prepend(
203224
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
204225
): this
226+
205227
/**
206228
* Add child to the end of the node.
207229
*
@@ -214,23 +236,6 @@ declare abstract class Container_<
214236
*/
215237
push(child: Child): this
216238

217-
/**
218-
* Traverses the container’s descendant nodes, calling callback
219-
* for each comment node.
220-
*
221-
* Like `Container#each`, this method is safe
222-
* to use if you are mutating arrays during iteration.
223-
*
224-
* ```js
225-
* root.walkComments(comment => {
226-
* comment.remove()
227-
* })
228-
* ```
229-
*
230-
* @param callback Iterator receives each node and index.
231-
* @return Returns `false` if iteration was broke.
232-
*/
233-
234239
/**
235240
* Removes all children from the container
236241
* and cleans their parent properties.
@@ -243,6 +248,7 @@ declare abstract class Container_<
243248
* @return This node for methods chain.
244249
*/
245250
removeAll(): this
251+
246252
/**
247253
* Removes node from the container and cleans the parent properties
248254
* from the node and its children.
@@ -259,6 +265,11 @@ declare abstract class Container_<
259265
*/
260266
removeChild(child: Child | number): this
261267

268+
replaceValues(
269+
pattern: RegExp | string,
270+
replaced: { (substring: string, ...args: any[]): string } | string
271+
): this
272+
262273
/**
263274
* Passes all declaration values within the container that match pattern
264275
* through callback, replacing those values with the returned result
@@ -288,11 +299,6 @@ declare abstract class Container_<
288299
replaced: { (substring: string, ...args: any[]): string } | string
289300
): this
290301

291-
replaceValues(
292-
pattern: RegExp | string,
293-
replaced: { (substring: string, ...args: any[]): string } | string
294-
): this
295-
296302
/**
297303
* Returns `true` if callback returns `true` for (at least) one
298304
* of the container’s children.
@@ -330,11 +336,6 @@ declare abstract class Container_<
330336
walk(
331337
callback: (node: ChildNode, index: number) => false | void
332338
): false | undefined
333-
334-
walkAtRules(
335-
callback: (atRule: AtRule, index: number) => false | void
336-
): false | undefined
337-
338339
/**
339340
* Traverses the container’s descendant nodes, calling callback
340341
* for each at-rule node.
@@ -369,16 +370,17 @@ declare abstract class Container_<
369370
callback: (atRule: AtRule, index: number) => false | void
370371
): false | undefined
371372

373+
walkAtRules(
374+
callback: (atRule: AtRule, index: number) => false | void
375+
): false | undefined
376+
372377
walkComments(
373378
callback: (comment: Comment, indexed: number) => false | void
374379
): false | undefined
375380

376381
walkComments(
377382
callback: (comment: Comment, indexed: number) => false | void
378383
): false | undefined
379-
walkDecls(
380-
callback: (decl: Declaration, index: number) => false | void
381-
): false | undefined
382384

383385
/**
384386
* Traverses the container’s descendant nodes, calling callback
@@ -413,11 +415,9 @@ declare abstract class Container_<
413415
propFilter: RegExp | string,
414416
callback: (decl: Declaration, index: number) => false | void
415417
): false | undefined
416-
417-
walkRules(
418-
callback: (rule: Rule, index: number) => false | void
418+
walkDecls(
419+
callback: (decl: Declaration, index: number) => false | void
419420
): false | undefined
420-
421421
/**
422422
* Traverses the container’s descendant nodes, calling callback
423423
* for each rule node.
@@ -444,6 +444,9 @@ declare abstract class Container_<
444444
selectorFilter: RegExp | string,
445445
callback: (rule: Rule, index: number) => false | void
446446
): false | undefined
447+
walkRules(
448+
callback: (rule: Rule, index: number) => false | void
449+
): false | undefined
447450
}
448451

449452
declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}

0 commit comments

Comments
 (0)