Skip to content

classPrefix is not working #20

Open
@Tokimon

Description

@Tokimon

I have tried to create a build with the setting classPrefix: 'has-' from gulp, but the setting doesn't work, and as the gulp-modernizr is really just passing in the config to customizr, I write the issue here:

  1. The crawler doesn't find any properties has-xxx, so correct tests are not initialized.
  2. The prefix is never passed on to the Modernizr script.

I did some digging and it seems that the legacy property cssprefix is still used in the code:

  // customizr/src/crawler.js line 57
  // (method findStringMatches)

  prefix = settings.cssprefix || '';

Hence I need to pass in cssprefix: 'has-' instead of classPrefix: 'has-' before it works, but that contradicts the fact that the property name has been changed to classPrefix (see #8).

If I change the line indicated to prefix = settings.classPrefix || '' the crawler finds the correct properties with the has- prefix.

But unfortunately the prefix is still not passed on to the final Modernizr script and right now I have no precise idea why.

Below is the Gulp setting I have used:

  return gulp.src([path.resolve('.tmp/index.css'), path.resolve('.tmp/index.js')])
    .pipe(modernizr({
      "classPrefix": "has-",
      "options": [ "html5printshiv", "html5shiv", "setClasses" ],
    }))
    .pipe(uglify())
    .pipe(gulp.dest(config.destination));

As a side note; I think it is a bit strange that setClasses is not added to the default list of options, as personally I have never used Modernizr without wanting to use the classes as well.

Related issues
Modernizr/grunt-modernizr#30
#8

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