Last active
August 29, 2015 14:07
-
-
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
This file contains 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
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