-
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
Extend of extended selector #1641
Comments
|
@seven-phases-max If extend all would treat selector elements independently, then it would be impossible to match combinators. They are compared now, so current version behaves as (B):
compiles into:
The combinator must be in the middle, leading and trailing combinators do not work. I think that this one is separate issue #1642 . |
@SomMeri, Yes, (B) is what I suspected. But then I also expect (3)'s |
@seven-phases-max I say, good catch. I was simplifying example and forgot about that pseudo, sorry. The example should look like this:
and compiles into:
So, I will edit the above example, so others do not waste time with the same mistake. |
Ah, OK - then I'll wash out my first post since it simply repeats (3). |
https://github.com/less/less.js/blob/master/lib/less/visitors/extend-visitor.js Looks like we need to rip out the chaining concept there and re-implement it so that every new selector that is created has all of the extends processed on it - this would allow you to extend a selector created via another extend. |
Extend all does not always find matches in selector generated by another extend. Such match can but does not have to be found, depending on circumstances:
The combination of these rules make it hard to predict what will be generated. It is also very hard to describe for documentation :) (or for newbie). I think that two extends matching the same selector should either act independently or together at the same selector, but should not create new extending selectors on the fly.
Sorry if it sounds confusing. I tried to isolate cases that work and does not work and describe them all below.
1. Two Extend All of The Same Selector
If two extend all match the same selector, less.js will not combine them. However, both of them will extend original selector:
compiles into:
I expected one of following:
2. Extend All Extending Selector
If extend all matches something inside another extend all, then it is going to be extended too:
compiles into:
Less.js created
partialMatch:pseudo:extend(a:first all) {}
on the fly and applied it to the ruleset.3. Extend All of Extended Selector
If extend all of matches extended selector, less.js will not find it: (EDIT: fixed the example, the original version had mistake in it)
compiles into:
I expected one of the following:
All In One - Full Case
The main question is, what should be generated by following less:
As it is now, less.js produces this:
I expected it to contain following selector:
chained:pseudo chained
. I did not expected thechained exSelector
to be there, but it can be explained, so it may be ok.The text was updated successfully, but these errors were encountered: