-
Notifications
You must be signed in to change notification settings - Fork 464
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
Support parent selector & in values / and/or interpolations #548
Comments
Ohhh... this is a good one. Thanks for the useful bug report. I've marked this as needs test and we'll get it in sass-spec soon. |
Spec added sass/sass-spec#103 |
Just stumbled upon this issue. It seems this is also a blocker for using http://www.csstyle.io/ with libsass. |
I second benjixx's comment. libsass is choking on csstyle. I've been trying to figure out why. We have something like this:
That throw an error like this:
I have tracked it down to the ampersand on line 25, but have been unsuccessful at fixing it in csstyle alone. (Note: In my case I am using sass-loader for webpack that uses libsass under the hood---I am pretty sure.) |
Hi guys, I'd like to try to implement this in my own fork but not quite sure how to get the parent selector and then translate that to an expression. It seems that the if block in parse_simple_selector_sequence in the Parser isn't what I thought. I thought that that would give me a reference to the parent selector (based on the comments). If it does, I"m not sure how to reference that in the parse_value method when it tries to parse an assignment statement. Any help would be appreciated. Also it seems that Selectors can't be Expressions, which is fine because I can use Selector_Schema to get the string value, right? I think what I'm really looking for is a way to get the environment/context when the parser is parsing a given statement. Thanks in advance. |
If you're willing to wait I plan to tackle this over the weekend. |
Thats great news! Thank you. Ive spent some trying to figure it out and
|
The general idea is you want want If you want to give it a shot I'll take a look at the PR. |
Thank you~! So that was my first approach but parse_value returns an expression and I didn't know how to create an Expression from a Selector_Reference. The AST value isn't accessible from a Selector_Reference object.... Also i'd love to continue to contribute to this so I'll take a shot and send you a PR when I think I have it working.... |
So I am trying to return this: And when i output the & reference, I get an empty string. So I think I must not be returning the correct value.... |
Yeah I had a look, it's a little more complicated than expected. You need to expand the This gets tricky because Some wire will need to be crossed to get crossed. My gut feeling is that the selector expanding logic will need to be factored out of the |
Ah, okay so that's what I thought. I was hoping for a simpler answer, which was simply returning the right value in parse_value, but like you said, there was no way to access the member I needed, or rather, the member simply doesn't exist. When you say expand the I can work on refactoring the selector expanding logic into its own operator. |
If you take a look at the
|
Wouldn't I have to a) make Selector_Reference inherit from Expression |
Unfortunately it's not assignments. The
|
ah...the spec that was written only seemed to account for the assignment case....so this means that I'd have to apply this to ALL the visitor methods??? that kinda sucks....there should be a better way. |
You should need to create a single operator on the the expand and eval
|
Ah, that's what you mean by the stacks being different...the eval visitor is for expressions primarily and the expand visitor is primarily for Statements? It seems like I need to create a SelectorExpression, like the MediaQuery_Expression class....what do you think? |
Exactly. Only the expand visitor know how to hydrate the
|
Hmm....so there's a dilemma where the expand visitor takes the eval visitor as a constructor parameter because it uses it to eval arguments, which is fine, but if I were to make the eval visitor take the expand visitor as a construction parameter then that would be circular....do I need a new visitor class to submit to both classes? |
No worries @ekskimn I'm rather pre-occupied myself atm. We appreciate all your work. |
Hey @xzyfer What do you recommend? |
I'm sorry but it's just really hard to visualise with out seeing the code
|
PR to you @xzyfer ...like the comments say, i have the declaration and the binary operations working but the interpolation isn't...though it really should and not quite sure why it wouldn't....I'm still looking at that, but if you get a chance take a look at the PR |
Thanks for your work, we really appreciate it. FWIW there's a comprehensive spec suit for this feature now at https://github.com/sass/sass-spec/tree/master/spec/libsass-todo-tests/selectors. |
edits responding to comments for append_string typo for the broken line comma added contextualize_eval to the visual studio project file.
includes from parent selector: 158a5af Support parent selector & in values / and/or interpolations sass#548 d10b572 Merge branch 'master' into parent-selector 829fef7 merge from master to parent-selector e1f78c0 Merge commit 'dea27e5e3cc61a0d9f00ffa3f598a1080c6502d6' into parent-selector ef73c1b issue 548 776e997 sass#548 Fixed the interpolation~! 324b14f sass#548 Fixing orphaned variable 1c15df0 sass#548 fixes for eval calling var->perform(this) edits responding to comments for append_string typo for the broken line comma added contextualize_eval to the visual studio project file. d9090b3 sass#548 fixed the set fault tests... 92e3f0b sass#548 removing commented out code thanks @mgreter. 98977d8 sass#548 removed commented code 5b6d06a sass#548 applied @xzyfer patch. Some clean up of commented out code
includes from parent selector: 158a5af Support parent selector & in values / and/or interpolations sass#548 d10b572 Merge branch 'master' into parent-selector 829fef7 merge from master to parent-selector e1f78c0 Merge commit 'dea27e5e3cc61a0d9f00ffa3f598a1080c6502d6' into parent-selector ef73c1b issue 548 776e997 sass#548 Fixed the interpolation~! 324b14f sass#548 Fixing orphaned variable 1c15df0 sass#548 fixes for eval calling var->perform(this) edits responding to comments for append_string typo for the broken line comma added contextualize_eval to the visual studio project file. d9090b3 sass#548 fixed the set fault tests... 92e3f0b sass#548 removing commented out code thanks @mgreter. 98977d8 sass#548 removed commented code 5b6d06a sass#548 applied @xzyfer patch. Some clean up of commented out code
…ssue-548 * 'issue-548' of https://github.com/ekskimn/libsass: sass#548 squashed commit
Awesome! |
Great effort guys 👍 |
Hi
First I'd like to thank you for your awesome work!
I've put together a small BEM Sass library http://codepen.io/gionkunz/pen/rkswl and there are problems in libsass with the parent selector. It looks like there is an undocumented feature in RubySass that the parent selector & can also be converted to a selector string. I believe internally its a list of lists if I'm not mistaken. So in
.test { .abc, .def { &:before { content: "." } } }
& would be stored as list of lists( ( ".test .abc" ) , (".test .def") )
. In RubySass when the parent selector&
appears where a value is expected it gets converted to a string http://sass-lang.com/documentation/Sass/Script/Functions.html#selector_functions .Gets processed to:
This feature is particularly interesting for libraries and frameworks that need to have more control over selectors during nesting. I'd really love to have this in libsass too.
I did not find any spec in https://github.com/sass/sass-spec concerning this undocumented feature and I'd also help where I can to get this in.
Cheers
Gion
The text was updated successfully, but these errors were encountered: