This is hilarious:
A co-worker noticed something strange happening in his Chrome browser:
Every element in an HTML page that has an id
attribute gets attached
as a member of the global window
object!
I checked and it happens in my Safari as well. A bit of googling led us
to the answer at
StackOverflow:
What is supposed to happen is that ‘named elements’ are added as apparent properties of the
document
object. This is a really bad idea, as it allows element names to clash with real properties ofdocument
.IE made the situation worse by also adding named elements as properties of the
window
object. This is doubly bad in that now you have to avoid naming your elements after any member of either thedocument
or thewindow
object you (or any other library code in your project) might want to use.
…
Opera copied IE, then WebKit joined in, and now both the previously-unstandardised practice of putting named elements on
document
properties, and the previously-IE-only practice of putting them onwindow
are being standardised by HTML5, whose approach is to document and standardise every terrible practice inflicted on us by browser authors, making them part of the web forever. So Firefox 4 will also support this.
This is such a funny turn of events. And a great metaphor for how these inner decisions are made in browser politics.