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
anyone think 【tag:before{&:hover{color:red}}】 should compiles to 【tag:hover:before{color:red}】? #1605
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.:
@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.
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.
Activity
seven-phases-max commentedon Oct 17, 2013
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.
lukeapage commentedon Oct 17, 2013
Does it make any difference? If not why do people care what its compiled
too?
matthew-dean commentedon Oct 21, 2013
@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.
lukeapage commentedon Oct 21, 2013
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.
radium-v commentedon Oct 25, 2013
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:
lukeapage commentedon Dec 23, 2013
am I right in thinking this particular bug can be closed, e.g. better handling of & is covered by other bugs?
matthew-dean commentedon Dec 23, 2013
Yes, in the way this issue is written, Less doesn't need to reorder psuedo-elements.