Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces removed from :is statement #1246

Open
04alband opened this issue Feb 27, 2023 · 1 comment
Open

Spaces removed from :is statement #1246

04alband opened this issue Feb 27, 2023 · 1 comment

Comments

@04alband
Copy link

04alband commented Feb 27, 2023

Hi, this seems very similar to this closed issue: #996

I'm using the latest gulp-clean-css (4.3.0) which I believe is a wrapper for clean-css.
I'm seeing spaces be removed from a complex :is() statement, changing the meaning of it. I've tried disabling spaces.aroundSelectorRelation but that didn't seem to help. The only thing I've found that solves it is changing optimisation to level 0, but that removes a lot of other nice stuff. See example...

EDIT:
The following option resolves it (which sort of makes sense):

    level: {
        1: {
            all: false,
            removeWhitespace: false, // controls removing unused whitespace; defaults to `true`
        },
    }

I still wonder if this would be regarded as a bug though as the meaning of the CSS has changed. But I'm happy with this solution for the time being.

Environment

  • clean-css version - npm ls clean-css: gulp-clean-css is 4.3.0
  • node.js version - node -v: v16.14.2
  • operating system: Windows

Configuration options

My gulp task is very simple, like this:

gulp.task('build:sass', () => {
    console.log('building sass');

    return gulp.src(paths.sass.src, { since: gulp.lastRun('build:sass') })
        .pipe(sourcemaps.init())
        .pipe(sass().on('error', sass.logError))
        .pipe(cleanCSS(cleanOptions))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest(paths.sass.dest));
});

For the options, I've tried playing with many options but the default no-options produces the error.

Input CSS

:is(.dataTables_wrapper > .dataTables_scroll .dataTables_scrollHead table.dataTable, .dataTables_wrapper > table.dataTable) thead {
	background: red;
}

Actual output CSS

:is(.dataTables_wrapper>.dataTables_scroll.dataTables_scrollHeadtable.dataTable,.dataTables_wrapper>table.dataTable) thead {
  background: red
}

Expected output CSS

:is(.dataTables_wrapper > .dataTables_scroll .dataTables_scrollHead table.dataTable, .dataTables_wrapper > table.dataTable) thead {
	background: red;
}

If I'm doing something wrong, I'm sorry and any help would be greatly appreciated.

@shuffgy
Copy link

shuffgy commented Jul 26, 2023

@04alband i had the same issue but did not want to set all rules to false.
Also for me it was not removeWhitespace: false that fixed it, it was tidySelectors: false

Input:

&:nth-last-child(1 of .event__info) {
	margin-bottom: var(--margin-l);
}

Here was the output :nth-last-child(1of.event__info) { before, now its correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants