dvtng / jss

JavaScript library for getting and setting CSS stylesheet rules
335 stars 54 forks source link

check if there is a css rule #9

Closed jedierikb closed 12 years ago

jedierikb commented 12 years ago

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.

barneycarroll commented 12 years ago

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?

jedierikb commented 12 years ago

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.

barneycarroll commented 12 years ago

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