Created
September 16, 2011 10:17
-
-
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)
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
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