dvtng / jss

JavaScript library for getting and setting CSS stylesheet rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

check if there is a css rule

jedierikb opened this issue · comments

Would be nice to have a function which, given a string, returns a boolean if there is a css rule or not for said string.

jss(selector).get() returns an empty object if there are no rules applied, so you could use underscore.js as follows:

_.isEmpty(jss(selector).get());

But the jss API doesn't really need this, does it? What's the use case?

thank you for pointing that out regarding empty objects.

my use case is needing to know what background, if any was currently in effect in a css rule.

much thanks.

jss only reads rules it's implemented itself, but you'd basically be lookin at jss(selector).get() && jss(selector).background