-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Spec for the @at-root directive #774
Comments
|
@nex3 it is semantically ambiguous, but not syntactically. |
That is, it would be a semantic conflict if there was ever a html element added named |
Another test case: Make sure interpolation works in |
Quite complex but cool! Why not use
Like the Syntax of the other at-rules? |
@Hannes-III I like this. |
Another test case: ensure that properties are disallowed within a block-style |
Whatever you want to call it, I don't want to hijack some specific valid selector syntax to have a special meaning in this context. |
I understand this idea is already pretty solid, so please take this semi-rhetorically. With the block and flag additions to |
That's a good point. But I'm not sure it's common enough to have completely different behaviors. might as well have several directives at that point. |
Either a single directive with multiple flags or multiple nestable directives works equally well for me, as long as the choice is consistant. I think it would be confusing if there's I prefer single directives/functions/mixins with flags, but I know you're a big fan of breaking things out into descriptive single use pieces :). |
I like the consistent syntax of @robwierzbowski's suggestion, but I don't like how verbose it makes the simple cases. What used to be |
True. The all directive pattern would look like: ...selectors... {
@at-root {
@without-media {
...rules... }
@future-selector-transformer {
...rules... } } which I like too, now that I wrote it out. |
I'm also not a big fan of adding a bunch of new directives for this. I'd like to find a way to do this with a single directive that can be configured to address the needs of all the use cases, but is easiest to use in the most common case. One possibility would be to have This suggests a second possibility: removing the parent selector but not any parent directives, while still being configurable. This fits the common case better, but is less consistent for more complex cases. Finally, a much more radical possibility is to start thinking about bubblable directives like |
I'm opposed to making the default behavior of Regarding making directives part of |
I agree that it's important that the default behavior of
I'm by no means wedded to it, but I would like to understand more about why you dislike it.
I'm not a huge fan of adding a separate function for getting each different type of context. Regardless, this is something that will likely not happen for a while; without being necessary for
This conclusion doesn't follow. Getting block-level parent context is very different than accessing a representation of a property that's actively being defined. |
I agree with you that the second option is the best so far, it was also what was already proposed 😄
Although it doesn't seem to have any backwards compatiblity issue at this time, it fundamentally changes (what I think is) the mental model of
Obviously, alternative forms of the same concept (using a function to access non-selector context) are welcome and encouraged.
I don't see a fundamental difference. Context is context. Please explain. |
The block-level context already exists when the SassScript is getting run; property values is being defined while the SassScript accessing it is run. Accessing block-level context preserves the invariant that |
Gotcha. Seems worth preserving without a very compelling use case -- which I've not see to-date. |
👍 on this feature. I have been looking for a solution to moving out of the current scope for a long time. Would be super helpful |
👍 will be very helpful for writing media query mixins |
Hi, Is there a way to access to the parent element to add a class? I used lot of times the parent to trigger css animations and would like to have something like this: HTML:
SCSS:
OUTPUT CSS:
and the parameter passed to @go-out(X) indicate the how many levels want to go out. Thanks! |
Not currently. In version 3.4, you'll be able to access the parent selector in SassScript using |
Yeah, an @at-node(n) construct to traverse back up the selector tree would be great. I've needed that a few times. |
I'd like to nail down the exact spec for how
@at-root
will work.So here's some test cases:
inline selector mode
&
still works when not in script mode&
works when in script mode@at-root
can take a block@at-root
blocks only affect the nearest child selectors.@at-root
doesn't remove selectors from directives by default.@at-root
in block form can remove a selector from all directives.@at-root
in block form can remove a selector from specific directives.Media:
Supports:
Several directives removed:
Selector inheritance uses the resulting selector and directive context.
In theory we can make
without-xxx
be agnostic of directive type, but this may have issues with prefixed directives. Or we can have a whitelist of directive names.The cases around directive removal will solve a big problem with the limitations around using
@extend
within media blocks. Specifically, this allows you to extend a selector via a mixin for all media contexts instead of just within the current media block.The text was updated successfully, but these errors were encountered: