Re:GetElementById vs. QuerySelector
by sillysaurusx on Thursday November 25, 2021 @10:58PM
(#29347374)
What an awful design. Why would it differ like that? No doubt some legacy baggage that was later turned into a justification.
[ Parent
| on HN ]
These APIs didn’t all come out the same time, so they weren’t designed to differ.
Instead they decided against doing live node lists in future but couldn’t change how the older methods work as that would break websites. In the world of DOM/JS you can’t really make breaking changes.
https://humanwhocodes.com/blog/2010/09/28/why-is-getelements... Has more context
Re:GetElementById vs. QuerySelector
by Ozzie_osman on Thursday November 25, 2021 @11:07PM
(#29347399)
I'd actually expect the opposite just from the names. I'd expect a selector to select a "live" node, and getElement to get a static one.