This method is used to apply standard ECMA 3 classes (prototype based) to random elements in a web page. It is inspired by the Actionscript's method with the same name.
The goal is that you can create reutilizable OOP based code and use it in a various documents without rewriting any part of it except the instanciation routine.
The major problem with OOP in modern browsers is that is difficult to extend the core classes of DOM in a crossbrowser maner. There are some issues related to this:
<coolinput type="text" /> and behave like a <input> subclass is not possible on client side.The idea here is to take any standard HTML/DOM element once it was previously instantiated by the browser engine and make it behave like it is inheriting all of our class functionality, including the constructor inicialization. That is what Object.registerClass does. Something like re-instanciate the elements adding custom functionality.
A simple example of usage. The following code takes all the input elements in a web page and make them behave like they were directly inheriting from the FieldDecorator class at the top of the prototype chain, maintaining his original class below. The FieldDecorator class is declared somewhere else in the code. Finally, Initilizes them passing 2 params to the constructor:
Object.registerClass("input",FieldDecorator,["#FF11AA","#AA3344"]);
Object.registerClass(element(s),class[,params array]);
A boolean indicating if the operation was sucessfull.
Tested and working on: IE5, IE55, I6, any gecko-based and Opera 7. IE5 has a limitation of 10 parameters for the constructor call.
Any object created with document.createElement is automatly mapped to the class if it was applied before to that kind of element.