logo       

Re: getElementById method on SVGSVGElement: msg#00033

web.svg

Subject: Re: getElementById method on SVGSVGElement


Thomas DeWeese wrote:
Well, it would seem to me that the restriction is that duplicate
id's are not allowed on any two Elements that can be reached via
the DOM tree traversal methods (getParentNode, firstChild, nextSibling, etc). If the node is in the document then all of it's
nodes are reachable from all other nodes in the document and thus
the id's in the SVG element's subtree must not duplicate any in the
rest of the document tree. I don't think this part is any different
from the behavior of any existing conforming DOM implementation.

Do you have a reference for this? I couldn't find anything in the DOM allowing (or forbidding) such behaviour. Nodes that aren't attached to the hierarchy still belong to the document. I could well see an implementation that doesn't check to see if a node is attached or not before indexing IDs in a global ID table (in fact I know of at least one that does that).

In fact, if I read DOM 3 Core correctly, the attachement of the node to the tree appears to be irrelevant. If you look at the spec, the isId field on Attr says "when it is [of type ID] and its value is unique, the ownerElement of this attribute can be retrieved using the method Document.getElementById"[0]. Based on that, I would expect that given element 'el' not attached to the tree but belonging to document 'doc' and having an attribute 'foo' of value 'bar', if I did el.setIdAttribute('foo', true) it appears to be expected that doc.getElementById('bar') would return el.

[0]http://www.w3.org/TR/DOM-Level-3-Core/core.html#Attr-isId

--
Robin Berjon
Research Scientist
Expway, http://expway.com/






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise