Skip to content

Commit

Permalink
skip ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenie committed Jun 14, 2018
1 parent af9f179 commit b49d9ee
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
[![Build Status](https://travis-ci.org/lbenie/qselector.svg?branch=master)](https://travis-ci.org/lbenie/qselector)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/lbenie/qselector/master)](https://stryker-mutator.github.io)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![license](https://img.shields.io/github/license/lbenie/qselector.svg)](https://github.com/lbenie/qselector)
[![Known Vulnerabilities](https://snyk.io/test/github/lbenie/qselector/badge.svg?targetFile=package.json)](https://snyk.io/test/github/lbenie/qselector?targetFile=package.json)
[![npm](https://img.shields.io/npm/v/qselector.svg)](https://github.com/lbenie/qselector)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/qselector.svg)](https://github.com/lbenie/qselector)
[![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/qselector.svg)](https://github.com/lbenie/qselector)

qselector (query selector) is just a small package to create aliases for `querySelector` and `querySelectorAll` to `$` and `$$` respectively.
qselector (query selector) is just a small package to create aliases for
`querySelector` and `querySelectorAll` to `$` and `$$` respectively.

## API
The api is pretty simple. Each functions receive a DOMElement and returns either the node or a list of node.

The api is pretty simple. Each functions receive a DOMElement and returns either
the node or a list of node.

**Example**

```html
<div class="test">
<span>s</span>
Expand All @@ -24,9 +32,10 @@ The api is pretty simple. Each functions receive a DOMElement and returns either
**$(el, selector)**

Returns the first match of `selector` on `el` and its children

```js
let node = $('div');
/* node value
let node = $('div');
/* node value
<div class="test">
<span class="test">s</span>
<span>t</span>
Expand All @@ -36,28 +45,30 @@ Returns the first match of `selector` on `el` and its children
</div>
*/

node = $('span', '.test');
/* node value
node = $('span', '.test');
/* node value
<span>s</span>
*/
```

**$$(el, selector)**

Returns the list of all matches of `selector` on `el` and its children

```js
let node = $$('div');
/* node value
let node = $$('div');
/* node value
[div.test, div.retest]
*/

node = $$('.test', 'span');
/* node value
node = $$('.test', 'span');
/* node value
[span, span]
*/
```

## Installation

```bash
$ yarn add qselector
```
Expand All @@ -69,24 +80,24 @@ or
```

## License

(MIT)

Copyright (c) 2018 Lucien Bénié

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit b49d9ee

Please sign in to comment.