That makes sense. I was tempted to go down the route of using sizzle or sly etc. Would have been the sensible thing to do. Mine has a get method attached which does return an array. I could add the length test to account for single nodes though.
I use Sizzle (the selector engine in jQuery). Sizzle returns an array of DOM elements. My function returns the first item if there's only one, unless I specify using the arr attribute that I want an array even if there's only one item. Makes it easy to do stuff like this, knowing I'm working with an actual DOM element rather than some other object:
So, for CSS it's clear that as we KNOW it parses from right to left, any extra step will demand more processing.
Btw, i know this has been widely debated, but right-to-left for CSS seems counter intuitive for developers.
Come on, who ever replaced "#div a" by adding a class to every single link in DIV ? seriously ...
Regarding JS, there doens't seem to be a clear consensus. Looks like there may be a difference between the selector engines ... (btw jquery is not the only one out there).