{"id":13,"date":"2007-10-19T02:48:33","date_gmt":"2007-10-19T08:48:33","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/index.php\/2007\/10\/19\/css-parser-in-javascript\/"},"modified":"2011-02-23T19:48:16","modified_gmt":"2011-02-24T01:48:16","slug":"css-parser-in-javascript","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2007\/10\/19\/css-parser-in-javascript\/","title":{"rendered":"CSS parser in Javascript"},"content":{"rendered":"<p><strong>Please note: the CSS parser is complete and documented in <a href=\"\/blog\/2009\/01\/16\/jquery-css-parser\/\">this post<\/a><\/strong><br \/>\nI had an idea to write a CSS parser to allow custom jQuery attributes, since a lot of the jQuery I use is more presentation than behavior, and the redesign of the YI website allows for switching stylesheets, which may require different plugins to be applied. My idea would be to allow something like:<br \/>\n<code><br \/>\ndiv {<br \/>\n-jquery-round: 5;<br \/>\n-jquery-gradient: {from: '#008800', to: '#000088'}<br \/>\n}<br \/>\n<\/code><br \/>\nBut I never did anything about until Andy Kent developed <a href=\"http:\/\/andykent.bingodisk.com\/bingo\/public\/jss\/\">JSS<\/a> which does something similar for CSS selectors that a browser can&#8217;t handle but that jQuery can. His code also includes a cache for selectors that implements partial selector caching (thus <code>div span img<\/code> would also search the cache for <code>div<\/code> and <code>div span<\/code> as well). I emailed him back and forth a few times, and made some suggestions; my best css parser and selector cache are available <a href=\"\/blog\/blogfiles\/cssparser\/test.html\">here<\/a> (look at the code and use Firebug to look at the console). I still haven&#8217;t got the custom jQuery stuff together yet, but the pieces may be useful right now.<br \/>\n<strong>Please note: the CSS parser is complete and documented in <a href=\"\/blog\/2009\/01\/16\/jquery-css-parser\/\">this post<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Please note: the CSS parser is complete and documented in this post I had an idea to write a CSS parser to allow custom jQuery attributes, since a lot of the jQuery I use is more presentation than behavior, and the redesign of the YI website allows for switching stylesheets, which may require different plugins [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":2,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":1610,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions\/1610"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}