postcss-query-ast
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

postcss-query-ast

Build Status

Query PostCSS AST with CSS selectors.

Supported selectors are:

In addition to standard selectors, there are also custom selectors:

  • Attribute selector with regular expression: [attr="/^value$/i"]

Install

npm install postcss-query-ast --save

Usage

import queryAst from 'postcss-query-ast';

queryAst('rule[selector="body"]').then(( ast ) => {
	/* [ Rule {
	    raws: { before: '\n\t', between: ' ', semicolon: true, after: '\n\t' },
	    type: 'rule',
	    nodes: [ [Object] ],
	    parent: 
	     AtRule { ... },
	    source: { start: [Object], input: [Object], end: [Object] },
	    selector: 'body',
	    lastEach: 11,
	    indexes: {} } ] */
});

API

queryAst(query, ast)

Returns: Promise

Queries PostCSS with CSS selector.

query

Type: String

CSS selector.

ast

Type: PostCSS.Node

PostCSS AST.

License

MIT © Ivan Nikolić

Package Sidebar

Install

npm i postcss-query-ast@1.0.0

Version

1.0.0

License

MIT

Unpacked Size

31.6 kB

Total Files

6

Last publish

Collaborators

  • niksy