Created
March 13, 2014 16:03
-
-
Save mattjburrows/9531251 to your computer and use it in GitHub Desktop.
Return a matching prefix from either an array or object literal. If non match return false.
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 getPrefix(prefixes) { | |
| var div = document.createElement('div'); | |
| // Check to see if we are dealing with an array. | |
| if(Object.prototype.toString.call(prefixes) === '[object Array]') { | |
| var max = prefixes.length; | |
| while(max--) { | |
| if(prefixes[max] in div.style) { | |
| return prefixes[max]; | |
| } | |
| } | |
| } | |
| // Else we'll assume it is an object. | |
| else { | |
| for(prefix in prefixes) { | |
| if(prefix in div.style) { | |
| return prefixes[prefix]; | |
| } | |
| } | |
| } | |
| return false; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment