Creating a Type variable that refers to arguments[i]. Including parentheses when calling the constructor. r=elemoine (closes #2791)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10642 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -35,30 +35,31 @@ OpenLayers.Class = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
var extended = {};
|
var extended = {};
|
||||||
var parent, initialize;
|
var parent, initialize, Type;
|
||||||
for(var i=0, len=arguments.length; i<len; ++i) {
|
for(var i=0, len=arguments.length; i<len; ++i) {
|
||||||
if(typeof arguments[i] == "function") {
|
Type = arguments[i];
|
||||||
|
if(typeof Type == "function") {
|
||||||
// make the class passed as the first argument the superclass
|
// make the class passed as the first argument the superclass
|
||||||
if(i == 0 && len > 1) {
|
if(i == 0 && len > 1) {
|
||||||
initialize = arguments[i].prototype.initialize;
|
initialize = Type.prototype.initialize;
|
||||||
// replace the initialize method with an empty function,
|
// replace the initialize method with an empty function,
|
||||||
// because we do not want to create a real instance here
|
// because we do not want to create a real instance here
|
||||||
arguments[i].prototype.initialize = function() {};
|
Type.prototype.initialize = function() {};
|
||||||
// the line below makes sure that the new class has a
|
// the line below makes sure that the new class has a
|
||||||
// superclass
|
// superclass
|
||||||
extended = new arguments[i];
|
extended = new Type();
|
||||||
// restore the original initialize method
|
// restore the original initialize method
|
||||||
if(initialize === undefined) {
|
if(initialize === undefined) {
|
||||||
delete arguments[i].prototype.initialize;
|
delete Type.prototype.initialize;
|
||||||
} else {
|
} else {
|
||||||
arguments[i].prototype.initialize = initialize;
|
Type.prototype.initialize = initialize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get the prototype of the superclass
|
// get the prototype of the superclass
|
||||||
parent = arguments[i].prototype;
|
parent = Type.prototype;
|
||||||
} else {
|
} else {
|
||||||
// in this case we're extending with the prototype
|
// in this case we're extending with the prototype
|
||||||
parent = arguments[i];
|
parent = Type;
|
||||||
}
|
}
|
||||||
OpenLayers.Util.extend(extended, parent);
|
OpenLayers.Util.extend(extended, parent);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user