B
B
BanterFace2018-04-09 18:20:49
JavaScript
BanterFace, 2018-04-09 18:20:49

What namespace is valid for xml attributes inside svg?

The task is to start the svg animation through js. My (not) implementation - create a dom node with the animate tag, set the necessary attributes, insert it at the end of the svg. The problem is when doing

elem.setAttributeNS('http://www.w3.org/2000/xmlns', 'xmlns:xlink', 'http://www.w3.org/1999/xlink')

(as well as similarly setting any other attribute) I catch the error:
Uncaught DOMException: Failed to execute 'setAttributeNS' on 'Element': ' www.w3.org/2000/xmlns ' is an invalid namespace for attributes.

If you try to use ordinary .setAttribute()and .createElement(), then the animation simply does not work without any errors.
Question: what namespace is valid for xml attributes inside svg?
Look at the situation (see the error in the console)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
ElijahTr, 2018-04-09
@ElijahTr

Or something like this:
https://codepen.io/elijah_tr/pen/pLqYLp
(probably not cross-browser)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question