Made instanceof reflection work for class hierarchies. r=elemoine,pvalsecc (closes #1802)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@8445 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
* To create a new OpenLayers-style class with multiple inheritance, use the
|
||||
* following syntax:
|
||||
* > var MyClass = OpenLayers.Class(Class1, Class2, prototype);
|
||||
* Note that instanceof reflection will only reveil Class1 as superclass.
|
||||
* Class2 ff are mixins.
|
||||
*
|
||||
*/
|
||||
OpenLayers.Class = function() {
|
||||
@@ -33,9 +35,21 @@ OpenLayers.Class = function() {
|
||||
}
|
||||
};
|
||||
var extended = {};
|
||||
var parent;
|
||||
var parent, initialize;
|
||||
for(var i=0, len=arguments.length; i<len; ++i) {
|
||||
if(typeof arguments[i] == "function") {
|
||||
// make the class passed as the first argument the superclass
|
||||
if(i == 0 && len > 1) {
|
||||
// replace the initialize method with an empty function,
|
||||
// because we do not want to create a real instance here
|
||||
initialize = arguments[i].prototype.initialize;
|
||||
arguments[i].prototype.initialize = function() {};
|
||||
// the line below makes sure that the new class has a
|
||||
// superclass
|
||||
extended = new arguments[i];
|
||||
// restore the original initialize method
|
||||
arguments[i].prototype.initialize = initialize;
|
||||
}
|
||||
// get the prototype of the superclass
|
||||
parent = arguments[i].prototype;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user