- From: Andrew Fedoniouk <news@terrainformatica.com>
- Date: Fri, 15 Jan 2010 19:08:31 -0800
- To: Lachlan Hunt <lachlan.hunt@lachy.id.au>
- CC: Niels Matthijs <niels.matthijs@internetarchitects.be>, www-style list <www-style@w3.org>
Lachlan Hunt wrote:
> Niels Matthijs wrote:
>> I'm quite sure that someone before me must've thought about this, or
>> maybe I just didn't look closely enough at the latest specs, but I
>> believe we are missing an important css combinator.
>>
>> For the full explanation you can check the following article:
>> http://www.onderhond.com/blog/work/missing-css-combinator
>>
>> In short, I'd like something between the space and child combinator. A
>> combinator that allows for an (x) number of levels between parent and
>> child, but stops at the first matching level it hits.
>
> Here's a similar proposal of mine from 2003. It's basically the same
> idea, but using ^ instead of %.
>
> http://lists.w3.org/Archives/Public/www-style/2003Dec/0034.html
>
Here is one more practical use case for such selector.
Let's say we have following markup:
<body dir="rtl">
...
<div dir="ltr">
<ul>...</ul>
</div>
...
</body>
There is a need to have selector that will allow to specify following:
<if ltr environment> ul
{
padding-left: 10px;
}
<if rtl environment> ul
{
padding-right: 10px;
}
<if ltr environment> is simply this: "nearest parent of the element with
defined @dir and this @dir is precisely 'ltr'".
And <if rtl environment> is this: "nearest parent of the element with
defined @dir and this @dir is precisely 'rtl'".
Seems like that proposed '%' (or '^') will not allow to do that - is not
generic enough.
I think that instead of '%' we should have something like "no such
parent" construction.
So to select nearest <header> to the .box we can write:
.box no(header) header { ... }
And for the ltr/rtl environment testing we can write simply this:
[dir=ltr] no([dir]) ul { ... ltr styles ... }
[dir=rtl] no([dir]) ul { ... rtl styles ... }
So such no() combinator:
A no(B) C
is pronounced as:
If there are any parent elements in the child/parent chain between C and
A then none of these parent elements should match B.
Such selector can be implemented pretty effectively - it has
computational complexity of "A B C" selector.
Huh?
--
Andrew Fedoniouk.
http://terrainformatica.com
Received on Saturday, 16 January 2010 03:08:54 UTC