Last active
August 29, 2015 14:14
-
-
Save DigiTec/6379074de4cf74fb201e to your computer and use it in GitHub Desktop.
Vendor Prefix Enumeration - Note prior to Chrome 43 we have to use instances to get values back. So there is a switch for some of the known instances, but this is heavily incomplete. Starting with Chrome 43 more information is on the prototype. Still, things like window and CSSStyleDeclaration lack type system and so you still need an instance f…
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
// http://jsfiddle.net/8n6c1dpz/12/ | |
var out = document.getElementById("output"); | |
var vendorPrefixes = [/^ms|^onms/i, /^moz|^onmoz/i, /^webkit|^onwebkit/i]; | |
var vendorProps = vendorPrefixes.map(function (prefix) { | |
return Object.getOwnPropertyNames(window).filter(function (name) { | |
try { | |
return (this[name].prototype && this[name].prototype.constructor === this[name]); | |
} catch (exc) { | |
return false; | |
} | |
}).sort().map(function (name) { | |
var props = [name]; // Add the name for constructors that are prefixed | |
switch (name) { | |
case "CSSStyleDeclaration": | |
Array.prototype.push.apply(props, Object.keys(window.getComputedStyle(document.body))); | |
break; | |
case "HTMLElement": | |
Array.prototype.push.apply(props, Object.keys(document.body)); | |
break; | |
case "HTMLDocument": | |
Array.prototype.push.apply(props, Object.keys(document)); | |
break; | |
case "Window": | |
Array.prototype.push.apply(props, Object.keys(window)); | |
break; | |
} | |
return props.concat(Object.keys(this[name].prototype)).filter(function (prop) { | |
return prefix.test(prop); | |
}); | |
}).reduce(function (prev, curr) { | |
return prev.concat(curr); | |
}, []).sort().filter(function (prop, index, arr) { | |
return prop !== arr[index-1]; | |
}); | |
}); | |
out.innerHTML = vendorProps.map(function (props, index) { | |
return ["Prefix " + vendorPrefixes[index] + ": " + props.length].concat(props).join("\n"); | |
}).join("\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment