Skip to content

Variable passing to ruleset by a mixin contain a loop #2098

Closed
@oltodo

Description

@oltodo

Hi,

This is my parametric mixin contain a loop who set a @width variable and provide to ruleset :

.foo (@ruleset) {
    .loop(1);

    .loop (@index) when (@index < 4) {
        @width: 30px * @index;

        .bar {
            @ruleset();
        }

        .loop(@index + 1);
    }
}

When I call this mixin twice like that :

.foo({
    width: @width;
});
.foo({
    width: @width;
});

I have this output :

.bar {
  width: 30px;
}
.bar {
  width: 60px;
}
.bar {
  width: 90px;
}

.bar {
  width: 30px;
}
.bar {
  width: 30px;
}
.bar {
  width: 30px;
}

The first three are correct but the last three stay on 30px width.

Strangely, the following example has no problem :

.first {
    .foo({
        width: @width;
    });
}

.second {
    .foo({
        width: @width;
    });
}

An idea ?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions