Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/bundler/deps.ts>postcss.Container#walkRules

A Bundler with the web in mind.
Go to Latest
method postcss.Container.prototype.walkRules
Re-export
import { postcss } from "https://deno.land/x/bundler@0.6.2/deps.ts";
const { Container } = postcss;

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

If you pass a filter, iteration will only happen over rules with matching selectors.

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

const selectors = []
root.walkRules(rule => {
  selectors.push(rule.selector)
})
console.log(`Your CSS uses ${ selectors.length } selectors`)

Parameters

selectorFilter: string | RegExp

String or regular expression to filter rules by selector.

callback: (atRule: Rule, index: number) => false | void

Iterator receives each node and index.

Returns

false | undefined

Returns false if iteration was broke.

Parameters

callback: (atRule: Rule, index: number) => false | void

Returns

false | undefined