{"id":13447845,"url":"https://github.com/ericclemmons/unique-selector","last_synced_at":"2025-05-16T11:05:59.413Z","repository":{"id":5883246,"uuid":"7101060","full_name":"ericclemmons/unique-selector","owner":"ericclemmons","description":"Given a DOM node, return a unique CSS selector matching only that element","archived":false,"fork":false,"pushed_at":"2023-10-16T15:20:31.000Z","size":214,"stargazers_count":267,"open_issues_count":17,"forks_count":57,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-12T05:52:18.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericclemmons.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-12-10T21:25:55.000Z","updated_at":"2025-04-17T15:20:14.000Z","dependencies_parsed_at":"2024-06-18T13:53:07.309Z","dependency_job_id":null,"html_url":"https://github.com/ericclemmons/unique-selector","commit_stats":{"total_commits":75,"total_committers":18,"mean_commits":4.166666666666667,"dds":0.5733333333333333,"last_synced_commit":"dbbb4a90534ae0120608cee641f21f3549c5f785"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Funique-selector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Funique-selector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Funique-selector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericclemmons%2Funique-selector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericclemmons","download_url":"https://codeload.github.com/ericclemmons/unique-selector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518383,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:28.454Z","updated_at":"2025-05-16T11:05:54.380Z","avatar_url":"https://github.com/ericclemmons.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"unique-selector\n===============\n\n[![Build Status](https://travis-ci.org/ericclemmons/unique-selector.png)](https://travis-ci.org/ericclemmons/unique-selector)\n[![CocoaPods](https://img.shields.io/cocoapods/l/AFNetworking.svg)]()\n[![semantic-versioning](https://img.shields.io/badge/semantic%20-versioning-green.svg)]()\n\nGiven a DOM node, return a unique CSS selector matching only that element.\nThis is particularly useful when tracking in custom variables in analytics:\n\n\n    document.addEventListener('click', function(event) {\n        var selector = unique(event.target);\n\n        _gaq.push(['_trackEvent', 'Engagement', 'Click', selector]);\n    }, false);\n\n\nInstallation\n------------\n\n[![NPM](https://nodei.co/npm/unique-selector.png?mini=true)](https://nodei.co/npm/unique-selector/)\n\nOptions\n------------\ne.g.1 DomElement = `\u003cspan id=\"test\"\u003e\u003c/span\u003e`\n\n```\nimport unique from 'unique-selector';\n\n// Optional Options\noptions = {\n    // Array of selector types based on which the unique selector will generate\n    selectorTypes : [ 'ID', 'Class', 'Tag', 'NthChild' ]\n}\n\nunique( DomElement, options ); // #test\n```\n\ne.g.2 DomElement = `\u003cspan test=\"2\"\u003e\u003c/span\u003e`\n\n```\nimport unique from 'unique-selector';\n\n// Optional Options\noptions = {\n    // Array of selector types based on which the unique selector will be generate\n    selectorTypes : [ 'Attributes' ]\n}\n\nunique( DomElement, options ); // [test=\"2\"]\n```\n\ne.g.3 DomElement = `\u003cdiv id=\"xyz\" class=\"abc test\"\u003e\u003c/div\u003e`\n\n```\nimport unique from 'unique-selector';\n\n// Optional Options\noptions = {\n    // Regular expression of ID and class names to ignore\n    excludeRegex : RegExp( 'xyz|abc' )\n}\n\nunique( DomElement, options ); // .test\n```\n\n\nTests\n-----\n\n    $ npm run test\n\n\nContributing\n-----\nFeel free to open issues, make suggestions or send PRs.\nThis project adheres to the Contributor Covenant [code of conduct](http://contributor-covenant.org/). By participating, you are expected to uphold this code.\n\n\nContact\n-----\n\nAvraam Mavridis : [@avraamakis](https://twitter.com/avraamakis)\n\nEric Clemmons : [@ericclemmons](https://twitter.com/ericclemmons)\n\n\nReleases\n--------\n- v0.1.0\n\n    - Big refactor/rewrite using es6\n    - More test + Change the test script\n    - Script to compile es6 to es5 using babel\n    - Ability to pass options for the **selectorTypes** based on which the unique selector will be generated, see the options\n\n\n- v0.0.4\n\n    - Handle extra whitespace in `className` ([#9](https://github.com/ericclemmons/unique-selector/pull/9))\n\n- v0.0.3\n\n    - Add support for various `\u003cform\u003e` elements ([#2](https://github.com/ericclemmons/unique-selector/issues/2))\n\n- v0.0.2\n\n    - Fix bug with `nth-child` calculation\n\n- v0.0.1\n\n    - Initial release\n\n\n\nLicense\n-------\n\nMIT\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/AvraamMavridis/unique-selector/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Funique-selector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericclemmons%2Funique-selector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericclemmons%2Funique-selector/lists"}