W3C home > Mailing lists > Public > www-style@w3.org > November 2014

Re: [selectors] Proposal: :only-of(selector list)

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 13 Nov 2014 17:48:01 -0800
Message-ID: <CAAWBYDDpz076t8VwHacB3DAM4iSi_SXeNxPi3urBXkR7Bx8Djg@mail.gmail.com>
To: Benjamin Poulain <benjamin@webkit.org>
Cc: www-style list <www-style@w3.org>
On Wed, Nov 12, 2014 at 8:30 PM, Benjamin Poulain <benjamin@webkit.org> wrote:
> On 11/11/14 4:14 PM, Tab Atkins Jr. wrote:
>>
>> On Mon, Nov 10, 2014 at 8:40 PM, Benjamin Poulain <bpoulain@apple.com>
>> wrote:
>>>
>>> It looks like it would be useful to include :only-of(selector list) in
>>> Selectors Level 4.
>>>
>>> It is already possible to achieve the same behavior by using :nth-child(1
>>> of selector list):nth-last-child(1 of selector list) but that is
>>> significantly uglier. Repeating the selector list is error prone when
>>> updating the stylesheet and the specificity is doubled.
>>>
>>> The selector :only-of(selector list) would behave like :nth-child(1 of
>>> selector list):nth-last-child(1 of selector list) but with lower specificity
>>> (accounting for the selector list once instead of duplicating it). The
>>> definition of :only-of-type is pretty much the same.
>>>
>>> The implementation is trivial based on the existing :nth-child() and
>>> :nth-last-child(). The single :only-of() is likely to be more efficient than
>>> :nth-child():nth-last-child() in most implementations.
>>
>>
>> Do you have some use-cases to share that would use this?
>
>
> Pretty much the same uses use cases of :only-of-type and :only-child exists
> for :only-of.
>
> Many designs are based on classes or data attributes. Having :only-of-type
> does not help in those cases.

Sounds reasonable.  I'll bring it up at the next telcon.

~TJ
Received on Friday, 14 November 2014 01:48:47 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:26 UTC