{"_id":"@derhuerst/snabbdom-selector","_rev":"2-8932af56711ca6aeea39d83e4de02d47","name":"@derhuerst/snabbdom-selector","description":"Snabbdom CSS-Selector","dist-tags":{"latest":"1.3.2"},"versions":{"1.3.2":{"name":"@derhuerst/snabbdom-selector","version":"1.3.2","description":"Snabbdom CSS-Selector","main":"lib/index.js","module":"lib/es6/index.js","typings":"lib/index.d.ts","scripts":{"test:lint":"tslint src/*.ts src/**/*.ts","test:unit":"cross-env TS_NODE_PROJECT=./test/tsconfig.json mocha -r ts-node/register test/*.ts","test":"npm run test:lint && npm run test:unit","build:cjs":"tsc -P tsconfig.json --module commonjs","build:es6":"tsc -P tsconfig.json --module es6 --outDir lib/es6","build":"npm run build:cjs && npm run build:es6"},"repository":{"type":"git","url":"git+https://github.com/tylors/snabbdom-selector.git"},"keywords":["Snabbdom","CSS","Selector"],"author":{"name":"Tylor Steinberger","email":"tlsteinberger167@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/tylors/snabbdom-selector/issues"},"homepage":"https://github.com/tylors/snabbdom-selector#readme","devDependencies":{"@types/mocha":"^2.2.32","@types/node":"^6.0.46","cross-env":"^3.1.3","mocha":"^3.1.2","snabbdom":"0.6.3","ts-node":"^1.6.1","tslint":"^3.15.1","typescript":"2.0.6"},"dependencies":{"cssauron2":"^2.0.1"},"gitHead":"181812df3c217f917b96cdeb1cf4663ce37d701f","_id":"@derhuerst/snabbdom-selector@1.3.2","_npmVersion":"5.4.2","_nodeVersion":"8.5.0","_npmUser":{"name":"derhuerst","email":"mail@jannisr.de"},"dist":{"integrity":"sha512-NIY0aqKIEvTXY/uAesn7+Sf9IsfOPzeqrentuJ3N5dKu7sT4HQk8jXnxWx9FPqaNQLMhUBGhoZnW7t6RPhMD9g==","shasum":"d4770bb2c29f72548dc1c63bc3280405791aba86","tarball":"https://registry.npmjs.org/@derhuerst/snabbdom-selector/-/snabbdom-selector-1.3.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9SRi45ZISgbVn2+kU+rgcwIVCYKdioxTkea9FyTV4PwIgb7qNIXZnX7RWYeUpsfM5iJuZr9Cj/usozzm0c0AQvk4="}]},"maintainers":[{"name":"derhuerst","email":"mail@jannisr.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/snabbdom-selector-1.3.2.tgz_1507916303112_0.16790686640888453"},"deprecated":"Use snabbdom-selector@2 instead."}},"readme":"# Snabbdom Selector [![ComVer](https://img.shields.io/badge/ComVer-compliant-brightgreen.svg)](https://github.com/staltz/comver)\n\n`snabbdom-selector` is a utility tool, written in TypeScript,\nto find snabbdom VNode objects matching a given CSS Selector.\n\n*Note:* **This is a temporary fork of [`TylorS/snabbdom-selector`](https://github.com/TylorS/snabbdom-selector)**, published as `@derhuerst/snabbdom-selector`. I'm waiting for [a PR](https://github.com/TylorS/snabbdom-selector/pull/21) to get merged.\n\n## This is for me!\n```sh\nnpm install @derhuerst/snabbdom-selector\n```\n\n## Basic Usage\n```js\nimport { select } from '@derhuerst/snabbdom-selector'\nimport * as h from 'snabbdom/h'\n\nconst vNode = h('div', {}, [\n  h('div.test', {}, [\n    h('p', {key: 1}, 'Foo')\n  ])\n])\n\nconst matches = select('.test p', vNode)\n\nconsole.log(matches)\n// => [{sel: 'p', text: 'Foo', elm: HTMLElement, key: 1, children: undefined, data: {...}}]\n```\n\n## API\n\n### `select(cssSelector: string, vNode: snabbdom.VNode): Array<snabbdom.VNode>`\n### `select(cssSelector: string): (vNode: snabbdom.VNode) => Array<snabbdom.VNode>`\n\nNote that there are 2 function signatures, this is because `select` is curried!\n\nThis is the main function provided by this library, it allows using a css selector to\nfind vNode's that are made from that css selector. The vNode used will be traversed, and\nany matches at any arbitrary depth will be returned inside of the resulting array. An empty\narray will be returned if no matches are found.\n\n```js\nimport { select } from '@derhuerst/snabbdom-selector'\n\nconst vNode = h('div', {}, [\n  h('div.test', {}, [\n    h('p', {key: 1}, 'Foo')\n  ])\n])\n\nconst match = select('.test p'); // if given 1 parameter it returns a new function!\nconst matches = match(vNode);\n\nconsole.log(matches)\n// => [{sel: 'p', text: 'Foo', elm: HTMLElement, key: 1, children: undefined, data: {...}}]\n```\n\n### `selectorParser(selector: string): Object`\n\nThis function given a CSS selector like that passed to snabbdom's `h` function, returns an object\ncontaining parsed tagName, id, and className.\n\n```js\nimport { selectorParser } from '@derhuerst/snabbdom-selector'\n\nconst { tagName, id, className } = selectorParser('div#foo.bar.baz');\n\nconsole.log(tagName) // div\nconsole.log(id) // foo\nconsole.log(className) // 'bar baz'\n```\n\n### `classNameFromVNode(vNode: snabbdom.VNode): string`\n\nThis function given a snabbdom VNode object will return its className including that contained\nwithin snabbdom's provided `props` and `class` modules.\n\n```js\nimport { classNameFromVNode } from '@derhuerst/snabbdom-selector'\n\nconst vNode = h('div.foo', { class: { bar: true } }, [])\n\nconsole.log(classNameFromVNode(vNode)) // 'foo bar'\n```\n\n## Versioning\nThis library uses [compatible versioning](https://github.com/staltz/comver), a versioning system\nthat is backwards compatible with semantic-versioning.\n","maintainers":[{"name":"derhuerst","email":"mail@jannisr.de"}],"time":{"modified":"2022-04-05T03:48:37.374Z","created":"2017-10-13T17:38:24.086Z","1.3.2":"2017-10-13T17:38:24.086Z"},"homepage":"https://github.com/tylors/snabbdom-selector#readme","keywords":["Snabbdom","CSS","Selector"],"repository":{"type":"git","url":"git+https://github.com/tylors/snabbdom-selector.git"},"author":{"name":"Tylor Steinberger","email":"tlsteinberger167@gmail.com"},"bugs":{"url":"https://github.com/tylors/snabbdom-selector/issues"},"license":"MIT","readmeFilename":"README.md"}