Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

yields/uniq-selector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

get a uniq css selector from element.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •