Re: Selectors API: Multiple elements with the same ID

* Simon Pieters wrote:
>> Since having a second element with the same ID is invalid there is no  
>> need for a browser to continue looking once it finds the first one since  
>> the subsequent ones shouldn't be there and it is therefore more correct  
>> to ignore them and assume that they don't exist than it would be to  
>> continue searching for something which in a valid page wont be there.  
>> Any browser that continues searching once it finds the first occurrence  
>> of an id is just being inefficient.
>  --  
>http://www.sitepoint.com/forums/showthread.php?t=454192#post_message_3258069
>
>Perhaps this case has to be defined explicitly. Should getAll() (or  
>whatever it ends up being called) catch only the first element when  
>there's an ID in the selector (not group of selectors), or would it catch  
>all elements that match the selector?

This is out of scope of the document. The method would return all
elements that match the selector. When an element matches a selector
is defined by the CSS Selectors specification. If that specification
is unclear about this case, that's for the CSS WG to address. All
the API specification could usefully say is how getElementById(...)
compares to the method that returns a single element if we are to
keep that method, since the behavior of the two may be different.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Saturday, 27 January 2007 18:31:06 UTC