3.0.0 • Published 6 years ago

@tiaanduplessis/pika v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

pika

Efficient DOM element selection in 427 bytes (gzipped)

npm package version npm downloads standard JS linter Greenkeeper travis ci build status project license make a pull request

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!

  1. Fork it.
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Or open up a issue.

License

Licensed under the MIT License.

3.0.0

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.1

7 years ago

1.0.0

7 years ago