parse-css-class-id-selector

1.0.0 • Public • Published

parse-css-class-id-selector

NPM version Build Status Coverage Status

Code Climate Dependencies DevDependencies

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

Package Sidebar

Install

npm i parse-css-class-id-selector

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • dustinspecker