logoalt Hacker News

post-ityesterday at 2:01 PM5 repliesview on HN

> you would eliminate all usage of innerHTML

The mythical refactor where all deprecated code is replaced with modern code. I'm not sure it has ever happened.

I don't have an alternative of course, adding new methods while keeping the old ones is the only way to edit an append-only standard like the web.


Replies

thenewnewguyyesterday at 2:19 PM

If you want to adopt this in your project, you can add a linter that explicitly bans innerHTML (and then go fix the issues it finds). Obviously Mozilla cannot magically fix the code of every website on the web but the tools exist for _your_ website.

Vinnlyesterday at 2:18 PM

I kinda like the way JS evolved into a modern language, where essentially ~everyone uses a linter that e.g. prevents the use of `var`. Sure, it's technically still in the language, but it's almost never used anymore.

(Assuming transpilers have stopped outputting it, which I'm not confident about.)

show 4 replies
bulbaryesterday at 2:36 PM

It for sure happens for drop in replacements.

littlestymaaryesterday at 3:38 PM

Nobody's talking about old code here.

Having an alternative to innerHTML means you can ban it from new code through linting.

noduermeyesterday at 2:08 PM

Finally, a good use case for AI.

show 2 replies