Re: [Selectors4] Another interpretation of [att~=val] when val contains space

On 03/10/2011 09:25 PM, Kang-Hao (Kenny) Lu wrote:
> (On courtesy of John Hax's proposal[1])
>
> I think this should have been proposed before, but I'll post it again in
> case it hasn't.
>
> Currently, for [att~=val], the selectors spec says:
>
> [[ If "val" contains whitespace, it will never represent anything (since
> the words are separated by spaces). ]]
>
> I am wondering whether we can redefine this to be a list of possible
> match. Namely,
>
> [rel~="a b c d"]
>
> should represent what is represented by
>
> :any([rel~=a],[rel~=b],[rel~=c],[rel~=d])
>
> The use case is something like,
>
> nav a[rel~="prev next first last up"]::before {
>    border-radius: 4px;
>    background: url(nav-link-bg.png)
> }
> which will be less lengthy than the :any equivalent.
>
> My personally opinion is that the use case is not strong enough to add a
> hack to the current syntax, but I am curious about what folks in this
> forum think.

I think I agree with your opinion. :) But we could do something like

   [rel~=prev,next,first,last,up]                 /* quotes not needed for idents */
   [rel ~= "prev", "next", "first", "last", "up"] /* if you need/prefer quotes */

That will allow us to use the same notation for other types of attribute
selectors. I'll ask what the WG thinks, and if they agree I'll add it to
the Selectors 4 draft.

~fantasai

Received on Monday, 10 October 2011 21:17:31 UTC