permit abstract classes (an abstract class being a class without an "initialize" method) as parent classes, final patch from tschaub, r=tschaub (closes #1987)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9091 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -41,19 +41,17 @@ OpenLayers.Class = function() {
|
||||
// make the class passed as the first argument the superclass
|
||||
if(i == 0 && len > 1) {
|
||||
initialize = arguments[i].prototype.initialize;
|
||||
if(typeof initialize === "function") {
|
||||
// replace the initialize method with an empty function,
|
||||
// because we do not want to create a real instance here
|
||||
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;
|
||||
// replace the initialize method with an empty function,
|
||||
// because we do not want to create a real instance here
|
||||
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
|
||||
if(initialize === undefined) {
|
||||
delete arguments[i].prototype.initialize;
|
||||
} else {
|
||||
// if someone uses Class to mix objects, we don't want to
|
||||
// mess with the prototype
|
||||
extended = new arguments[i];
|
||||
arguments[i].prototype.initialize = initialize;
|
||||
}
|
||||
}
|
||||
// get the prototype of the superclass
|
||||
|
||||
Reference in New Issue
Block a user