Re: [selectors] :sorted pseudoclass for sorted tables

> On Nov 25, 2013, at 8:06 PM, Peter Linss <peter.linss@hp.com> wrote:
> 
> 
>> On Nov 25, 2013, at 1:05 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> 
>> Now that HTML defines a way to sort tables, Hixie would like a
>> pseudoclass letting authors target based on this:
>> <https://www.w3.org/Bugs/Public/show_bug.cgi?id=20522>
>> 
>> His proposal is for a :sorted pseudo-class, which also comes in a
>> functional version, :sorted( [ ascending | descending ] ).  He's
>> looking at defining it to match <th> elements that head a sorted
>> column.
>> 
>> Thoughts?  Any objections to me adding this to Selectors 4?
> 
> Sounds reasonable. If we¡¯re going to add it though, I suggest we also add the capability to select on the ordinality of the sort, something like:
> :sorted( [ ascending | descending ] || <number> )

Would numeric vs. alphabetic change how it was styled? I wouldn't think so. I imagine it would mainly be useful for setting a background color or maybe gradient for the column's TDs and TH's, and for setting a triangle or arrow background in the TH.

> It¡¯s also unfortunate that the selector uses ¡®ascending¡¯ and ¡®descending¡¯ where HTML uses ¡®¡¯ and ¡®reversed¡¯ for the sort order. It would be easier for authors to remember if they were in sync.

Then I think we should have :sorted( [ normal | reversed | unsorted ] ). 'Unsorted' would be for setting styles that only apply when the sister values do not apply. 'sorted(normal)' would go well with a '' sort order value.

Is there a link to where this is described in HTML? Does the TH get an attribute of 'sorted' and 'sorted=reversed' or something? Do the TDs in scope also get to use the pseudo-class? It seems like the attribute should also be able to be used on a COL or TR, but I guess that is not up to us.

Received on Tuesday, 26 November 2013 16:00:51 UTC