Re: [selectors-api] Leading and Trailing Whitespace in Selectors (was: Handling :link and :visited Pseudo Classes)

Boris Zbarsky wrote:
>> (As an aside, IE8 throws if the selector argument has trailing white
>> space, but does not if it's leading white space instead. A quick reading
>> of css3-selectors suggests white space on either end is illegal).
> 
> Interesting.  My first-cut implementation in Gecko allows both leading 
> and trailing whitespace, more or less as a consequence of reusing the 
> existing CSS selector parsing, which allows whitespace around selector 
> lists.  It sounds like this might need to be explicitly specified (with 
> tests in the test suite, etc).

 From my reading of the Selectors grammar, that certainly does seem to 
be the case (but someone please correct me if I'm wrong).  I believe 
there are 3 possible ways that this issue could be dealt with:

1. Accept it as is and thus require selectors with leading or trailing
    space to throw a SYNTAX_ERR exception.

2. Ask the CSS WG to modify the grammar of Selectors to allow leading
    and trailing space.

3. Add a requirement to Selectors API to trim leading and trailing white
    space before processing the selector.

Option 1 seems to be incompatible with 3 1/2 implementations.  Gecko, 
WebKit and Opera's implementations allow both leading and trailing 
whitespace, and IE allows only leading whitespace.  It also seems like 
an unnecessary error to inflict upon authors.

Option 2 or 3 would solve the issue, but option 2 has the advantage of 
applying to all other langauges that use Selectors, such as XBL.

-- 
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/

Received on Friday, 18 April 2008 01:29:28 UTC