Socket
Socket
Sign inDemoInstall

css-specificity

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-specificity

CSS selector specificity calculator


Version published
Maintainers
1
Created
Source

css-specificity Build Status

CSS3 selector specificity calculator.

css-specificity is wrapper module of specimen.

Installation

$ npm install css-specificity

Example

var specificity = require('css-specificity')

var calc = specificity.calc('.class, p.sel:after')
var winner = specificity.vs('.class', 'p.sel:after')

console.log(calc)
/*
[
    {
        'selector': '.class',
        'specificity': [0, 0, 1, 0],
        'a': 0,
        'b': 1,
        'c': 0
    },
    {
        'selector': 'p.sel:after',
        'specificity': [0, 0, 1, 2],
        'a': 0,
        'b': 1,
        'c': 2
    }
]
*/

console.log(winner)
// 'p.sel:after'

API

specificity.calc(selector)

return caluculation result.

specificity.vs(selector1, selector2)

return selector has higher specificity.

License

The MIT License (MIT)

Copyright (c) 2014 Masaaki Morishita

Keywords

FAQs

Package last updated on 24 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc