ded / klass

a utility for creating expressive classes in JavaScript
751 stars 78 forks source link

cache old supr #1

Closed Kambfhase closed 13 years ago

Kambfhase commented 13 years ago

Within the closure loop you need to maintain a reference to any old vaue of the .supr property. See John Resigs simple inheritance.

Test case:

var A = klass({
    first: function(){
        return "first";
    },
    second: function(){
        return "second";
    }
}), B=A.extend(function(){}).methods({
    first: function(){
        this.second();
        return this.supr();
    },
    second: function(){
        return this.supr();
    }
});

console.log( new A().second()); // "second"
console.log( new A().first()); // "first"
console.log( new B().second()); // "second"
console.log( new B().first()); // "second", should be "first"

mfg Kambfhase

ded commented 13 years ago

you're right. we'll have a play on getting that working

fat commented 13 years ago

oh doi, nevermind

fat commented 13 years ago

fixed! thanks for pointing that out!