Permalink
Browse files

Fixing bug that prevents you from binding the callSuper method and ca…

…lling it successfully later; helpful for methods that involve some async code.
  • Loading branch information...
1 parent 34dd764 commit a54f5bb885f501abbb34fe561d605ab5d050fff8 @jcoglan jcoglan committed Oct 1, 2008
Showing with 16 additions and 2 deletions.
  1. +2 −2 source/class.js
  2. +14 −0 test/test.html
View
@@ -202,7 +202,7 @@ JS.extend(JS.Module.prototype, {
chain: JS.mask( function(self, name, args) {
var callees = this.lookup(name),
- stackIndex = callees.length,
+ stackIndex = callees.length - 1,
currentSuper = self.callSuper,
params = JS.array(args),
result;
@@ -216,7 +216,7 @@ JS.extend(JS.Module.prototype, {
return returnValue;
};
- result = self.callSuper();
+ result = callees.pop().apply(self, params);
currentSuper ? self.callSuper = currentSuper : delete self.callSuper;
return result;
} ),
View
@@ -842,6 +842,20 @@
assertEqual('TopClass(2) extends SubClass(2) extends BaseClass(2)', top.getName());
}},
+ testBoundSuper: function() { with(this) {
+ var Parent = new JS.Class({
+ n: 4,
+ getNum: function() { return this.n }
+ });
+
+ var Child = new JS.Class(Parent, {
+ getNum: function() { return this.method('callSuper') }
+ });
+
+ var m = (new Child).getNum();
+ assertEqual(4, m());
+ }},
+
testInheritanceFromNativeClass: function() { with(this) {
var nat = new NativeClass();
assertEqual('Native', nat.getName());

0 comments on commit a54f5bb

Please sign in to comment.