CSS Specificity Calculator
Calculate the Specificity of a given CSS Selector
Installation
npm i @bramus/calculate-specificity
Usage / Example
This library comes as an ES Module and exposes a function/algorithm to generate an array of pagination entries.
import { calculate } from '@bramus/calculate-specificity';
const specificity = calculate('.foo :is(.bar, #baz)');
License
@bramus/calculate-specificity
is released under the MIT public license. See the enclosed LICENSE
for details.
Acknowledgements
The code was sparked by the wonderful Specificity Calculator created by Kilian Valkhof / Polypane.
The heavy lifting of doing the actual parsing is done by CSSTree.