Quote:
Originally Posted by Dormilich
didn’t test it too extensively, but it seems that FF uses some sort of getter. while you can address the ID’d element as such (which I also deem a bad idea) the (var in window) test failed (and I didn’t find anything related in the Firebug DOM list).
PS. what does the second post have to do with the first? all 3 examples seem logical (eval() does have the window context, so the reference should work).
|
it's almost worse that you can't easily iterate the implicit globals without the dom. That was another big problem with the way IE6 did it, and did't easily let you figure out what names they'd stepped on.
two main issues:
1. novice coders: they already use eval() to get numbered form elements, now they will be eval'ing table rows and everything else under the sun. The forms alone were enough to get coders to recommend not using eval at all, this is just going to encourage that misguided directive to get broadcast even louder.
2. hampered sniffing. I like knowing that window.XML, window.URL, window.btoa, etc mean what they are supposed to. If the browser doesn't have the named method i look for, i do something else; no biggie. But, the way i've been determining the feature's presence, which is not uncommon, is to simply ask if(window.btoa){...}. I figure if it is taken, it's with a replacement polyfill.
Now i have to go back and retype them. the shortest one i could come up with is if(window.btoa && !window.btoa.id){...}. i guess for btoa, i could do "typeof btoa", but not all the native globals are functions, URL and alert in IE for example...
@felgall: while i agree that using local is good, i don't see what that has to do with the problems stemming from introducing new and novel globals. I mean, i was worred about all the new one like FormData, File, FileReader, etc, but moving IDs to globals blows the barn door off my stable of concerns. since the IDs are 2nd-class to user-defined globals, old code would work just the same in new browsers under global scope as it would locally in an anon function...