[whatwg] [WHATWG] HTMLElement ids as global object properties
Alexandre.Morgaut at 4d.com
Fri Apr 1 00:26:52 PDT 2011
My biggest nightmare today is that recent browsers like Chrome, IE9, FF4 generate a global variable from the id of each HTMLElement of the document...
(even for Meta in the Head of the document)
It is know possible in these browser to write
domNode = myPanel;
domNode = window.myPanel;
domNode = document.getElementById('myPanel');
or with jQuery:
domNode = $('#myPanel');
Note that this behavior is not part of HTML4
It is neither part of HTML5
Let's imagine the effects of existing HTMLElements with id like "location", "document", "event", "toolbar", or even "window"...
What should be the list of reserved keywords for valid id value ?
All the BOM API ?
+ APIs like Web Storages, Web Sockets... ?
+ Global namespaces of common Ajax frameworks ?
And what about future HTML5/W3C APIs ?
And what about future or private frameworks ???
It is even one of the key part of the strict mode of ECMAScript 5
The values given to ids of an HTML document is part of the business logic of the web interface
Developers are encouraged to use a single global variable as their application specific namespace
if "document.getElementById()" is too long, why not coming back to the IE4 form "document.all()"
I would be more comfortable with at least a standard namespace global property like "elements" on window than the current situation
60, rue d'Alsace
Standard : +33 1 40 87 92 00
Email : Alexandre.Morgaut at 4d.com
Web : www.4D.com
More information about the whatwg