Although the DOM implementation in GWT is very good, one function that I personally use a lot has been missing since the beginning and is also not expected to be there in release 2.1, getElementsByClassName.
The function is similar to getElementsByTagName, but instead of matching all elements against the tag name (e.g. A, DIV) it matches against one or more CSS class names. In all modern browsers this function is implemented natively in the JavaScript document object. Quirksmode provides a good list on which browsers implement this and which do not.
In my library the function is in the com.xind.gwt.dom.client.DOM class, which has a generic implementation and specialized ones depending on the browsers capabilities. The generic implementation tests for the existence of the native function and uses it if available, if not, it uses a JavaScript implementation of it. For Internet Explorer the implementation never checks for the native function as no version implements it at this point.
Include the library in your build path and make sure you inherit the following module in your applications XML configuration file:
<inherits name=”com.xind.gwt.dom.DOM”/>
The library is licensed under the Apache License, Version 2.0 just like most of GWT. A copy of which can be obtained here.
As I use this library in my own projects, most of the testing has gone into my specific scenarios, do let me know if you find any issues.
The library can be downloaded here:
Post a Comment