Skip to content

Commit

Permalink
Fix container clone
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Jul 21, 2023
1 parent 9b05f58 commit a55c3e2
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions lib/container.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ declare namespace Container {
* Note that all containers can store any content. If you write a rule inside
* a rule, PostCSS will parse it.
*/
declare abstract class Container_<
Child extends Node = ChildNode
> extends Node {
declare abstract class Container_<Child extends Node = ChildNode> extends Node {
/**
* An array containing the container’s children.
*
Expand Down Expand Up @@ -71,6 +69,13 @@ declare abstract class Container_<
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
): this

assign(overrides: Container.ContainerProps | object): this

clone(overrides?: Partial<Container.ContainerProps>): Container

cloneAfter(overrides?: Partial<Container.ContainerProps>): Container

cloneBefore(overrides?: Partial<Container.ContainerProps>): Container
/**
* Iterates through the container’s immediate children,
* calling `callback` for each child.
Expand Down Expand Up @@ -122,7 +127,6 @@ declare abstract class Container_<
every(
condition: (node: Child, index: number, nodes: Child[]) => boolean
): boolean

/**
* The container’s first child.
*
Expand Down Expand Up @@ -155,6 +159,23 @@ declare abstract class Container_<
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
): this

/**
* Traverses the container’s descendant nodes, calling callback
* for each comment node.
*
* Like `Container#each`, this method is safe
* to use if you are mutating arrays during iteration.
*
* ```js
* root.walkComments(comment => {
* comment.remove()
* })
* ```
*
* @param callback Iterator receives each node and index.
* @return Returns `false` if iteration was broke.
*/

/**
* Insert new node before old node within the container.
*
Expand Down Expand Up @@ -202,6 +223,7 @@ declare abstract class Container_<
prepend(
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
): this

/**
* Add child to the end of the node.
*
Expand All @@ -214,23 +236,6 @@ declare abstract class Container_<
*/
push(child: Child): this

/**
* Traverses the container’s descendant nodes, calling callback
* for each comment node.
*
* Like `Container#each`, this method is safe
* to use if you are mutating arrays during iteration.
*
* ```js
* root.walkComments(comment => {
* comment.remove()
* })
* ```
*
* @param callback Iterator receives each node and index.
* @return Returns `false` if iteration was broke.
*/

/**
* Removes all children from the container
* and cleans their parent properties.
Expand All @@ -243,6 +248,7 @@ declare abstract class Container_<
* @return This node for methods chain.
*/
removeAll(): this

/**
* Removes node from the container and cleans the parent properties
* from the node and its children.
Expand All @@ -259,6 +265,11 @@ declare abstract class Container_<
*/
removeChild(child: Child | number): this

replaceValues(
pattern: RegExp | string,
replaced: { (substring: string, ...args: any[]): string } | string
): this

/**
* Passes all declaration values within the container that match pattern
* through callback, replacing those values with the returned result
Expand Down Expand Up @@ -288,11 +299,6 @@ declare abstract class Container_<
replaced: { (substring: string, ...args: any[]): string } | string
): this

replaceValues(
pattern: RegExp | string,
replaced: { (substring: string, ...args: any[]): string } | string
): this

/**
* Returns `true` if callback returns `true` for (at least) one
* of the container’s children.
Expand Down Expand Up @@ -330,11 +336,6 @@ declare abstract class Container_<
walk(
callback: (node: ChildNode, index: number) => false | void
): false | undefined

walkAtRules(
callback: (atRule: AtRule, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
* for each at-rule node.
Expand Down Expand Up @@ -369,16 +370,17 @@ declare abstract class Container_<
callback: (atRule: AtRule, index: number) => false | void
): false | undefined

walkAtRules(
callback: (atRule: AtRule, index: number) => false | void
): false | undefined

walkComments(
callback: (comment: Comment, indexed: number) => false | void
): false | undefined

walkComments(
callback: (comment: Comment, indexed: number) => false | void
): false | undefined
walkDecls(
callback: (decl: Declaration, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
Expand Down Expand Up @@ -413,11 +415,9 @@ declare abstract class Container_<
propFilter: RegExp | string,
callback: (decl: Declaration, index: number) => false | void
): false | undefined

walkRules(
callback: (rule: Rule, index: number) => false | void
walkDecls(
callback: (decl: Declaration, index: number) => false | void
): false | undefined

/**
* Traverses the container’s descendant nodes, calling callback
* for each rule node.
Expand All @@ -444,6 +444,9 @@ declare abstract class Container_<
selectorFilter: RegExp | string,
callback: (rule: Rule, index: number) => false | void
): false | undefined
walkRules(
callback: (rule: Rule, index: number) => false | void
): false | undefined
}

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

0 comments on commit a55c3e2

Please sign in to comment.