prototype: Ensure that classes always have an initialize method.

This commit is contained in:
Sam Stephenson 2007-08-21 16:15:59 +00:00
parent 6086db40a7
commit 001b54865c
3 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Ensure that classes always have an initialize method. [Mislav Marohnić]
* Update Template, Selector, Ajax.*, and ObjectRange classes to use the new class system. [Mislav Marohnić]
* Change Abstract.TimedObserver to subclass PeriodicalExecuter and tweak its subclasses to use new inheritance functionality. TimedObserver can now be stopped the same way as PeriodicalExecuter. Closes #8589. [Mislav Marohnić]

View File

@ -21,6 +21,9 @@ var Class = {
}
if (properties) Class.extend(klass, properties);
if (!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;
klass.prototype.constructor = klass;
return klass;

View File

@ -415,6 +415,9 @@
assertEqual('Nibbles: Hi!', pet.say('Hi!'));
assertEqual(Animal, pet.constructor, "bad constructor reference");
assertUndefined(pet.superclass);
var Empty = Class.create();
assert('object', typeof new Empty);
}},
testInheritance: function() { with(this) {