-
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
Interpolated selectos and three letters long id selectors #2481
Comments
This (a related problem) was discussed once at #1648 (comment). The problem is that Actually the example can be simplified to just:
P.S. Ah, sorry, missed the fact that |
@seven-phases-max One solution would be to keep original color format in color node. It could get lost during math operations and functions, but be kept when assigning variables to variables etc. If original color format would be available, that one would be printed into output. |
I want a way of describing selectors in variables e.g. $(#abc) or
selector(#abc)
|
@SomMeri Could be (this is similar to what I did for #1604). Though in general, for the selector interpolation case, it would mean unfortunate duplication of code, i.e. another
:) This is totally artificial example of course but to illustrate it's not only color issue... I.e. almost every complex tree object would have to provide that special |
Yes, I guess I will agree with @lukeapage for the need of |
Would be awesome if you could also capture current selector scope that way, for later re-use. .mixin() {
@selector : selector(&);
// ( ... )
&-sub {
// ( ... )
& + @{selector} {
// ( ... )
}
}
}
// ( ... )
.prfx-foobar { .mixin(); } .prfx-foobar {
// ( ... )
}
.prfx-foobar-sub {
// ( ... )
}
.prfx-foobar-sub + .prfx-foobar {
// ( ... )
} Could come in quite handy when you want to parent everything in a mixin against a common ancestor CSS classname, as is the case when you develop mixins for a BEM-style framework of components. |
@seven-phases-max I would not duplicate code, just render it in original (shorthand) notation everywhere. Browsers should be able to accept that, so there is no reason to split flow depending on context. |
@seven-phases-max I through about doing it only for colors. It did not occurred me to do it for everything. So the change would be only in parser or whoever it is that fills this.value in toCss function of color object. |
@SomMeri Then it's OK I guess. Though.. hmm... then when/if
Obviously the second statement would require Or maybe I'm just overcomplicating this and you should just do it and let it fly whatever way it flies :) |
I think that it should be solved the same way as this, e.g. they are the same problem:
|
And that's what my initial concern is. It's too many examples to fix if we're about fixing them all (in that case Now, after all, how many real code you can imagine out there that is really to use a CSS selector with an identifier being ambiguous with a hex color? (i.e. |
I meant that your and my example should be solved by the same code. There is no reason to have different code path for It is just the question of knowing that color can be also valid id, you do not need to list all the ways in which they can be the same. That is something you can not avoid because The The |
OK, now I guess I get it. So you mean if variable is defined as
). But still for a consistency this ideally would need more changes in the parser so that it works the same for |
Yes, that is what I meant. Just using the same code that already exists because of You think that |
No. I mean it does not really matter how it's to be parsed (well, currently
Currently the excuse is: the first is a color value (hence it works) and the second is some unknown "typo" (hence it bails out). But as soon as |
I don't see how this is an issue when you can use a string to define the selector. Seems pretty expected that a non-quoted
How is this a significant problem worth changing? |
@matthew-dean It looks like a bug and in all likelihood trivial to fix. |
I'm still concerned of the inconsistencies the "trivial fix" does not takes into account, e.g.: @a: #abc; // OK
@{a} {1: 1}
@b: #foo; // OK
@{b} {2: 2}
@c: #abcfoo; // SyntaxError: Invalid HEX color code
@{c} {3: 3}
In other words, I'd expect if we legalize the code like this, then all three cases should pass. (By now while the first two pass OK, they still are in "unspecified behaviour" category. But if we make this officially supported syntax it should become consistent. As I already mentioned above it would be not so easy to reasonably answer "why first two are OK and the 3rd isn't?" stuff). |
@seven-phases-max I see this mostly as applying the "keep color in its original form" rule to shorthand colors too. So I see the inconsistency you mention as slightly different issue (although likely to be easy to fix too). Since following thing compiles: @c: .abcfoo;
@{c} {3: 3} into: .abcfoo {
3: 3;
} Maybe My primary goal is to close all easily closeable bugs I can find, either by fixing or closing as 'wont fix'. There is no advantage in keeping tiny stuff like this open forever. Feel free to suggest favorites if you have some. |
Interpolation treats three letters long id selectors as colors and converts them into their long form:
compiles into
expected result:
Note: string interpolation does the same thing.
Workaround - store only identifier in the variable:
The text was updated successfully, but these errors were encountered: