Permalink
Browse files

Fixing an infinite recursion bug caused when a module uses an include…

…d() hook to cause the including class to extend the module as well as include it.
  • Loading branch information...
1 parent 7c211f1 commit ece11601f4a4f3f1ce2ec2657bd8098cd3808dd6 @jcoglan jcoglan committed Aug 6, 2008
Showing with 19 additions and 1 deletion.
  1. +1 −1 source/class.js
  2. +18 −0 test/test.html
View
@@ -132,7 +132,7 @@ JS.extend(JS.Module.prototype, {
if (module.__inc__ && module.__fns__) {
this.__inc__.push(module);
module.__dep__.push(this);
- if (module.extended && options.extended) module.extended(options.extended);
+ if (options.extended) module.extended && module.extended(options.extended);
else module.included && module.included(options.included || this);
}
else {
View
@@ -195,6 +195,17 @@
}
});
+ ExtendingModule = new JS.Module({
+ someMethod: function() {
+ return 'I am working'
+ },
+ extend: {
+ included: function(base) {
+ base.extend(this);
+ }
+ }
+ });
+
//================================================================
//================================================================
@@ -784,6 +795,13 @@
assertEqual(klass, ModA.exts[1]);
}},
+ testIncludeCausingExtend: function() { with(this) {
+ var klass = new JS.Class({include: ExtendingModule});
+
+ assertEqual('I am working', klass.someMethod());
+ assertEqual('I am working', (new klass).someMethod());
+ }},
+
testClassDefinition: function() { with(this) {
var frog = new Animal('Kermit');
assertEqual('My name is Kermit and I like Ms. Piggy', frog.speak('Ms. Piggy'));

0 comments on commit ece1160

Please sign in to comment.