postcss-selector-parser
TypeScript icon, indicating that this package has built-in type declarations

7.0.0 • Public • Published

postcss-selector-parser test

Selector parser with built in methods for working with selector strings.

Install

With npm do:

npm install postcss-selector-parser

Quick Start

const parser = require('postcss-selector-parser');
const transform = selectors => {
    selectors.walk(selector => {
        // do something with the selector
        console.log(String(selector))
    });
};

const transformed = parser(transform).processSync('h1, h2, h3');

To normalize selector whitespace:

const parser = require('postcss-selector-parser');
const normalized = parser().processSync('h1, h2, h3', {lossless: false});
// -> h1,h2,h3

Async support is provided through parser.process and will resolve a Promise with the resulting selector string.

API

Please see API.md.

Credits

  • Huge thanks to Andrey Sitnik (@ai) for work on PostCSS which helped accelerate this module's development.

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
7.0.05,095,444latest
5.0.0-rc.17next

Version History

VersionDownloads (Last 7 Days)Published
7.0.05,095,444
6.1.29,681,398
6.1.1788,080
6.1.01,073,493
6.0.161,145,063
6.0.151,006,968
6.0.1429,325
6.0.131,846,538
6.0.1289,159
6.0.11972,350
6.0.102,074,759
6.0.9225,634
6.0.860,808
6.0.726,723
6.0.6425,450
6.0.537,185
6.0.4312,899
6.0.33,055
3.1.22,483,713
6.0.2410,062
6.0.1108
6.0.07
5.0.02,119,727
5.0.0-rc.44,660
5.0.0-rc.31,871
5.0.0-rc.26
5.0.0-rc.17
5.0.0-rc.07
4.0.06,119
4.0.0-rc.14
4.0.0-rc.014
3.1.1195,433
3.1.06
3.0.06
3.0.0-rc.021
2.2.3490,874
2.2.21,594
2.2.17,663
2.2.09,536
2.1.167
2.1.012
2.0.020
1.3.315,796
1.3.26
1.3.137
1.3.09
1.2.13
1.2.010
1.1.47
1.1.36
1.1.27
1.1.15
1.1.09
1.0.16
1.0.09
0.0.53
0.0.46
0.0.35
0.0.22
0.0.14

Package Sidebar

Install

npm i postcss-selector-parser

Weekly Downloads

22,723,969

Version

7.0.0

License

MIT

Unpacked Size

187 kB

Total Files

36

Last publish

Collaborators

  • ai
  • chriseppstein
  • jonathantneal
  • evilebottnawi