forked from scottjehl/picturefill
-
Notifications
You must be signed in to change notification settings - Fork 1
/
svgfall.min.js
1 lines (1 loc) · 1.16 KB
/
svgfall.min.js
1
(function(a){"use strict";if(a.hasSvgSupport="no-svg",window.Modernizr!==void 0)a.hasSvgSupport=Modernizr.svg?"svg":"no-svg";else{var b={svg:"http://www.w3.org/2000/svg"};document.createElementNS&&document.createElementNS(b.svg,"svg").createSVGRect&&(a.hasSvgSupport="svg")}a.svgfall=function(){for(var b=a.document.getElementsByTagName("div"),c=0,d=b.length;d>c;c++)if(b[c].getAttribute("data-svgfall")!==null){for(var e=b[c].getElementsByTagName("div"),f=[],g=0,h=e.length;h>g;g++){var i=e[g].getAttribute("data-support");i||(i=e[g].getAttribute("data-src").substr(-4)==".svg"?"svg":"no-svg"),i==a.hasSvgSupport&&f.push(e[g])}var j=b[c].getElementsByTagName("img")[0];if(f.length){if(!j){j=a.document.createElement("img"),j.alt=b[c].getAttribute("data-alt");var k=b[c].getAttribute("data-width");k&&(j.width=k);var l=b[c].getAttribute("data-height");l&&(j.height=l),b[c].appendChild(j)}j.src=f.pop().getAttribute("data-src")}else j&&b[c].removeChild(j)}},a.addEventListener?(a.addEventListener("DOMContentLoaded",function(){a.svgfall(),a.removeEventListener("load",a.svgfall,!1)},!1),a.addEventListener("load",a.svgfall,!1)):a.attachEvent&&a.attachEvent("onload",a.svgfall)})(this)