Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can anyone speak a bit more to that? I was wondering if this was just a convenience feature that browsers added or something that has been in Javascript all along?


Has been like this for as long as I can remember (at least back to IE6).


Yup - in fact there's an old bug that jQuery (in versions < 2, I believe) accounts for where IE would return elements with a name equal to the id you're searching for as the underlying system there was all wonky.

e.g:

    <input name="test">
    <div id="test">

    document.getElementById('test'); // <input> in IE6
I believe this also wound up in some Webkit and Opera releases, perhaps for emulation. Someone more knowledgeable about it all should feel free to correct me if I'm wrong though.

(Edited for code formatting, I don't comment too much these days)


yay, I wrote an article about that!

http://xem.github.io/articles/#implicitgetelementbyid_en

Cheers :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: