- From: Joćo Eiras <joao.eiras@gmail.com>
- Date: Sun, 07 Dec 2008 14:41:06 -0000
IMO, anyone suggesting a Node.getElementById clearly does not know very well how getElementById is supposed to work. There are ways to transverse a DOM tree currently, either DOM properties and methods, XPath, selectors API and such. Considering ids are required to be unique in the context of a single document, implementations can, and do, implement id lookup using optimized data structures like a hash table, which is much more performant than doing transversal. So if there is a special node in a document, add an id to it and get its reference will be performant (ideally O(1)). If the uniqueness requirement is removed, then getElementById looses its whole meaning and should actually be removed from the specification entirely, else then we would need more bloat like getElementById or getElementListById and whatever. If you really need to get the element with id in a subtree, connected or disconnected from the main tree, one can use selectors API, DOM transversal, XPath, etc. So, IMO the DOM spec is just fine. What is asked for Node.getElementById is already supported by other APIs.
Received on Sunday, 7 December 2008 06:41:06 UTC