My proposal is for the browser to make the DOM more accessible through implicit calls to the ID array, class array and potentially other natural arrays such as attributes, etc.
Much of my javascripting is required by the lack of such access to these DOM objects. I think others will agree with me here. Why do I first need to create a variable then set it to an element(s) by class or id? Why can't I simply call that element directly? You might think this is a ECMA or Javascript feature but it's not... it is DOM scripting/manipulation/traversal and really should be a feature of the DOM itself or the implementation of it by the browser.
Each DOM object should pre-compile these arrays for me so I can grab elements/arrays of elements directly w/o having to resort to a javascript library to do the job for me.
Really this is just a browser/DOM implemented shortcut for getElementById and getElementByClassName, etc.
An example of this would be:
[code]<script language="javascript">
.myClass.onClick = function(){
this.style.display = (this.style.display == 'block') ? "none" : "block";
}
#myElementID.onSubmit = function(){
doSomething();
}
</script>[/code]
Additionally an implementation of XPATH would come in really handy here as well so that I can find child/parent/sibling elements easily again w/o needing a 3rd party library.
[code]
<script language="javascript">
(.toggleBlock >> a.toggleHandler).onClick = function(){
(this <> div.toggleBody).style.display = (this.style.display == 'block') ? "none" : "block";
}
// where >> means children and <> means sibling
</script>[/code]
The reasoning for this is twofold:
1) make code easier to write and read... no more vague variables holding already defined objects (don't define a class object array twice, once in the DOM and again in my custom variable)
2) speed up the whole thing and improve memory usage by moving these commonly used object arrays into the browser code (which is inherently more optimized and faster) as well as make these available as soon as the DOM is available (which currently requires a 3rd party library to ensure)