Hi, Jacob-

Jacob Beard wrote (on 10/17/10 3:59 AM):
> "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."

Thanks for digging that up.  I think the author of that may actually 
have been a bit confused... or at least, they didn't state the facts 
clearly.  (There may have been a bit of propagandizing there, as well, 
to get people to use XML namespaces more, perhaps.)

Indeed, if you try to set a namespaced attribute with setAttribute(), it 
won't work correctly... the attribute will be placed in the null 
namespace.  So, when you use

  el.setAttribute( "xlink:href", "#foo" );

it's the equivalent of using

  el.setAttributeNS( null, "xlink:href", "#foo" );

where the local node-name (unintuitively) is 'xlink:href', not 'href' in 
the XLink namespace.

But that's only when you're dealing with namespaces.  Since most 
attributes are in the null namespace, and setAttribute() places 
everything in the null namespace, then these are equivalent and 
perfectly safe:

  el.setAttribute( "fill", "#f00" );
  el.setAttributeNS( null, "fill", "#f00" );


As an aside, this is actually a rather poor design, which could have 
been made better if they had simply accounted for hardcoded prefixed to 
be bound to specific namespaces, rather than introducing the arbitrary 
level of abstraction where any namespace could have any prefix string; 
this is made a bit simpler in HTML5, which does define a few hardcoded 
prefixes for namespaces.  Maybe in some future version of XML, XML 
Namespaces, or the like, this can be be expanded beyond HTML.

Regards-
-Doug


------------------------------------

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

Reply via email to