- From: Runbing <notifications@github.com>
- Date: Tue, 09 Sep 2025 12:15:16 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1403@github.com>
runbing created an issue (whatwg/dom#1403) ### What is the issue with the DOM Standard? In [Section 2.1](https://dom.spec.whatwg.org/#introduction-to-dom-events), "Introduction to DOM Events," it says that the `addEventListener()` callback is "__typically a JavaScript Function__," suggesting that a regular function object is a valid argument. However, [Section 2.7](https://dom.spec.whatwg.org/#interface-eventtarget), the detailed specification for the `EventTarget` interface, states that the callback can only be __null or an EventListener object__ and does not explicitly mention that a regular function is allowed. As noted in [Section 2.4](https://webidl.spec.whatwg.org/#idl-callback-interfaces) of the Web IDL specification, callback interfaces like `EventListener` are primarily used for existing (older) DOM APIs. Newer APIs tend to use callback functions directly, allowing plain functions to be passed without requiring an object with a handleEvent method. Should Section 2.7 explicitly state that regular functions are allowed? Alternatively, is this behavior considered an implementation detail left to browsers, even if the spec doesn’t explicitly mention it? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1403 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1403@github.com>
Received on Tuesday, 9 September 2025 19:15:20 UTC