[whatwg/dom] "Web developers are strongly encouraged to inste..." (Issue #1123)

https://dom.spec.whatwg.org/commit-snapshots/6b3f055f3891a63423bf235d46f38ffdb298c2e7/#interface-window-extensions

> Web developers are strongly encouraged to instead rely on the Event object passed to event listeners, as that will result in more portable code\. This attribute is not available in workers or worklets, and is inaccurate for events dispatched in shadow trees\. 

Could a second note be added: 

"Note: This is not a deprecation notice, and this API will not be removed, but a warning of possible pitfalls in certain use cases".

A lot of people are wrongly assuming and marking this API as deprecated in programming tools and programming documentation, e.g. MDN https://developer.mozilla.org/en-US/docs/Web/API/Window/event, or wrongly marking it as deprecated in [IDE's](https://youtrack.jetbrains.com/issue/WEB-40773) and [lib.dom.d.ts](https://github.com/Microsoft/TypeScript/blob/main/lib/lib.dom.d.ts#L19501), which is misleading, adding strikethroughs everywhere in the code where this API is being used.

As per my comment on https://github.com/mdn/content/issues/21848, there are plenty of past, present and future valid use cases to use the readily available event and event.target object inside functions, and there's no problem at all for people to continue using it. 

By adding that note above, we can start clearing the air about those misleading deprecation notices, and start having them removed or replaced. 

As per my full comment above in #21848, I have been building javascript UX for years and that's the method I use for my user interactions, and I've never had an issue with it in 20 years.

I call the function from an onclick= attribute for example, and I access event.target inside the function, without passing "e", "event", or evaluating "if (e)", or whatever else, as simple as that, and has worked flawlessly.

This has been practical and eases the wiring information and function signatures from a purely pragmatic standpoint.

I always build my sites from scratch to never have to deal with new arbitrary premises and new levels of abstraction that frameworks create, and having "event" and "event.target" inside my functions readily and painlessly available has always worked perfectly.

The only issues I've ever seen with this is when frameworks come and mess with the natural behavior and flow of things.

But I've never had a single issue when developing sites from scratch, which is 100% of what I do.

I don't use frameworks, and I'm not planning to. One level of abstraction is enough for me.

I was just hoping to start clearing up those misleading deprecation notices in programming documentation and tools, and I think adding that clarifying comment on the spec would help.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1123
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1123@github.com>

Received on Wednesday, 26 October 2022 13:40:11 UTC