Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
method Container.prototype.walkDecls
Re-export
import { Container } from "https://deno.land/x/postcss@8.4.16/lib/postcss.js";

Traverses the container’s descendant nodes, calling callback for each declaration node.

If you pass a filter, iteration will only happen over declarations with matching properties.

root.walkDecls(decl => {
  checkPropertySupport(decl.prop)
})

root.walkDecls('border-radius', decl => {
  decl.remove()
})

root.walkDecls(/^background/, decl => {
  decl.value = takeFirstColorFromGradient(decl.value)
})

Like Container#each, this method is safe to use if you are mutating arrays during iteration.

Parameters

propFilter: string | RegExp

String or regular expression to filter declarations by property name.

callback: (decl: Declaration, index: number) => false | void

Iterator receives each node and index.

Returns

false | undefined

Returns false if iteration was broke.

Parameters

callback: (decl: Declaration, index: number) => false | void

Returns

false | undefined