parse-css-class-id-selector
v1.0.0
Published
Retreive class names and id from a CSS selector
Downloads
5
Maintainers
Readme
parse-css-class-id-selector
Retreive class names and id from a CSS selector
Install
npm install --save parse-css-class-id-selector
Usage
import parseCssClassIdSelector from 'parse-css-class-id-selector'
parseCssClassIdSelector('.hello#world.good-bye')
// => {id: 'world', classNames: ['hello', 'good-bye']}
parseCssClassIdSelector('#world')
// => {id: 'world', classNames: []}
parseCssClassIdSelector('.hello.good-bye')
// => {id: null, classNames: ['hello', 'good-bye']}
API
parseCssClassIdSelector(selector)
Returns an object with a classNames
array and an id
. An empty array is return if no class names found. Null is return if no id is found.
selector
type: String
A string consisting of only class and/or id selectors.
LICENSE
MIT © Dustin Specker