-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsvginnerhtml.min.js
3 lines (3 loc) · 1.21 KB
/
svginnerhtml.min.js
1
2
3
(function(g){var b=["SVGSVGElement","SVGGElement"],d=document.createElement("dummy");if(!b[0]in g)return!1;if(Object.defineProperty){var e={get:function(){d.innerHTML="";Array.prototype.slice.call(this.childNodes).forEach(function(a){d.appendChild(a.cloneNode(!0))});return d.innerHTML},set:function(a){var b=this,e=Array.prototype.slice.call(b.childNodes),f=function(a,c){if(1!==c.nodeType)return!1;var b=document.createElementNS("http://www.w3.org/2000/svg",c.nodeName.toLowerCase());Array.prototype.slice.call(c.attributes).forEach(function(a){b.setAttribute(a.name,
a.value)});"TEXT"===c.nodeName&&(b.textContent=c.innerHTML);a.appendChild(b);c.childNodes.length&&Array.prototype.slice.call(c.childNodes).forEach(function(a){f(b,a)})},a=a.replace(/<(\w+)([^<]+?)\/>/,"<$1$2></$1>");e.forEach(function(a){a.parentNode.removeChild(a)});d.innerHTML=a;Array.prototype.slice.call(d.childNodes).forEach(function(a){f(b,a)})},enumerable:!0,configurable:!0};try{b.forEach(function(a){Object.defineProperty(window[a].prototype,"innerHTML",e)})}catch(h){}}else Object.prototype.__defineGetter__&&
b.forEach(function(a){window[a].prototype.__defineSetter__("innerHTML",e.set);window[a].prototype.__defineGetter__("innerHTML",e.get)})})(window);