polyfills.getComputedStyle.min.js Maven / Gradle / Ivy
The newest version!
!function(t){function e(t,o,r){var n,i=t.document&&t.currentStyle[o].match(/([\d\.]+)(%|cm|em|in|mm|pc|pt|)/)||[0,0,""],l=i[1],u=i[2];return r=r?/%|em/.test(u)&&t.parentElement?e(t.parentElement,"fontSize",null):16:r,n="fontSize"==o?r:/width/i.test(o)?t.clientWidth:t.clientHeight,"%"==u?l/100*n:"cm"==u?.3937*l*96:"em"==u?l*r:"in"==u?96*l:"mm"==u?.3937*l*96/10:"pc"==u?12*l*96/72:"pt"==u?96*l/72:l}function o(t,e){var o="border"==e?"Width":"",r=e+"Top"+o,n=e+"Right"+o,i=e+"Bottom"+o,l=e+"Left"+o;t[e]=(t[r]==t[n]&&t[r]==t[i]&&t[r]==t[l]?[t[r]]:t[r]==t[i]&&t[l]==t[n]?[t[r],t[n]]:t[l]==t[n]?[t[r],t[n],t[i]]:[t[r],t[n],t[i],t[l]]).join(" ")}function r(t){var r,n=this,i=t.currentStyle,l=e(t,"fontSize"),u=function(t){return"-"+t.toLowerCase()};for(r in i)if(Array.prototype.push.call(n,"styleFloat"==r?"float":r.replace(/[A-Z]/,u)),"width"==r)n[r]=t.offsetWidth+"px";else if("height"==r)n[r]=t.offsetHeight+"px";else if("styleFloat"==r)n["float"]=i[r];else if(/margin.|padding.|border.+W/.test(r)&&"auto"!=n[r])n[r]=Math.round(e(t,r,l))+"px";else if(/^outline/.test(r))try{n[r]=i[r]}catch(c){n.outlineColor=i.color,n.outlineStyle=n.outlineStyle||"none",n.outlineWidth=n.outlineWidth||"0px",n.outline=[n.outlineColor,n.outlineWidth,n.outlineStyle].join(" ")}else n[r]=i[r];o(n,"margin"),o(n,"padding"),o(n,"border"),n.fontSize=Math.round(l)+"px"}r.prototype={constructor:r,getPropertyPriority:function(){throw new Error("NotSupportedError: DOM Exception 9")},getPropertyValue:function(t){return this[t.replace(/-\w/g,function(t){return t[1].toUpperCase()})]},item:function(t){return this[t]},removeProperty:function(){throw new Error("NoModificationAllowedError: DOM Exception 7")},setProperty:function(){throw new Error("NoModificationAllowedError: DOM Exception 7")},getPropertyCSSValue:function(){throw new Error("NotSupportedError: DOM Exception 9")}},t.getComputedStyle=function(t){return new r(t)}}(this);