premasagar / pablo

Pablo is a lightweight, expressive JavaScript SVG library. Pablo creates interactive drawings with SVG (Scalable Vector Graphics), giving access to all of SVG's granularity and power.
https://pablojs.com
MIT License
413 stars 16 forks source link

Allow conversion of SVG markup -> elements #72

Closed premasagar closed 10 years ago

premasagar commented 11 years ago

Detect if SVG in text/html is supported, with a modification of this check: http://diveintohtml5.info/everything.html#inline-svg

var e = document.createElement('div');
e.innerHTML = '<svg></svg>';
return !!('SVGSVGElement' in window && e.firstChild instanceof window.SVGSVGElement);

If supported, use it to innerHTML the markup.

If not, create a new document in either an iframe or an object, then importNode from the iframe/object's document to the current window's document.