Short question.
Dojo’s query module always returns an array of nodes. Is there any way I can config/modify it so that
var contentNode = query('#content')[0];
can be written
var contentNode = query('#content');
instead?
That extra [0] annoys me, especially when Id’s are unique.
No. I’m sure this is a very conscious API decision so the return value is always uniform. That way the calling code doesn’t need to know the details of the path and whether it would return a list or a single node.
dojo.byId('content')does what you want though. Perhaps you could use that instead?