Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["latest"]
"presets": ["@babel/preset-env"]
}
74 changes: 34 additions & 40 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
{
"rules": {
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
],
"no-console": 0,
"max-len": [1, 160],
"quote-props": [1, "consistent-as-needed"],
"no-cond-assign": [2, "except-parens"],
"radix": 0,
"keyword-spacing": 0,
"one-var": 0,
"func-names": 0,
"padded-blocks": 0,
"computed-property-spacing": [2, "always"],
"space-infix-ops": 0,
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
"space-before-function-paren": 2,
"space-in-parens": [2, "always"],
"key-spacing": [2, { "align": "colon", "beforeColon": true, "afterColon": true }],
"brace-style": [2, "allman", { "allowSingleLine": true }]
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"globals": {
"describe": true,
"it": true
},
"extends": "airbnb/base"
"rules": {
"sourceType": "module",
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"no-console": 0,
"max-len": [1, 160],
"quote-props": [1, "consistent-as-needed"],
"no-cond-assign": [2, "except-parens"],
"radix": 0,
"keyword-spacing": 0,
"one-var": 0,
"func-names": 0,
"padded-blocks": 0,
"computed-property-spacing": [2, "always"],
"space-infix-ops": 0,
"no-unused-vars": [1, { "vars": "local", "args": "none" }],
"space-before-function-paren": 2,
"key-spacing": [
2,
{ "align": "colon", "beforeColon": true, "afterColon": true },
],
},
"env": {
"es6": true,
"browser": true,
"node": true,
},
"globals": {
"describe": true,
"it": true,
"beforeEach": true,
"expect": true,
"unique": true,
},
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 80,
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always"
}
59 changes: 22 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
unique-selector
===============
# unique-selector

[![Build Status](https://travis-ci.org/ericclemmons/unique-selector.png)](https://travis-ci.org/ericclemmons/unique-selector)
[![CocoaPods](https://img.shields.io/cocoapods/l/AFNetworking.svg)]()
Expand All @@ -8,7 +7,6 @@ unique-selector
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);

Expand All @@ -17,16 +15,15 @@ This is particularly useful when tracking in custom variables in analytics:

Selector uniqueness is determined based on the given element's root node. Elements rendered within Shadow DOM will derive a selector unique within the associated ShadowRoot context. Otherwise, a selector unique within an element's owning document will be derived.

Installation
------------
## Installation

[![NPM](https://nodei.co/npm/unique-selector.png?mini=true)](https://nodei.co/npm/unique-selector/)

Options
------------
## Options

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

```
```
import unique from 'unique-selector';

// Optional Options
Expand All @@ -52,64 +49,52 @@ options = {
unique( DomElement, options ); // [test="2"]
```


Tests
-----
## Tests

$ npm run test


Contributing
-----
## Contributing

Feel free to open issues, make suggestions or send PRs.
This project adheres to the Contributor Covenant [code of conduct](http://contributor-covenant.org/). By participating, you are expected to uphold this code.


Contact
-----
## Contact

Avraam Mavridis : [@avraamakis](https://twitter.com/avraamakis)

Eric Clemmons : [@ericclemmons](https://twitter.com/ericclemmons)


Releases
--------
## Releases

- v2.1.0

-

- 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.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](https://github.com/ericclemmons/unique-selector/pull/9))
- Handle extra whitespace in `className` ([#9](https://github.com/ericclemmons/unique-selector/pull/9))

- v0.0.3

- Add support for various `<form>` elements ([#2](https://github.com/ericclemmons/unique-selector/issues/2))
- Add support for various `<form>` elements ([#2](https://github.com/ericclemmons/unique-selector/issues/2))

- v0.0.2

- Fix bug with `nth-child` calculation
- Fix bug with `nth-child` calculation

- v0.0.1

- Initial release
- Initial release



License
-------
## License

MIT


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/AvraamMavridis/unique-selector/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/AvraamMavridis/unique-selector/trend.png)](https://bitdeli.com/free 'Bitdeli Badge')
Loading