-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
anyone think 【tag:before{&:hover{color:red}}】 should compiles to 【tag:hover:before{color:red}】? #1605
Comments
Well, perhaps. But (usually) it's not compiler's job to guess user intentions and depending on such guesswork to change its own rules (in other words "automatically fix errors for you"). So in this particular case I'm afraid that if you want a different order you need to write it in this different order (even if it won't look very compact), e.g.:
See also #1075. |
Does it make any difference? If not why do people care what its compiled |
@lukeapage A generated block (div:before) doesn't have a hover state. It's a sub-element and created via CSS, so it doesn't receive events (e.g. div:before:hover never occurs). But, of course the main div does, and you can generate a block in that main div based on it's hover state (div:hover:before). @xieranmaya As a general rule, Less doesn't have awareness of what the CSS is, just how the code is written. So div:before:hover == div:blerg:flooglem to the parser. Changing the rules of parsing based on what you write can get messy quick and adds a heap to the parsing logic. |
I think this should be covered by the issue about selecting a parent for & e.g. if you could do
it would be one way of solving the issue.(though in this case @seven-phases-max suggestion would be better I presume it is feasible that although at the moment generated elements don't get hover events, that they could in the future? If so we don't want to make this change as we would then have to then make a breaking change to revert it back. |
If we're going against the W3C spec, there's this:
It's slightly different in the CSS3 proposed spec though:
To me, it doesn't make sense to accommodate for this, since the compiler will just do what you tell it to: div {
&:before {
content: 'css generated content';
color: green;
}
&:hover {
&:before {
color:red;
}
}
} |
am I right in thinking this particular bug can be closed, e.g. better handling of & is covered by other bugs? |
Yes, in the way this issue is written, Less doesn't need to reorder psuedo-elements. |
I'm using LESS today and I wrote a LESS spinet like this:
and it compiles to
and this can't work, but it's intuitive....
you can see this question:
http://stackoverflow.com/questions/5777210/how-to-write-hover-condition-for-abefore-and-aafter
so, do you think that the above LESS code should compiles to
and it's works in browser
which means
should compile to
mind the
's orderThe text was updated successfully, but these errors were encountered: