Extending objects with methods

Extending objects with methods


There are discussion in year ago about this
jQuery.extend: Make overridden functions available to "Subclass"
http://groups.google.com/group/jquery-dev/browse_thread/thread/12a5f52dad9123d7/e69639289b6ab9a1?q=extendSuper#e69639289b6ab9a1
Core = {
extendSuper: function(target, Super, $Class, options)
{
var __f;
var __super = new Super
(options);
jQuery.extend(true, target,
__super);
jQuery.extend(true, target,
$Class);
jQuery.extend(true, target,
options);
for(var f in __super){
if(jQuery.isFunction
(__super[f])){
__f = __super
[f];
__super[f] =
function(){
//?race
conditions
if(!
target.__top){

this.__top = {__target:target};
}else{

this.__top = target.__top
}

this.__top.__target.__super = this.__super;
var
__r = __f.apply(this.__top.__target, arguments);

this.__top.__target.__super = __super;
return
__r;
};
}
}
target.__super = __super;
}
}
this code works fine, but it's .apply() executes LAST function of
superclass in current.