You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parent selectors not working within mixins using (reference) #1979
I just add a sort-of self-note to save some time when reading this issue in future... (well, honestly, yes, it's sort of useless then since it adds nothing new).
The point is that reference ignores third level and up nested rules
But all examples here use parent selector... (i.e. &). So as I said #hola example above is just more verbose version of the initial snippet.
And if you change your example to :
which btw. is equal style (& is redundant there) you'll find it works with (reference) just fine. So I still can't see anything specific about this example. (So it is& issue as the title says).
The key is that the & is used in places where cascaded nesting wouldn't work. If the import isn't using reference, the ::after pseudo-element gets output (and so does ._justify, which we treat as an internal, extend-only helper). With reference, the ::after doesn't get output.
The only working solution would be to change the mixin and reduce the nesting, like so:
Activity
aonez commentedon Nov 7, 2014
Same here. If the mixin.less is something like this works:
So the point is in reference import only the first level nested rules are used. It goes no deeper than that.
Another example:
less code:
html code:
You'll only see two of the three divs.
seven-phases-max commentedon Nov 7, 2014
@aonez Could you elaborate what your second example has to do with
(reference)?aonez commentedon Nov 7, 2014
Sure, sorry I copy-pasted some code and now it does lack some meaning:
Take a common.less file:
Take a someName.less file that imports common.less and uses its classes:
The html page is the same as in my first comment, and will be using the someName.less file:
The css output, just using plain import is the expected:
Oviously we only need the #hola part in this case, so common.less must be imported using reference:
The new ouput:
As you can see, it lacks any nested rule but the first level. In that case, the code should be:
It lacks the third div properties:
Hope this helps 😄
seven-phases-max commentedon Nov 7, 2014
I see, thanks. So the second example is just more verbose variant of the original snippet.
aonez commentedon Nov 7, 2014
You mean it's useless for you?
seven-phases-max commentedon Nov 7, 2014
I just add a sort-of self-note to save some time when reading this issue in future... (well, honestly, yes, it's sort of useless then since it adds nothing new).
aonez commentedon Nov 7, 2014
The point is that reference ignores third level and up nested rules, not rules with parent selectors as the tittle of this ticket says.
seven-phases-max commentedon Nov 7, 2014
But all examples here use parent selector... (i.e.
&). So as I said#holaexample above is just more verbose version of the initial snippet.And if you change your example to :
which btw. is equal style (
&is redundant there) you'll find it works with(reference)just fine. So I still can't see anything specific about this example. (So it is&issue as the title says).radium-v commentedon Dec 16, 2014
We use Modernizr classes in our build - here's an example of our justify-align hack:
Expected output:
Actual output:
The key is that the
&is used in places where cascaded nesting wouldn't work. If the import isn't usingreference, the::afterpseudo-element gets output (and so does._justify, which we treat as an internal, extend-only helper). Withreference, the::afterdoesn't get output.The only working solution would be to change the mixin and reduce the nesting, like so:
SomMeri commentedon Jan 23, 2015
I think I incidentally fixed this by #2410 . So I will just add unit test for this into that one.
Added unit test for referenced parent selectors