{"_id":"zest","_rev":"15-6f54eed5258f1e878c1cbff43cdc7f0f","name":"zest","time":{"modified":"2022-06-29T16:57:31.092Z","created":"2011-03-13T03:59:46.259Z","0.1.1":"2011-03-13T03:59:46.651Z","0.1.2":"2011-03-13T04:11:37.798Z","0.0.5":"2014-06-11T01:39:04.667Z","0.1.3":"2014-06-11T06:11:50.344Z"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"dist-tags":{"latest":"0.1.3"},"description":"Fast, lightweight, extensible css selector engine.","readme":"# Zest\n\n__zest__ is a fast, lightweight, and extensible CSS selector engine.\n\nZest was designed to be very concise while still supporting CSS3/CSS4\nselectors and remaining fast.\n\n## Usage\n\n``` js\nzest('section! > div[title=\"hello\" i] > :local-link /href/ h1');\n```\n\n## Benchmarks\n\nEach selector run 1000 times on Google Chrome 13 beta (ms):\n\n    benchmarking: `header > h1` 1000 times.\n    zest: 13\n    sizzle: 24\n    native: 13\n    benchmarking: `body > header > h1` 1000 times.\n    zest: 16\n    sizzle: 26\n    native: 13\n    benchmarking: `html a` 1000 times.\n    zest: 45\n    sizzle: 55\n    native: 12\n    benchmarking: `:first-child` 1000 times.\n    zest: 44\n    sizzle: 68\n    native: 11\n    benchmarking: `:only-child` 1000 times.\n    zest: 49\n    sizzle: 66\n    native: 12\n    benchmarking: `:not(a)` 1000 times.\n    zest: 51\n    sizzle: 125\n    native: 12\n    benchmarking: `h1 + time:last-child` 1000 times.\n    zest: 15\n    sizzle: 32\n    native: 13\n    benchmarking: `h1 + time[datetime]:last-child` 1000 times.\n    zest: 21\n    sizzle: 45\n    native: 14\n    benchmarking: `header > h1, :not(a)` 1000 times.\n    zest: 72\n    sizzle: 212\n    native: 17\n    benchmarking: `a[rel~=\"section\"]` 1000 times.\n    zest: 41\n    sizzle: 54\n    native: 11\n    benchmarking: `a, h1` 1000 times.\n    zest: 25\n    sizzle: 55\n    native: 11\n    benchmarking: `:nth-child(2n+1)` 1000 times.\n    zest: 82\n    sizzle: 97\n    native: 13\n\n__NOTE:__ If you want to run these benchmarks yourself make sure to turn off\nSizzle's (and Zest's) `document.querySelectorAll` delegation mechanism,\notherwise you will be benchmarking against `document.querySelectorAll`.\n\nZest will cache compiled selectors if it can't delegate to\n`document.querySelectorAll`, `document.getElementById`, or\n`document.getElementsByClassName` (depending). __The benchmark tests you see\nabove were performed with the caching mechanism disabled. If caching were\nenabled, Zest would be faster than the native `document.querySelectorAll`.__\n\n## Install\n\n``` bash\n$ npm install zest\n```\n\n## Notes\n\nZest currently includes support for ender.js, Prototype, and jQuery.\n\n__Unsupported Selectors:__ `:hover`, `:active`, `:link`, `:visited`, all pseudo\nelements, and namespaces.\n\n`:link`, `:visited`, and pseudo elements are unsupported for obvious reasons\n(they don't work). `:hover` and `:active` aren't supported because they examine\na dynamic state, you should be binding to events for this (`:focus` is\nsupported, but there is no fallback for legacy browsers).\n\n## Extension\n\nZest doesn't support (m)any non-standard selectors, but it is possible to add\nyour own.\n\n### Adding a simple selector\n\nAdding simple selectors is fairly straight forward. Only the addition of pseudo\nclasses and attribute operators is possible. (Adding your own \"style\" of\nselector would require changes to the core logic.)\n\nHere is an example of a custom `:name` selector which will match for an\nelement's `name` attribute: e.g. `h1:name(foo)`. Effectively an alias\nfor `h1[name=foo]`.\n\n``` js\n// if there was a parameter,\n// it gets closured as `param`\nzest.selectors[':name'] = function(param) {\n  return function(el) {\n    if (el.name === param) return true;\n  };\n};\n```\n\n__NOTE__: if you're pseudo-class does not take a parameter, there will be no\nclosure.\n\n### Adding an attribute operator\n\n``` js\n// `attr` is the attribute\n// `val` is the value to match\nzest.operators['!='] = function(attr, val) {\n  return attr !== val;\n};\n```\n\n### Adding a combinator\n\nAdding a combinator is a bit trickier. It may seem confusing at first because\nthe logic is upside-down. Zest interprets selectors from right to left.\n\nHere is an example how a parent combinator could be implemented:\n\n``` js\nzest.combinators['<'] = function(test) {\n  return function(el) { // `el` is the current element\n    el = el.firstChild;\n    while (el) {\n      // return the relevant element\n      // if it passed the test\n      if (el.nodeType === 1 && test(el)) {\n        return el;\n      }\n      el = el.nextSibling;\n    }\n  };\n};\n```\n\nThe `test` function tests whatever simple selectors it needs to look for, but\nit isn't important what it does. The most important part is that you return\nthe relevant element once it's found.\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your code\nto be distributed under the MIT license. You are also implicitly verifying that\nall code is your original work. `</legalese>`\n\n## License\n\n(c) Copyright 2011-2012, Christopher Jeffrey (MIT Licensed).\nSee LICENSE for more info.\n","versions":{"0.0.5":{"name":"zest","description":"Fast, lightweight, extensible css selector engine.","author":{"name":"Christopher Jeffrey"},"version":"0.0.5","main":"./lib/zest.js","ender":"./ext/zest.ender.js","preferGlobal":false,"scripts":{"install":"make"},"repository":{"type":"git","url":"git://github.com/chjj/zest.git"},"homepage":"https://github.com/chjj/zest","bugs":{"url":"https://github.com/chjj/zest/issues"},"keywords":["css","selector","engine"],"tags":["css","selector","engine"],"dependencies":{"uglify-js":"*"},"gitHead":"1511524bea11cf60fbcd62ef41c5abcee6389eb9","_id":"zest@0.0.5","_shasum":"1a6b76e2555b2fada8286ea6186b8050185b9385","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"dist":{"shasum":"1a6b76e2555b2fada8286ea6186b8050185b9385","tarball":"https://registry.npmjs.org/zest/-/zest-0.0.5.tgz","integrity":"sha512-1Yu7oeXjYo/6NSr4FNyQ7l4jVD/3T37fewmca3RTw/XzrLnFHSvRiWKKOXsESRV7xPXbLeDk+PR1kj7jHd/wew==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHpTXK9ThLEIB29VbUD0p++AptD9iCHPzaW2K16kV4jsAiABYKJvrClyJhvFxaT3lKhsIhk/ideE3wVa5lb/AGp2vQ=="}]}},"0.1.3":{"name":"zest","description":"Fast, lightweight, extensible css selector engine.","author":{"name":"Christopher Jeffrey"},"version":"0.1.3","main":"./lib/zest.js","ender":"./ext/zest.ender.js","preferGlobal":false,"scripts":{"install":"make"},"repository":{"type":"git","url":"git://github.com/chjj/zest.git"},"homepage":"https://github.com/chjj/zest","bugs":{"url":"https://github.com/chjj/zest/issues"},"keywords":["css","selector","engine"],"tags":["css","selector","engine"],"dependencies":{"uglify-js":"*"},"gitHead":"653ffcc43426bb1697776fb7ebe806ce481c4925","_id":"zest@0.1.3","_shasum":"47c6c3951454b475d38791dd8c972c66b2f5b184","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"chjj","email":"chjjeffrey@gmail.com"},"maintainers":[{"name":"chjj","email":"chjjeffrey@gmail.com"}],"dist":{"shasum":"47c6c3951454b475d38791dd8c972c66b2f5b184","tarball":"https://registry.npmjs.org/zest/-/zest-0.1.3.tgz","integrity":"sha512-DVHkF9xDHPPxb1CorRYsLVsF1nPmseEdWeHU811m3scirQ5X7FKe/M+wH8Mke0dK5n1YLdISYPWPxYJXpkUWGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBuhhcqUQXT+VVCaaBL+vi0Q5IMSTA4yzvjqQyMVpWAVAiEAzf2LDE44/N8tIYUL3Uq5OJOGQii9MbZBkR+s3hsc+zQ="}]}}},"homepage":"https://github.com/chjj/zest","keywords":["css","selector","engine"],"repository":{"type":"git","url":"git://github.com/chjj/zest.git"},"author":{"name":"Christopher Jeffrey"},"bugs":{"url":"https://github.com/chjj/zest/issues"},"readmeFilename":"README.md"}