{"name":"cssauron","version":"0.0.2","description":"create matching selectors from css for your very own nested object hierarchy","main":"index.js","directories":{"test":"test"},"scripts":{"test":"node test/index.js"},"repository":{"type":"git","url":"git://github.com/chrisdickinson/cssauron.git"},"keywords":["css","selector","parser","match"],"author":{"name":"Chris Dickinson","email":"chris@neversaw.us"},"license":"MIT","_id":"cssauron@0.0.2","dist":{"shasum":"6812797e6f2ac2cb9a695a92df7c420ee4dc6a62","tarball":"http://registry-npm.ywwl.com/cssauron/download/cssauron-0.0.2.tgz","integrity":"sha512-X5+T9pTei29+XKco7UXo+UXzA2TDH//XDUEa86MrSWu/Zumptogq/qdJZ59+NmmKfVKx/P/cLTkqzAuREr6j2Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2KMTb4zkgk1RQsfRdxVayj0wTJeBah+kQS/dmxIA4hwIgbqLEMK28+Pf0g2PM3dzcpFnhpzH8geZQodJob4AEJPc="}],"size":3971,"noattachment":false,"key":"/cssauron/-/cssauron-0.0.2.tgz"},"maintainers":[{"name":"chrisdickinson","email":"chris@neversaw.us"}],"readme":"# cssauron\n\nbuild a matching function in CSS for any nested object structure!\n\n```javascript\nvar language = require('cssauron')({\n    tag: 'tagName'\n  , contents: 'innerText'\n  , id: 'id'\n  , class: 'className'\n  , parent: 'parentNode'\n  , children: 'childNodes'\n  , attr: 'getAttribute(attr)'\n})\n\nvar selector = language('body > #header .logo')\n  , element = document.getElementsByClassName('logo')[0]\n\nif(selector(element)) {\n  // element matches selector\n} else {\n  // element does not match selector\n}\n```\n\nIt's easy to use with your favorite nested tree structures!\nDelicious with HTML! Digestable with JSON!\n\n| HTML | JSON | GLSL AST | JS AST (Esprima) |\n|------|------|----------|------------------------|\n| [cssauron-html](http://npm.im/cssauron-html) | [cssauron-json](http://npm.im/cssauron-json) | [cssauron-glsl](http://npm.im/cssauron-glsl) | [cssauron-falafel](http://npm.im/cssauron-falafel) |\n\n\n# API\n\n### require('cssauron')(options) -> selector factory\n\nImport `cssauron` and configure it for the nested object structure you'll\nwant to match against.\n\n#### options\n\n`options` are an object hash of lookup type to string attribute or `function(node)` lookups for queried\nnodes. You only need to provide the configuration necessary for the selectors you're planning on creating.\n(If you're not going to use `#id` lookups, there's no need to provide the `id` lookup in your options.)\n\n* `tag`: Extract tag information from a node for `div` style selectors.\n* `contents`: Extract text information from a node, for `:contains(xxx)` selectors.\n* `id`: Extract id for `#my_sweet_id` selectors.\n* `class`: `.class_name`\n* `parent`: Used to traverse up from the current node, for composite selectors `body #wrapper`, `body > #wrapper`.\n* `children`: Used to traverse from a parent to its children for sibling selectors `div + span`, `a ~ p`.\n* `attr`: Used to extract attribute information, for `[attr=thing]` style selectors.\n\n### selector_factory('some selector') -> match function\n\nCompiles a matching function.\n\n### match(node) -> false | node | [subjects, ...]\n\nReturns false if the provided node does not match the selector. Returns truthy if the provided\nnode *does* match. Exact return value is determined by the selector, based on\nthe [CSS4 subject selector spec](http://dev.w3.org/csswg/selectors4/#subject): if only\na single node is matched, only that node is returned. If multiple subjects are matched,\na deduplicated array of those subjects are returned.\n\nFor example, given the following HTML (and `cssauron-html`):\n\n```html\n<div id=\"gary-busey\">\n    <p>\n        <span class=\"jake-busey\">\n        </span>\n    </p>\n</div>\n```\n\nChecking the following selectors against the `span.jake-busey` element yields:\n\n - `#gary-busey`: `false`, no match.\n - `#gary-busey *`: `span.jake-busey`, a single match.\n - `!#gary-busey *`: `div#gary-busey`, a single match using the `!` subject selector.\n - `#gary-busey *, p span`: `span.jake-busey`, a single match, though both selectors match.\n - `#gary-busey !* !*, !p > !span`: `[p, span.jake-busey]`, two matches.\n\n## Supported pseudoclasses \n\n - `:first-child`\n - `:last-child`\n - `:nth-child`\n - `:empty`\n - `:root`\n - `:contains(text)`\n - `:any(selector, selector, selector)`\n\n## Supported attribute lookups\n\n - `[attr=value]`: Exact match\n - `[attr]`: Attribute exists and is not false-y.\n - `[attr$=value]`: Attribute ends with value\n - `[attr^=value]`: Attribute starts with value\n - `[attr*=value]`: Attribute contains value\n - `[attr~=value]`: Attribute, split by whitespace, contains value.\n - `[attr|=value]`: Attribute, split by `-`, contains value.\n\n\n","publish_time":1353719839508,"_cnpm_publish_time":1353719839508,"dist-tags":{"latest":"1.4.0"}}