{"id":13605150,"url":"https://github.com/choojs/nanohref","last_synced_at":"2025-04-12T02:32:54.739Z","repository":{"id":41168912,"uuid":"88273230","full_name":"choojs/nanohref","owner":"choojs","description":"⛓ - Tiny href click handler library","archived":false,"fork":false,"pushed_at":"2019-09-04T15:48:31.000Z","size":16,"stargazers_count":41,"open_issues_count":1,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-18T23:18:12.282Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/choojs.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}},"created_at":"2017-04-14T14:13:51.000Z","updated_at":"2024-02-03T07:30:41.000Z","dependencies_parsed_at":"2022-09-08T05:41:12.513Z","dependency_job_id":null,"html_url":"https://github.com/choojs/nanohref","commit_stats":null,"previous_names":["yoshuawuyts/nanohref"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanohref","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanohref/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanohref/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/choojs%2Fnanohref/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/choojs","download_url":"https://codeload.github.com/choojs/nanohref/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223489740,"owners_count":17153818,"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-08-01T19:00:55.211Z","updated_at":"2024-11-07T09:31:33.935Z","avatar_url":"https://github.com/choojs.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# nanohref [![stability][0]][1]\n[![npm version][2]][3] [![build status][4]][5]\n[![downloads][8]][9] [![js-standard-style][10]][11]\n\nTiny href click handler library.\n\n## Usage\n```js\nvar nanohref = require('nanohref')\n\n// Handler automatically attached to window.document\nnanohref(function (location) {\n  console.log('new location is', location.pathname)\n})\n\n// Create DOM node\nvar el = document.createElement('a')\nel.setAttribute('href', '/my-link')\nel.innerText = 'Click me'\ndocument.body.appendChild(el)\n\n// Trigger click\nel.click()\n// =\u003e \"new location is /my-link\"\n```\n\n## Ignoring links\nBy default all href links are handled. The event is not handled under the\nfollowing conditions:\n- the click event had `.preventDefault()` called on it\n- the link has a `data-nanohref-ignore` attribute\n- the link has a `target=\"_blank\"` attribute with `rel=\"noopener noreferrer\"`\n- a modifier key is enabled (e.g. `ctrl`, `alt`, `shift` or `meta`)\n- the link's href starts with protocol handler such as `mailto:` or `dat:`\n- the link points to a different host\n- the link has a `download` attribute\n\n:warning: Note that we only handle `target=_blank` if they also have\n`rel=\"noopener noreferrer\"` on them. This is needed to [properly sandbox web\npages](https://mathiasbynens.github.io/rel-noopener/). Once `noopener` [becomes\nmore widespread](http://caniuse.com/#feat=rel-noopener), we can drop\n`noreferrer` too (currently just 60% of browsers in use support it).\n\n## API\n### `nanohref(handler(location), [rootNode])`\nCreate a new anchor click handler. The second argument is for the root node,\nwhich defaults to `window.document`.\n\n## See Also\n- [MDN/link-types](https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types)\n- [caniuse/rel=noopener](http://caniuse.com/#feat=rel-noopener)\n- [mapbox/link-hijacker](https://github.com/mapbox/link-hijacker)\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square\n[1]: https://nodejs.org/api/documentation.html#documentation_stability_index\n[2]: https://img.shields.io/npm/v/nanohref.svg?style=flat-square\n[3]: https://npmjs.org/package/nanohref\n[4]: https://img.shields.io/travis/choojs/nanohref/master.svg?style=flat-square\n[5]: https://travis-ci.org/choojs/nanohref\n[6]: https://img.shields.io/codecov/c/github/choojs/nanohref/master.svg?style=flat-square\n[7]: https://codecov.io/github/choojs/nanohref\n[8]: http://img.shields.io/npm/dm/nanohref.svg?style=flat-square\n[9]: https://npmjs.org/package/nanohref\n[10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[11]: https://github.com/feross/standard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanohref","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchoojs%2Fnanohref","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchoojs%2Fnanohref/lists"}