Skip to content

Commit

Permalink
Fix #2991 (#3649)
Browse files Browse the repository at this point in the history
* Tests for 2991

* Fix for 2991

* chore: add missing newline

Co-authored-by: Olivier Nicodemi <olivier.nicodemi@zinal-consulting.de>
Co-authored-by: Lei Chen <chenleicoder@foxmail.com>
  • Loading branch information
3 people committed Aug 20, 2022
1 parent 721659e commit eefe33a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/less/src/less/visitors/to-css-visitor.js
Expand Up @@ -39,9 +39,9 @@ class CSSVisitorUtils {
? (rulesetNode.paths.length > 0) : false;
}

resolveVisibility(node, originalRules) {
resolveVisibility(node) {
if (!node.blocksVisibility()) {
if (this.isEmpty(node) && !this.containsSilentNonBlockedChild(originalRules)) {
if (this.isEmpty(node)) {
return ;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/test-data/css/_main/css-3.css
Expand Up @@ -136,8 +136,6 @@ body > .shadow {
symbols: ‣;
suffix: " ";
}
@-ms-viewport {
}
@unknown foo 42 (bar) {
x {
y: z;
Expand Down
3 changes: 3 additions & 0 deletions packages/test-data/less/_main/import-reference-issues.less
Expand Up @@ -5,6 +5,7 @@
// * #2716 - A file imported by reference and then normally - multiple imports should be independent
// * #1968 - When using an @import (reference), mixins that contain an & selector get added to the compiled output improperly
// * #2162 - Cannot put import by reference inside of a mixin (also doubles #1896)
// * #2991 - Empty @media queries generated through line comments when compiling less file with (reference)

// #1878: extend inside referenced file should not extend outside selectors
@import (reference) "import-reference-issues/global-scope-import.less";
Expand Down Expand Up @@ -48,3 +49,5 @@ show-all-content {
call-mixin-with-import-by-reference-inside {
.mixin-with-import-by-reference-inside();
}

@import (reference) "import-reference-issues/comments-2991.less";
@@ -0,0 +1,25 @@
.referenced {
// This file should not output anything if referenced.
@media (hover) {
// This file should not output anything if referenced.
}
// This file should not output anything if referenced.
@media (hover) {
// This file should not output anything if referenced.
}
// This file should not output anything if referenced.
@media (hover) {
/* This file should not output anything if referenced. */
}
// This file should not output anything if referenced.
@media (hover) {
color: #000000;
}
}
// This file should not output anything if referenced.
@media (hover) {
// This file should not output anything if referenced.
}
@media (hover) {
/* This file should not output anything if referenced. */
}

0 comments on commit eefe33a

Please sign in to comment.