Created
November 16, 2012 20:50
-
-
Save arv/4090806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.$super = function() { | |
var func = arguments.callee.caller; | |
var name = func.foundName_; | |
if (!name) { | |
for (var p in this) { | |
if (this[p] == func) { | |
name = p; | |
break; | |
} | |
} | |
func.foundName_ = name; | |
} | |
// Set up function to baseValue chain. | |
if (!func.baseValue_) { | |
for (var obj = Object.getPrototypeOf(this); obj; obj = Object.getPrototypeOf(obj)) { | |
if (Object.prototype.hasOwnProperty.call(obj, name)) { | |
obj[name].baseValue_ = obj; | |
obj[name].foundName_ = name; | |
} | |
} | |
} | |
var baseProto = Object.getPrototypeOf(func.baseValue_); | |
return baseProto[name].call(this); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment