Skip to content

Instantly share code, notes, and snippets.

@simonsmith
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save simonsmith/27d9090e2ec4bebfd585 to your computer and use it in GitHub Desktop.

Select an option

Save simonsmith/27d9090e2ec4bebfd585 to your computer and use it in GitHub Desktop.

Revisions

  1. simonsmith revised this gist Oct 6, 2014. 2 changed files with 18 additions and 17 deletions.
    18 changes: 18 additions & 0 deletions with-feature-detect.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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));
    });
    }
    17 changes: 0 additions & 17 deletions with-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -1,17 +0,0 @@
    module.exports = withModernizr;

    function withModernizr() {
    'use strict';

    this.attributes({
    supportClass: 'is-{class}-supported'
    });

    this.after('initialize', function() {
    $.each(Modernizr, function(key) {
    if (Modernizr.hasOwnProperty(key)) {
    this.$node.addClass(this.attr.supportClass.replace('{class}', key));
    }
    }.bind(this));
    });
    }
  2. simonsmith created this gist Oct 6, 2014.
    17 changes: 17 additions & 0 deletions with-modernizr.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    module.exports = withModernizr;

    function withModernizr() {
    'use strict';

    this.attributes({
    supportClass: 'is-{class}-supported'
    });

    this.after('initialize', function() {
    $.each(Modernizr, function(key) {
    if (Modernizr.hasOwnProperty(key)) {
    this.$node.addClass(this.attr.supportClass.replace('{class}', key));
    }
    }.bind(this));
    });
    }