Skip to content

Strange mismatch in selector name #16

Description

@aseem2625

Hi, I noticed a strange thing. Don't know if it's known.

My config

gulp.task('purifycss', function () {
    return gulp.src('src/bundle/css/**/*.css')
        .pipe(purify(['src/bundle/js/**/*.js', 'src/**/*.html']))
        .pipe(gulp.dest('src/bundle/css'))
});

This config works perfectly fine but strange results for following things.

Case: If I've 2 selectors in css file '.js-newClass' and '.newClass1' where only '.js-newClass' is being added through js and '.newClass1' is nowhere used. So purifycss still keeps '.newClass1' because of string matching 'newClass' in both selectors and '.js-newClass' is being kept because it's been used in js.
Observations:

  1. If I would remove '.js-newClass' from js then purifycss will remove both selectors from final css.
  2. If I would rename '.js-newClass' to '.js-newClas' or '.js-newClassa' then also it will remove '.newClass1' selector from the final css.
  3. If I would rename '.js-newClass' to '.js-newClass-hello' then also it keeps 'newClass1'
  4. If I would rename '.newClass1' to '.newClass' then also it still keep '.newClass' in the final css because 'newClass matches with '.js-newClass' substring
  5. If I would rename '.newClass1' to '.newClassa' then it removes it from final css because '.newClassa' is differently matches to '.js-newClass' than how '.newClass1' is matched to '.js-newClass'. So, putting number doesn't matter.

Please, let me know, whether it's know or can it be fixed with an update?

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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