Skip to content

Instantly share code, notes, and snippets.

@michael-brade
Created September 25, 2016 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michael-brade/850123d084776ef01fcdaecfa542521e to your computer and use it in GitHub Desktop.
Save michael-brade/850123d084776ef01fcdaecfa542521e to your computer and use it in GitHub Desktop.
fixed extendComponent()
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