{"name":"cssauron","version":"0.2.0","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","dependencies":{"through":"X.X.X"},"bugs":{"url":"https://github.com/chrisdickinson/cssauron/issues"},"_id":"cssauron@0.2.0","dist":{"shasum":"d23ecc97c91e9fcb47e81e11590f7385c10708a4","tarball":"http://registry-npm.ywwl.com/cssauron/download/cssauron-0.2.0.tgz","integrity":"sha512-B1uN4n8f8eB1yDd5coq8Zaf4bZetBi5386BRpn2cgtjESEPwnRK8OgOk3qkeEAEmZfiJal6gBGYVrtAeO9J7rQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsMMeMUZhgW18FbitidzTKk6bwRhkhduc4RXQhwt+g7AIhAKOt68FFQYG2fQCgtQPTS9jODHnJdB+ed8BB2O109yRq"}],"size":5239,"noattachment":false,"key":"/cssauron/-/cssauron-0.2.0.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"chrisdickinson","email":"chris@neversaw.us"},"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":1373917404133,"_cnpm_publish_time":1373917404133,"dist-tags":{"latest":"1.4.0"}}