- From: Benjamin Gruenbaum <notifications@github.com>
- Date: Fri, 12 Nov 2021 03:22:21 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 12 November 2021 11:22:33 UTC
@mfreed7 I am happy to write the bikeshed - I think the proposal in this case is pretty straightforward: - `addEventListener` accepts `DOMString or Symbol` for `type`. - The `Event` constructor (as well as all subclasses implciitly) take a `DOMString or Symbol` for `type`. - Places in the spec that reference the fact event names are strings get those references fixed. The primary use case is enabling events without having possible naming collisions something like: ```js const myLibraryEvent = new Symbol('myLibrary'); const component = obtainElement(); // get any target component.addEventListener(myLibraryEvent, myLibraryLogicForEvent); // later, in other code, communicate without collisions component.dispatchEvent(new Event(myLibraryEvent)); ``` I can list use cases (it's mostly important in browsers where events propagate but also in Node.js and other EventTarget consumers) --- Let me know what details you'd need to make a decision on this and if you think this is interesting enough to prototype I'll try to open a PR to this repo next week'ish. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/331#issuecomment-967025831
Received on Friday, 12 November 2021 11:22:33 UTC