7 ms·
> I noticed window.event which is documented in MDN and is marked as deprecated The Event API is not deprecated: https://developer.mozilla.org/en-US/docs/Web/A
by TAKEMYMONEY 4y ago
> I noticed window.event which is documented in MDN and is marked as deprecated
The Event API is not deprecated: https://developer.mozilla.org/en-US/docs/Web/API/Event https://developer.mozilla.org/en-US/docs/Web/API/Event. In the posted examples the `event` object implements the Event interface.
- spiralx 4y agoBut window.event is deprecated as you can see here: https://developer.mozilla.org/en-US/docs/Web/API/Window/event https://developer.mozilla.org/en-US/docs/Web/API/Window/even... It's been around since IE 4 and is the "current event being handled by the site's code" so it's event inside the scope of an event handler and undefined anywhere else. That's definitely an anti-feature lol, maybe IE 4 didn't pass the event object into an event handler's synthetic function as an argument and window.event was a bodge to allow for <div onclick="alert(event.button)"> ? Actually, I bet back then the code in the event handler attribute was just wrapped in eval() and executed, so you would need to have the event object in the global scope to be usable in the eval'd code.
- hnbad 4y agoThat is true, but also note that "deprecated" doesn't necessarily mean it's going away any time soon. The web platform is historically backwards compatible to a fault with the usual exceptions being mostly security-related (e.g. CORS) or "experimental" features that never saw widespread implementation.
- __ryan__ 4y agoRight, but it does mean “we suggest you don’t use this”.