Skip to content

Instantly share code, notes, and snippets.

@DavidBruant
Created September 16, 2011 10:17
Show Gist options
  • Save DavidBruant/1221763 to your computer and use it in GitHub Desktop.
Save DavidBruant/1221763 to your computer and use it in GitHub Desktop.
For Lea Verou, with love :-p (response to https://twitter.com/#!/LeaVerou/status/114636985846607874)
var keys = [];
var n;
var P = Object.getPrototypeOf;
var o = window;
// Retrieving all property names of the global object,
// because proto chain are messy and different in all browsers
while(o !== null){
keys = keys.concat(Object.getOwnPropertyNames(o));
o = P(o);
}
keys = keys.filter(function(e){
// A child "class" of HTMLElement has its prototype to HTMLElement.prototype
try{
return P(window[e].prototype) === HTMLElement.prototype;
}
catch(e){ // window[e] or window[e].prototype is not an object
return false;
}
});
console.log(keys);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment