Skip to content
A CSS selector parser, integrates with postcss but does not require it.
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src test: new pseudo classes (#193) Mar 16, 2019
.babelrc 6.0.0 Feb 25, 2019
.editorconfig
.eslintrc.json
.gitignore Removed the dot-prop dependency Mar 7, 2018
.npmignore
.travis.yml chore: remove outdated integration tests Oct 24, 2018
API.md
CHANGELOG.md
LICENSE-MIT README, licence, etc. May 29, 2015
README.md
package-lock.json
package.json
postcss-selector-parser.d.ts API for getting the node at specific source location. May 4, 2018

README.md

postcss-selector-parser Build Status

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

You can’t perform that action at this time.