Skip to content

Instantly share code, notes, and snippets.

@i-like-robots
Last active December 16, 2015 21:50
Show Gist options
  • Save i-like-robots/5502972 to your computer and use it in GitHub Desktop.
Save i-like-robots/5502972 to your computer and use it in GitHub Desktop.
Handy drop-in module for CSS feature detection.
define(function() {
/**
* CSS feature detection
* @param {String} property
* @returns {String}
*/
return function(property) {
var i, len, prop;
var support = '';
var prefixes = ['ms', 'moz', 'webkit'];
var temp = document.createElement('div');
prop = property.toLowerCase();
if (prop in temp.style) {
support = prop;
}
else {
for (i = 0, len = prefixes.length; i < len; i++) {
prop = prefixes[i] + property;
if (prop in temp.style) {
support = prop;
break;
}
}
}
return support;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment