-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
Description
Given the following, I would expect both loops to render similar output. However, the version where the each()
is inside the block and &
is used produces strange results. Specifically, the styles immediately under the &
are rendered at the top of the loop's generated output. Oddly, a child of the &
block is rendered in the expected spot.
Given
@infixes: a, b;
/*! LOOP IN BLOCK */
.amp {
each(@infixes, #(@_infix, @i) {
// Each infix actually generates the _next_ infix's block, with the last
// one generating styles with no infix.
@infix: e(if(
((@i + 1) <= length(@infixes)),
%('-%s', extract(@infixes, (@i + 1))),
''
));
&@{infix} {
display: block;
.child {
display: block;
}
}
});
}
/*! BLOCK IN LOOP */
each(@infixes, #(@_infix, @i) {
// Each infix actually generates the _next_ infix's block, with the last
// one generating styles with no infix.
@infix: e(if(
((@i + 1) <= length(@infixes)),
%('-%s', extract(@infixes, (@i + 1))),
''
));
.plain@{infix} {
display: block;
.child {
display: block;
}
}
});
Expected
/*! LOOP IN BLOCK */
.amp-b {
display: block;
}
.amp-b .child {
display: block;
}
.amp {
display: block;
}
.amp .child {
display: block;
}
/*! BLOCK IN LOOP */
.plain-b {
display: block;
}
.plain-b .child {
display: block;
}
.plain {
display: block;
}
.plain .child {
display: block;
}
Actual
/*! LOOP IN BLOCK */
.amp {
display: block;
}
.amp-b {
display: block;
}
.amp-b .child {
display: block;
}
.amp .child {
display: block;
}
/*! BLOCK IN LOOP */
.plain-b {
display: block;
}
.plain-b .child {
display: block;
}
.plain {
display: block;
}
.plain .child {
display: block;
}
Note that .amp
is floated to the top.