I have a SVG in my document and I add a symbol to it with JavaScript like this:
var myScene =document.getElementById('myScene');
var useSVG = document.createElement('use');
useSVG.setAttribute('xlink:href','spriteSheet.svg#mySymbol');
useSVG.setAttribute('x','10');
useSVG.setAttribute('y','30');
useSVG.setAttribute('width','10');
useSVG.setAttribute('height','10');
myScene.appendChild(useSVG);
The symbol does not show up whereas the resulting code is exactly the same as another node written in HTML which is displayed correctly.
Code shown in debugger:
<svg id="myScene" width="200px" height="200px">
<use xlink:href="spriteSheet.svg#mySymbol" x="5" y="50" width="10" height="10"></use>
<!-- this one was in html, it is visible -->
<use xlink:href="spriteSheet.svg#mySymbol" x="10" y="30" width="10" height="10"></use>
<!-- this one is added with javascript. it is not displayed -->
</svg>