Re: [attr|=""] Selector

Bert Bos wrote:
> 
>> Given this definition of |= there is no ambiguity about whether
>> [attr|=""] matches a given attribute. None.
> 
> To a programmer, maybe: [foo|=""] matches foo="-bar", because the value 
> starts with an empty string immediately followed by a dash. But that's 
> the same for ^=, which is defined as:
> 
>     Represents an element with the att attribute whose value begins
>     with the prefix "val".
> 
> So clearly [foo^=""] matches foo="bar", because "" is a prefix of every 
> string. And yet we decided that it was *not* clear, and indeed was not 
> the case.
> 
> I don't care whether the empty string matches everything or nothing 
> (although I suspect that most people will not consider the empty string 
> to be a prefix of anything), but I think we should be consistent.

In the case of [attr|=""] a literal interpretation of the wording would
not match everything, nor would it match nothing. It matches a very
specific subset of values. For the other selectors, ~=, *=, ^=, $=, the
choice is between everything and nothing, and there we decided to be
consistent with ~= and match nothing.

~fantasai

Received on Wednesday, 2 April 2008 20:49:38 UTC