@tiaanduplessis/pika
v3.0.0
Published
Efficient DOM element selection
Downloads
6
Readme
pika
Efficient DOM element selection in 427 bytes (gzipped)
Table of Contents
Install
$ npm install @tiaanduplessis/pika
# OR
$ yarn add @tiaanduplessis/pika
Usage
The most relevant method for locating a DOM element will be chosen, because some times document.querySelector
won't do:
import pika from '@tiaanduplessis/pika'
pika('body') // document.body
pika('head') // document.head
pika('#foo') // document.getElementById
pika('.foo') // document.getElementsByClassName
pika('div') // document.getElementsByTagName
pika('[value]') // document.querySelectorAll
You can optionally specify your own context(defaults to document
):
// find span within #foo
pika('span', { context: pika('#foo') })
By default, the first
option is specified as true
. This results in the a single element being returned, in case of a single match, instead of a array.
Contributing
Contributions are welcome!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
License
Licensed under the MIT License.