You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently discovered document.all in an effort to find more direct ways of referencing elements with an id attribute, like window.myElementId apparently works.
The getElementById method is safer (it will never return an HTMLCollection instead of an Element), more robust (consider the collisions that occur for ID values such as “__proto__”, “hasOwnProperty”, “length”, or even — given its own indexed access logic — “0”), and far less complicated.
Ah I see. If you did unfortunately have multiple elements with the same id then you get HTMLCollection not Element. Seems quite easy for a reasonable developer to avoid that as well as avoid accessing those other fields.
I recently discovered
document.all
in an effort to find more direct ways of referencing elements with an id attribute, likewindow.myElementId
apparently works.Anyway, I was disappointed to read that
document.all
is deprecated (https://developer.mozilla.org/en-US/docs/Web/API/Document/all) despite being supported by all current versions of major browsers.I'm not sure of any costs or legitimate issues with using
document.all
, but the DX is awesome:What's the harm with un-deprecating this property? #221 appears to be more or less okay with it 🤷♂️
The text was updated successfully, but these errors were encountered: