Created
September 25, 2016 21:11
-
-
Save michael-brade/850123d084776ef01fcdaecfa542521e to your computer and use it in GitHub Desktop.
fixed extendComponent()
This file contains hidden or 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
function extendComponent(constructor) { | |
// Don't do anything if the constructor already extends Component | |
if (constructor.prototype instanceof Component) | |
return; | |
// Otherwise, add an instance of Component to its prototype chain | |
var c = constructor.prototype; | |
for (var p = Object.getPrototypeOf(c); p !== Object.prototype && p !== Function.prototype; p = Object.getPrototypeOf(c)) { | |
c = p; | |
} | |
Object.setPrototypeOf(c, Component.prototype); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment