Skip to content

When using an @import (reference), mixins that contain an & selector get added to the compiled output improperly #1968

@bcullman

Description

@bcullman

When I import a less file with the (reference) directive, I expect to see no CSS output from that file.

However, I am seeing content being output from the imported file when a mixin contains an & selector.

mixin.less

.mixin-no-parent-selector() {
  background-color: red;
}
.mixin-with-parent-selector() {
  &:first-child{ //  USING AN & SELECTOR HERE
    background-color: blue;
 }
}

less-for-reference.less

.container-1 {
   .mixin-no-parent-selector();
}
.container-2{
   .mixin-with-parent-selector()
}

style.less

/*!
 * styles.less
 */
@import "mixin.less";
@import (reference) "less-for-reference.less";

Expected Output

/*!
 * styles.less
 */

Actual Output

/*!
 * styles.less
 */

.container-2:first-child{
    background-color: blue;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions