Skip to content

Instantly share code, notes, and snippets.

@simonsmith
Last active August 29, 2015 14:07
Show Gist options
  • Save simonsmith/27d9090e2ec4bebfd585 to your computer and use it in GitHub Desktop.
Save simonsmith/27d9090e2ec4bebfd585 to your computer and use it in GitHub Desktop.
Flight mixin for adding `is-` SUIT classes to a component based on Modernizr support
module.exports = withFeatureDetect;
function withFeatureDetect() {
'use strict';
this.addFeatureDetectClass = function(feature, supported) {
var prefix = (supported ? 'is-' : 'is-not-');
this.$node.addClass(prefix + feature + '-enabled');
};
this.after('initialize', function() {
$.each(Modernizr, function(key, value) {
if (Modernizr.hasOwnProperty(key)) {
this.addFeatureDetectClass(key, value);
}
}.bind(this));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment