- From: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
- Date: Wed, 02 Apr 2008 10:57:44 +0200
- To: Bjoern Hoehrmann <derhoermi@gmx.net>
- Cc: Boris Zbarsky <bzbarsky@MIT.EDU>, "Web APIs WG (public)" <public-webapi@w3.org>
Bjoern Hoehrmann wrote: > It would be easier to define that, if the argument starts with a non- > white space combinator, it is prefixed with a selector that selects the > element node it is called on and only that node. That would give you > > myFooElement.querySelectorAll(">*")[3] Urgh, to say the least. First it means the argument of querySelectorAll is not always a valid Selector. That is bad design. With both my Selectors spec's editor and my CSS WG Co-Chair hats on, that's not desirable. Second, querySelectorAll's implementation would need to parse the first token of the argument to recognize it, and would then rely on the Selectors parser one first time before calling a second time to resolve the selector. Or, second possibility, the Selectors parser has to be tweaked to add a context if the first token is a combinator. From my implementor's perspective, both are NOT acceptable. Really really ugly. > We could also standardize the popular .getChildrenByTagName() method, > that would give the similar > > myFooElement.getChildrenByTagName("*")[3] First it's not that popular. I write complex JS code on a daily basis and that's the first time I hear of it. Second, once again I don't see why we have childNode.item() and not childElements.item(). Please give one *good* reason why we cannot do that. Performance ? Let me laugh ! Complexity of implementation ? I guess Jonas answered to that. No use cases ? I would use it immediately and the JS code of Firefox and extensions is full of use cases. Speaking of memory footprint and performance, I certainly prefer getting the nth element child individually through item() rather than getting the whole list of children and then reaching the nth index of it... > Either would be preferable over > > myFooElement.querySelector(":nth-child(3)", null, myFooElement) Well... From a design perspective, that is MUCH better than your querySelectorAll() tweak above... </Daniel>
Received on Wednesday, 2 April 2008 08:58:17 UTC