Jacob, Doug and Wade,
Thanks for your assistance here. It definitely helps!
regards
David
- Original Message -
From: Jacob Beard
To: svg-developers
Sent: Sunday, October 17, 2010 3:59 AM
Subject: Re: [svg-developers] explaining setAttribute, setAttributeNS and
carburetors
On Sun, Oct 17, 2010 at 6:48 AM, Doug Schepers d...@schepers.cc wrote:
But in this case, the only thing to know there is that (for whatever
reason) attributes are generally in the 'null' namespace (*not* in the
SVG or HTML or whatever host-language namespace). I recommend teaching
setAttribute for normal attributes, and setAttributeNS only for xlink:href.
The DOM Level 2 Core spec has something to say about mixing
namespace-aware DOM methods with non-namespace-aware DOM methods:
Note: DOM Level 1 methods are namespace ignorant. Therefore, while it
is safe to use these methods when not dealing with namespaces, using
them and the new ones at the same time should be avoided. DOM Level 1
methods solely identify attribute nodes by their nodeName. On the
contrary, the DOM Level 2 methods related to namespaces, identify
attribute nodes by their namespaceURI and localName. Because of this
fundamental difference, mixing both sets of methods can lead to
unpredictable results. In particular, using setAttributeNS, an element
may have two attributes (or more) that have the same nodeName, but
different namespaceURIs. Calling getAttribute with that nodeName could
then return any of those attributes. The result depends on the
implementation. Similarly, using setAttributeNode, one can set two
attributes (or more) that have different nodeNames but the same prefix
and namespaceURI. In this case getAttributeNodeNS will return either
attribute, in an implementation dependent manner. The only guarantee
in such cases is that all methods that access a named item by its
nodeName will access the same item, and all methods which access a
node by its URI and local name will access the same node. For
instance, setAttribute and setAttributeNS affect the node that
getAttribute and getAttributeNS, respectively, return.
http://www.w3.org/TR/DOM-Level-2-Core/core.html
So, it seems like if you're strictly following the spec, mixing
setAttribute and setAttributeNS might not be the best idea, as it may
lead to inconsistent results across implementations. In practice, I
very rarely use the non-namespaced versions (only when I need to do a
bit of HTML DOM scripting in IE), so this may work just fine.
Best,
Jake
[Non-text portions of this message have been removed]
-
To unsubscribe send a message to: svg-developers-unsubscr...@yahoogroups.com
-or-
visit http://groups.yahoo.com/group/svg-developers and click edit my
membership
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
* Your email settings:
Individual Email | Traditional
* To change settings online go to:
http://groups.yahoo.com/group/svg-developers/join
(Yahoo! ID required)
* To change settings via email:
svg-developers-dig...@yahoogroups.com
svg-developers-fullfeatu...@yahoogroups.com
* To unsubscribe from this group, send an email to:
svg-developers-unsubscr...@yahoogroups.com
* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/