W3C home > Mailing lists > Public > public-css-testsuite@w3.org > April 2008

Re: Test of empty substring-matching attribute selectors

From: Bert Bos <bert@w3.org>
Date: Wed, 2 Apr 2008 19:23:45 +0200
To: public-css-testsuite@w3.org
Message-Id: <200804021923.46555.bert@w3.org>

On Wednesday 02 April 2008 18:50, fantasai wrote:
> Bert Bos wrote:
> > This test:
> >
> >    
> > http://www.w3.org/Style/Examples/013/css3-selectors-0603-empty.html
> >
> > tries to test substring-matching attribute selectors ~=, |=, ^=,
> > *=, $= (Selectors section 6.3[1]) with empty values, such as
> > p[title^=""].
> >
> > It assumes that such selectors are valid (i.e., not ignored) but
> > match nothing. I think that is what we decided last week[2]. I'm
> > not sure if we decided anything for |=, but it seems consistent to
> > treat it the same way.
> >
> > This test:
> >
> >     http://www.w3.org/Style/Examples/013/t050801-empty-attr-01.html
> >
> > is the same, except that it only tests ~= and |=, and is thus
> > suitable for CSS level 2, section 5.8.1[3].
> >
> > [1] http://www.w3.org/TR/css3-selectors/#attribute-selectors
> > [2] http://www.w3.org/2008/03/28-css-irc.html#T00-52-44
> > [3] http://www.w3.org/TR/CSS21/selector.html#matching-attrs
>
> Bert, [attr|=""] is not an ambiguous (match everything or match
> nothing) case. It is very clear from the existing definition that it
> should match attr=""
>    attr="-foo"
>    attr="-"
> and not
>    attr="foo--"
>    attr="foo"

I would drop the "very" and probably the "clear," too :-) It's not any 
more clear than the other substring-matching attributes. None of them 
says that the right-hand side must be non-empty to have an effect, and 
yet that is what we decided it meant.

It seems consistent to treat |= the same as ~=, except that the former 
uses white space as separators and the latter dashes. So if

    [foo~=""] does not match foo=" "

then also

    [foo|=""] does not match foo="-"

It's interesting that all browsers (at least those I tested: Konqueror, 
Opera 9.5 beta, iCab, Safari and Firefox) indeed treat [foo|=""] and 
[foo~=""] as matching nothing, although they treat [foo^=""] as 
matching always.

Firefox also treats [foo*=""] as matching nothing.

Konqueror is inconsistent, because [foo~=""] doesn't match, except when 
foo is itself empty (foo=""). I don't understand the logic of that. 
(Safari does the same, but not Webkit.)



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Wednesday, 2 April 2008 17:24:27 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 20 September 2010 17:51:56 GMT