{"id":22840686,"url":"https://github.com/compulim/event-target-properties","last_synced_at":"2026-02-15T15:06:11.282Z","repository":{"id":265195557,"uuid":"895341559","full_name":"compulim/event-target-properties","owner":"compulim","description":"Adds onevent property to EventTarget objects","archived":false,"fork":false,"pushed_at":"2025-12-31T07:49:21.000Z","size":127,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-04T08:55:40.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/event-target-properties","language":"TypeScript","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/compulim.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,"zenodo":null}},"created_at":"2024-11-28T02:58:36.000Z","updated_at":"2025-12-31T07:48:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"36440940-7bf0-4d31-9b36-8f2a95d47651","html_url":"https://github.com/compulim/event-target-properties","commit_stats":null,"previous_names":["compulim/event-target-properties"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/compulim/event-target-properties","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fevent-target-properties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fevent-target-properties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fevent-target-properties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fevent-target-properties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compulim","download_url":"https://codeload.github.com/compulim/event-target-properties/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fevent-target-properties/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29481925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T11:35:25.641Z","status":"ssl_error","status_checked_at":"2026-02-15T11:34:57.128Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-12-13T01:13:05.372Z","updated_at":"2026-02-15T15:06:11.268Z","avatar_url":"https://github.com/compulim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `event-target-properties`\n\nAdds `onevent` property to [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) objects.\n\n## Background\n\n[`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) is the official interface for objects which dispatch events and listeners to receive events.\n\nConventionally, in HTML, there are two types of event listeners:\n\n- [`addEventListener`/`removeEventListener` functions](https://developer.mozilla.org/en-US/docs/Web/Events/Event_handlers#eventtarget.addeventlistener)\n- [`onevent` properties](https://developer.mozilla.org/en-US/docs/Web/Events/Event_handlers#using_onevent_properties)\n\nHowever, `EventTarget` only offers `addEventListener`/`removeEventListener` functions, but not `onevent` properties.\n\nThis package enables `onevent` properties for objects that extends `EventTarget`.\n\n## How to use\n\nThe following code snippet adds `onload` property to an event target.\n\n```ts\nimport { EventTargetProperties, type TypedEventListener } from 'event-target-properties';\n\nclass MyEventTarget extends EventTarget {\n  constructor() {\n    super();\n\n    this.#eventTargetProperties = new EventTargetProperties(this);\n  }\n\n  #eventTargetProperties: EventTargetProperties\u003c'load', { load: CustomEvent }\u003e;\n\n  get onload(): TypedEventListener\u003cCustomEvent\u003e | undefined {\n    return this.#eventTargetProperties.getProperty('load');\n  }\n\n  set onload(value: TypedEventListener\u003cCustomEvent\u003e | null | undefined) {\n    this.#eventTargetProperties.setProperty('load', value);\n  }\n}\n```\n\n## Behaviors\n\n### The order of event listeners\n\n\u003e According to [HTML Living Standard](https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes).\n\nThe `onevent` property can be polyfilled via `addEventListener`/`removeEventListener` and follow the order designated by `EventTarget` class.\n\n- When the property is currently unassigned and being assigned, the event listener will be registered via `addEventListener`\n- When the property is currently assigned and being unassigned, it will be unregistered via `removeEventListener`\n- When the property is currently assigned and being assigned to another value, the event listener will not be re-registered again. Thus, the order of property event listener will be preserved\n\n## Contributions\n\nLike us? [Star](https://github.com/compulim/event-target-properties/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/event-target-properties/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/event-target-properties/pulls) a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fevent-target-properties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompulim%2Fevent-target-properties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fevent-target-properties/lists"}