Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28702
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: setting attributes from a namespace |
| Date | 2015-09-20 20:44 +0200 |
| Organization | Liberty Development |
| Message-ID | <mtmupq$das$1@news.albasani.net> (permalink) |
| References | <43eec4db-3acf-4840-bfd0-af2ea843a69d@googlegroups.com> |
Jay Braun wrote: > I have a Javascript application where images are being displayed using SVG. > > The following works: > > I define the namespace, e.g.: > var xmlns = "http://www.w3.org/2000/svg"; > > I create each element with a reference to the namespace, e.g.: > var elem = document.createElementNS (xmlns, "path"); > > And then I assign attributes in this manner: > elem.setAttributeNS(null, "fill", fillcolor); //fillcolor has been assigned > > This all works great. I wanted to see if my app would execute faster if I replaced the attribute assignment with something like: > elem.fill = fillcolor; > > In other words, perhaps reducing the amount of text that the interpreter has to process, as well as reducing the number of function calls, might speed things up. But the elements are not drawn. The browser console indicates no syntax errors. > > Must I use setAttributeNS to make use of the SVG specification? The SVG DOM is more complicated than the HTML DOM where most attributes defined on HTML elements translate directly into element properties in the DOM. There is no fill property defined. You can try with the CSS DOM elem.style.fill = fillcolor but I am not sure how good the support for that is across user agents.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
setting attributes from a namespace Jay Braun <lyngwyst@gmail.com> - 2015-09-20 10:11 -0700
Re: setting attributes from a namespace Martin Honnen <mahotrash@yahoo.de> - 2015-09-20 20:44 +0200
Re: setting attributes from a namespace Jay Braun <lyngwyst@gmail.com> - 2015-09-20 13:49 -0700
Re: setting attributes from a namespace Martin Honnen <mahotrash@yahoo.de> - 2015-09-21 11:18 +0200
csiph-web