unique-selector

WebJar for unique-selector

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

unique-selector
Last Version

Last Version

0.4.1
Release Date

Release Date

Type

Type

jar
Description

Description

unique-selector
WebJar for unique-selector
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ericclemmons/unique-selector

Download unique-selector

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/unique-selector/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>unique-selector</artifactId>
    <version>0.4.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/unique-selector/
implementation 'org.webjars.npm:unique-selector:0.4.1'
// https://jarcasting.com/artifacts/org.webjars.npm/unique-selector/
implementation ("org.webjars.npm:unique-selector:0.4.1")
'org.webjars.npm:unique-selector:jar:0.4.1'
<dependency org="org.webjars.npm" name="unique-selector" rev="0.4.1">
  <artifact name="unique-selector" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='unique-selector', version='0.4.1')
)
libraryDependencies += "org.webjars.npm" % "unique-selector" % "0.4.1"
[org.webjars.npm/unique-selector "0.4.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

unique-selector

Build Status CocoaPods semantic-versioning

Given a DOM node, return a unique CSS selector matching only that element. This is particularly useful when tracking in custom variables in analytics:

document.addEventListener('click', function(event) {
    var selector = unique(event.target);

    _gaq.push(['_trackEvent', 'Engagement', 'Click', selector]);
}, false);

Installation

NPM

Options

e.g.1 DomElement = <span id="test"></span>

import unique from 'unique-selector';

// Optional Options
options = {
    // Array of selector types based on which the unique selector will generate
    selectorTypes : [ 'ID', 'Class', 'Tag', 'NthChild' ]
}

unique( DomElement, options ); // #test

e.g.2 DomElement = <span test="2"></span>

import unique from 'unique-selector';

// Optional Options
options = {
    // Array of selector types based on which the unique selector will be generate
    selectorTypes : [ 'Attributes' ]
}

unique( DomElement, options ); // [test="2"]

e.g.3 DomElement = <div id="xyz" class="abc test"></div>

import unique from 'unique-selector';

// Optional Options
options = {
    // Regular expression of ID and class names to ignore
    excludeRegex : RegExp( 'xyz|abc' )
}

unique( DomElement, options ); // .test

Tests

$ npm run test

Contributing

Feel free to open issues, make suggestions or send PRs. This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code.

Contact

Avraam Mavridis : @avraamakis

Eric Clemmons : @ericclemmons

Releases

  • v0.1.0

    • Big refactor/rewrite using es6
    • More test + Change the test script
    • Script to compile es6 to es5 using babel
    • Ability to pass options for the selectorTypes based on which the unique selector will be generated, see the options
  • v0.0.4

    • Handle extra whitespace in className (#9)
  • v0.0.3

    • Add support for various <form> elements (#2)
  • v0.0.2

    • Fix bug with nth-child calculation
  • v0.0.1

    • Initial release

License

MIT

Bitdeli Badge

Versions

Version
0.4.1
0.3.6