vite-plugin-svg-spritemap
vite-plugin-svg-spritemap copied to clipboard
Question: How to programmaticaly add correct href paths?
Hi, how would I add the correct SVG path when using native JavaScript?
This won't replace the correct path:
const svg = document.createElement('svg');
const svgUse = document.createElement('use');
svgUse.setAttribute('href', '/__spritemap#sprite-comment');
svg.appendChild(svgUse);
Thank you!
Seems I need to use createElementNS
with the correct SVG namespace if there is no other way provided by the plugin.
Hi, the plugin doesn't provide any kind of API to manage SVG with javascript. I didn't test it with this kind of usage in mind. Maybe in a future feature?