vite-plugin-svg-spritemap icon indicating copy to clipboard operation
vite-plugin-svg-spritemap copied to clipboard

Question: How to programmaticaly add correct href paths?

Open dsine-de opened this issue 1 year ago • 2 comments

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!

dsine-de avatar Feb 16 '24 11:02 dsine-de

Seems I need to use createElementNS with the correct SVG namespace if there is no other way provided by the plugin.

dsine-de avatar Feb 16 '24 11:02 dsine-de

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?

Applelo avatar Feb 22 '24 08:02 Applelo