W3C home > Mailing lists > Public > public-webapi@w3.org > January 2007

Re: Selectors API: Multiple elements with the same ID

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Sat, 27 Jan 2007 19:30:58 +0100
To: "Simon Pieters" <zcorpan@gmail.com>
Cc: "public-webapi@w3.org" <public-webapi@w3.org>
Message-ID: <656nr2hkaij3105us5q1gvh20m8e2t110i@hive.bjoern.hoehrmann.de>

* 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.
>  --  
>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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:22 UTC