News for hackers. Stuff that matters.
Re:HTML event handler attributes: down the rabbit hole by megous on Tuesday May 03, 2022 @11:51AM (#31249793)
> This comment has a good explanation: https://news.ycombinator.com/item?id=31173042

Not really..., neither memory leaks, nor missing the addition of event handling to newly added DOM elements is a problem for the addEventListener solution.

If the codebase is using JSON submitted forms almost everywhere, it's easier to build that feature more declaratively, by adding support for a special enctype attribute value (using one global addEventListener that would handle it), for example:

   <form enctype="application/json"> ...
That would be more in line with how other features of the <form> element work.

addEventListener solution is also better if you decide to add CSP in the future.

There are no comments on this comment yet.