-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Unexpected output from @extend with the child combinator (>) #1807
Comments
@nex3 can you weigh in here? This is a superselector according to sass. I thought we basically choose the longest superselector in the extended selector to be shared with the extending selector, so I suspect this is a bug.
|
This is really complicated. Chris is right that the issue is the algorithm for finding the longest common subsequences (LCS). The way that algorithm works is to compare compound selectors against one another for superselectordom. However, in order to preserve combinators like Fixing this will be tricky. Even if we updated the LCS algorithm to handle this, the code consuming it strongly assumes that each compound selector in the LCS corresponds to a single compound selector in both of the source selectors, which won't be the case if |
I've spent some time looking into this again in light of the refactorings we did in #3340, and it's still very difficult. I've managed to get it working, but not without sacrificing some other desirable behavior. The trickiest example is the following test case: a > b c .c1 {a: b}
a c .c2 {@extend .c1} This currently produces a > b c .c1, a > b c .c2 {
a: b;
} but this is only possible because we look at Ultimately, I think this is too complex for too little payoff to be worth solving. In the distant future, once |
I'm surprised by the way that extender selectors containing the child combinator
>
merge with@extend
. I'm not sure if this is a bug or by design.First, consider the output when
>
is not used.SCSS:
Output CSS:
Next, we'll add a
>
combinator:SCSS:
Output CSS:
Now, neither of the two generated selectors are what I would expect, considering the fact the
.c .d
is a superselector of.c > .d
. Selector 2 has an extra.d
after the.c > .d
, and selector 3 strangely places an extra.d
between the inserted.a .b
at the end.This would be ideal:
Or, if
.c > .d
can't merge into.c .d
for some reason, I would expect it to fall back to this instead:The text was updated successfully, but these errors were encountered: