Skip to content

Odd classPrefix behaviour #143

@dave-green-uk

Description

@dave-green-uk

I've recently upgraded the grunt-modernizr (1.0.2) and modernizr (2.8.3) versions to the latest stable builds in our development boilerplate that we use for all new projects. and I've noticed something odd.

Here is our grunt-modernizr partial:

module.exports = {
    // Generate a custom Modernizr build based on checks found in our Sass & JS
    custom: {
        "cache": true,
        "uglify": false,
        "options": [
            "domPrefixes",
            "prefixes",
            "mq",
            "prefixed",
            "testAllProps",
            "testProp",
            "setClasses"
        ],
        "tests": [],
        "excludeTests": [
            "hidden"
        ],
        "devFile": "bower_components/modernizr/modernizr.js",
        "dest": "<%= siteInfo.assets_path %>/<%= siteInfo.js_dir %>/lib/modernizr-custom.js",
        "crawl": true,
        "files": {
            "src": [
                '<%= siteInfo.assets_path %>/<%= siteInfo.sass_dir %>/**/*.scss',
                '<%= siteInfo.assets_path %>/<%= siteInfo.js_dir %>/**/*.js',
                '!<%= siteInfo.assets_path %>/<%= siteInfo.js_dir %>/lib/modernizr-custom.js'
            ]
        }
    }
};

First of all, the .hidden class was being applied to the <html> element as this is a utility helper class we have in our CSS. After digging around Google/issues I saw that this relates to one of Modernizr's tests, so after further reading I added...

"classPrefix": "mzr-", to the above config.

As a direct result of this, the replacement of no-js failed, and hidden was actually replaced with the mzr- prefix. End result looked like...

<html class="no-js mzr-">

So, I removed classPrefix from the grunt config and excluded the hidden test as you can see above.

The issue I now have is I'm unable to prefix any of the Modernizr classes added to the root <html> element without the no-js --> js switch failing.

Am I doing something wrong, or is this an actual bug?

P.S Happy to re-post in the main Modernizr repo. 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions