Re: Selectors API naming

Hi, Simon-

Simon Pieters wrote:
> 
> A way to reduce the number of typos might be to drop the trailing "s" 
> from both method names. It's equally clear what it does IMHO.

Hmmm... that's a reasonable point, but "Selector" (singular) is a bit 
misleading.  You can provide multiple criteria.



> Of the two getElementListBySelector and getElementsBySelector, the 
> people I've spoken to seem to prefer getElementsBySelector.

Look at this:

var el = document.getElementBySelector(...);
el.setAttribute(...)
///blah blah more code
var el = document.getElementsBySelector(...);
el.setAttribute(...)

Imagine debugging that.  A single "s" would not be distinctive enough, IMO.


> Although if API consistency is desireable then "getElementListBy..." 
> doesn't seem to appear anywhere as far as I can tell.

Right, that was by design.  It's not about some sacrosanct magic word, 
but about a naming scheme... we considered NodeList instead, but didn't 
want people to think that it's a list of nodes (it's only elements), nor 
that it's live.  Thus, the distinction.

Regards-
-Doug

Received on Friday, 26 January 2007 23:08:51 UTC