|
Re: getElementById method on SVGSVGElement: msg#00038web.svg
Thomas DeWeese wrote: Robin Berjon wrote: By having two elements with the same ID? No, that's not a DOM error :) The behaviour of the DOM under such circumstances is undefined. If so there is no way to reuse an id and keep the document There are *many*, *many* situations in which it is if not difficult at least impossible to maintain a document in a way that the target language would consider consistent (if only based on some schema validation) by manipulating the DOM. DOM 3 Validation goes into some (but not much) detail to explain these sorts of problems. Ideally one would have some form of transaction support to define which changes are atomic (this would actually probably enable some interesting optimizations for DOM implementers) but there's no such thing, and users wouldn't use it anyway. Based on that, I would expect that given element 'el' not attached to the tree but belonging to document 'doc' Nah, you're stretching my argument :) There is indeed no argument stating that the element be in the same process or machine — you could well have a distributed DOM. What I'm saying is that it is a very reasonable (and I believe, common) implementation strategy to cache all IDs in a table that maps them to their elements — otherwise you have to perform a linear search of the entire document to get at an ID, which sort of nullifies the advantage of having IDs (instead of, say, running an XPath query) in the first place. A highly likely position in which to maintain such a table is in the methods that manipulate attributes as well as setIdAttribute* and importNode. Since I see no requirement that the element be attached to the tree in order to be returned by gEbId, and since maintaining the ID table for all element manipulations is likely to be so costly that you wouldn't want to have the table at all, I would assume it to be an unreasonable expectation to think that elements belonging to the document but not attached to it will interoperably never be returned. It's the spec doesn't even say the returned element needs to have ownerDocument be the same document that the message was sent to, but I would consider it unreasonable if it weren't the case, and a reasonable expectation that it is :) 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. It's not "ever created" since some of those may have been imported by another document, or destroyed entirely, but rather those that have their ownerDocument set to that given document. And it's not nodes but just elements. It is probably time to request a clarification from the DOM WG. The DOM WG? What DOM WG? -- Robin Berjon Research Scientist Expway, http://expway.com/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: getElementById method on SVGSVGElement: 00038, Thomas DeWeese |
|---|---|
| Next by Date: | Re: getElementById method on SVGSVGElement: 00038, Robin Berjon |
| Previous by Thread: | Re: getElementById method on SVGSVGElementi: 00038, Thomas DeWeese |
| Next by Thread: | Re: getElementById method on SVGSVGElement: 00038, Jonathan Watt |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |