0.2.3 • Published 8 years ago

uniq-selector v0.2.3

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

uniq-selector

generate a uniq selector of the given element.

Installation

Install with component(1):

$ component install yields/uniq-selector

API

uniq(el)

this will continue recursively through the element parents until it reaches an id or <body>.

see example below.

Example

<i>
  <i id="foo" class="foo button">
    <i>
      <i>
        <i class="baz"></i>
      </i>
    </i>
  </i>
</i>
var uniq = require('uniq-selector');
var el = document.querySelector('.baz');
uniq(el);
// => i#foo.foo.button:nth-child(1) > i:nth-child(1) > i:nth-child(1) > i.baz:nth-child(1)

Tests

~ make test

notes

if you are interested in this component, please add more tests cases, it's super easy!

License

MIT

0.2.3

8 years ago

0.2.2

8 years ago