is-pseudo
v2.1.0
Published
Validate if a CSS selector targets a pseudo class or element
Downloads
4
Maintainers
Readme
is Pseudo (?)
Provide a simple lookup to check if a provided selector targets a pseudo class or element.
About
Although there are already some projects which refer towards a list of pseudo classes or elements - they are not convenient to use for a simple lookup. On the contrary this library provides a simple validation function which also include browser vendor specific selectors and common extensions defined by jQuery & CSS Select.
Usage
Install
npm install --save is-pseudo
General
import isPseudo from 'is-pseudo'
if (isPseudo('div a.super:hover')) {
// true
}
if (isPseudo('div span:has(a)', { customs: true })) {
// true
}
TODO
- add strict comparison option for selectors with brackets (e.g.
:nth-child(3)
)
Links
Development
To build your own version run npm run dev
for development (incl. watch) or npm run build
for production (minified).