4 ms·
> This comment has a good explanation: https://news.ycombinator.com/item?id=31173042 https://news.ycombinator.com/item?id=31173042 Not really..., neither memo
by megous 5y ago
> This comment has a good explanation: https://news.ycombinator.com/item?id=31173042 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.