Closed paulyoung closed 9 years ago
The problem here is the meaning of :: inside the rule. In the wip version of GSS, :: points to the object matched by the current rule. Which is a virtual in this case. If we suppose that virtual constraints would be simply a rule, then we'll need to use some other pseudo selector to refer to element matched by parent rule.
I imagine that we'll have these pseudo classes:
Why ::that is a good idea? Because it works as mixins - you can bind your properties to the scope of a parent rule (or global scope).
So yes,
"foo" {
left: ::that[left]; /*Note that == is not necessary now*/
width: ::that[width];
}
or
"foo" {
::[left] == ::that[left];
::[width] == ::that[width];
}
is going to work. Optionally, we could add some sugar:
"foo" {
&[left] == ^[left]; // & points to ::this, ^ to ::that
width: ^[width];
}
I think I complicated things a little by using ::
.
I suppose it would be fine to say that left: == ::[left];
makes no sense inside of a virtual. I would expect width: == ::[height];
to be valid though...
I like the idea of using ^
to mean the parent element.
:: makes sense if you do this inside virtual:
"something" {
left: 20%
right: &[left]
}
because virtual is basically a container for variables, so it should be able to refer its own properties
I believe my original request is now possible via the parent scope selector:
"foo" {
left: == ^[left];
width: == ^[width];
}
I'd find it useful to be able to do this:
as opposed to this: