{"id":15537330,"url":"https://github.com/nullvoxpopuli/should-handle-link","last_synced_at":"2025-04-23T13:43:58.954Z","repository":{"id":253272148,"uuid":"842765805","full_name":"NullVoxPopuli/should-handle-link","owner":"NullVoxPopuli","description":"Utility for handling link clicks with event delegation.","archived":false,"fork":false,"pushed_at":"2024-11-21T15:37:36.000Z","size":113,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T05:14:37.359Z","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/NullVoxPopuli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-08-15T03:15:11.000Z","updated_at":"2025-02-12T02:48:08.000Z","dependencies_parsed_at":"2024-08-15T17:15:52.099Z","dependency_job_id":"032ccbcb-e279-42e6-adb6-73afd2703748","html_url":"https://github.com/NullVoxPopuli/should-handle-link","commit_stats":null,"previous_names":["nullvoxpopuli/should-handle-link"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fshould-handle-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fshould-handle-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fshould-handle-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NullVoxPopuli%2Fshould-handle-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NullVoxPopuli","download_url":"https://codeload.github.com/NullVoxPopuli/should-handle-link/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250441570,"owners_count":21431185,"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-10-02T11:56:11.474Z","updated_at":"2025-04-23T13:43:58.935Z","avatar_url":"https://github.com/NullVoxPopuli.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# should-handle-link\n\nA utility to help libraries and frameworks handle `\u003ca\u003e` clicks, properly handling all the default behavior that comes with clicking links (ctrl+click, cmd+click, etc).\n\nThis allows folks to usue a single event listener on the document to handle all the links in their app.\n\n\n## Installation\n\n```bash\npnpm add should-handle-link\n```\n\n## Usage\n\n```js\nimport { shouldHandle, getAnchor } from 'should-handle-link';\n\nfunction handler(event) {\n    let anchor = getAnchor(event);\n\n    if (!shouldHandle(location.href, anchor, event)) {\n        return;\n    }\n\n    event.preventDefault();\n    event.stopImmediatePropagation();\n    event.stopPropagation();\n    // Do single-page-app routing, \n    // or some other manual handling of the clicked anchor element\n}\n\ndocument.body.addEventListener('click', handler);\n```\n\n## License \n\nMIT\n\n## Related projects \n\n- [internal-nav-helper](https://github.com/HenrikJoreteg/internal-nav-helper)\n    This porject has narrower scope and doesn't cover as many use cases (and is also outdated).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullvoxpopuli%2Fshould-handle-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnullvoxpopuli%2Fshould-handle-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnullvoxpopuli%2Fshould-handle-link/lists"}