I made a quick svg-include service that simply replaces elements in the DOM that have this attribute with some svg. However, I hit the road block when I tried to replace.
To use element.replace(), each node must have a type node. How do I evaluate an SVG string so that I can replace it?
Here is a snippet:
//Do eval here so that svg is Node not String
svg = SvgIncludeSevice.paths[i].svg;
//svg.className = results[j].className;
results[j].parentNode.replaceChild(svg, results[j]);
And here is my JSFiddle!
Thanks everyone!
ON A WAY!
I will not accept answers saying to use jQuery Prototype or something else. I want to use my own calls only.
UPDATE
I tried using this messy method that I found to convert my string to managed HTML, but it still didn't work! He was silent...
This is what I changed:
hiddenDiv.innerHTML = SvgIncludeSevice.paths[i].svg;
svg = hiddenDiv.firstElementChild;
if(svg)
{
svg.className = results[j].className;
results[j].parentNode.replaceChild(svg, results[j]);
}
, SVG , ! , . :
, SVG node:

:

, ...
, JSFiddle, . , JSFiddle - ...: (