W3C home > Mailing lists > Public > www-svg@w3.org > February 2005

Re: getElementById method on SVGSVGElement

From: Thomas DeWeese <Thomas.DeWeese@Kodak.com>
Date: Mon, 07 Feb 2005 07:46:35 -0500
Message-ID: <4207632B.1060302@Kodak.com>
To: Robin Berjon <robin.berjon@expway.fr>
CC: www-svg@w3.org

Robin Berjon wrote:

> Thomas DeWeese wrote:
>> 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? 

    No. So, you would consider my example code to be in error?
If so there is no way to reuse an id and keep the document
consistent in the process, at some point the id which may
be referenced must be undefined.  This introduces all sorts
of interesting issues about how/when an SVG document can be

> 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]. 

    So it does...

> Based on that, I would expect that given 
> element 'el' not attached to the tree but belonging to document 'doc' 

    But I see no requirement on the ownerElement belonging to
'doc', or that ownerElement be in the same processes or even on the
same machine, so following your logic a DOM implementation must
search every machine in existence for an element with that id.
I knew id's had to be unique but I didn't realize they had to GUIDs ;)

> 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.

    Clearly there is some subset of the DOM universe that
is expected to be searched, I don't see a clear indication of
that that universe is from the DOM spec.  I personally find it
quite a stretch to extend the search to all nodes ever created
by a document (does it hold 'hard' references to them?).

    It is probably time to request a clarification from the DOM WG.

> [0]http://www.w3.org/TR/DOM-Level-3-Core/core.html#Attr-isId
Received on Monday, 7 February 2005 12:46:38 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:02 UTC