forked from eqcss/eqcss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEQCSS-polyfills.min.js
10 lines (10 loc) · 3.29 KB
/
EQCSS-polyfills.min.js
1
2
3
4
5
6
7
8
9
10
// EQCSS / Tommy Hodgins, Maxime Euzière / MIT licence
// version 1.2.1
(function(b,f){function h(k){var d=f[k];f[k]=function(e){return a(d(e))}}function g(a,d,e){return(e=this).attachEvent("on"+a,function(a){a=a||b.event;a.preventDefault=a.preventDefault||function(){a.returnValue=!1};a.stopPropagation=a.stopPropagation||function(){a.cancelBubble=!0};try{d.call(e,a)}catch(k){}})}function a(a){var d;if(d=a.length)for(;d--;)a[d].addEventListener=g;else a.addEventListener=g;return a}b.addEventListener||(a([f,b]),"Element"in b?b.Element.prototype.addEventListener=g:(f.attachEvent("onreadystatechange",
function(){a(f.all)}),h("getElementsByTagName"),h("getElementById"),h("createElement"),a(f.all)))})(window,document);
(function(b){function f(a,b,d){var e=a.document&&a.currentStyle[b].match(/([\d\.]+)(%|cm|em|in|mm|pc|pt|)/)||[0,0,""],c=e[1],e=e[2];d=d?/%|em/.test(e)&&a.parentElement?f(a.parentElement,"fontSize",null):16:d;a="fontSize"==b?d:/width/i.test(b)?a.clientWidth:a.clientHeight;return"%"==e?c/100*a:"cm"==e?37.7952*c:"em"==e?c*d:"in"==e?96*c:"mm"==e?37.7952*c/10:"pc"==e?1152*c/72:"pt"==e?96*c/72:c}function h(a,b){var d="border"==b?"Width":"",e=b+"Top"+d,c=b+"Right"+d,f=b+"Bottom"+d,d=b+"Left"+d;a[b]=(a[e]==
a[c]&&a[e]==a[f]&&a[e]==a[d]?[a[e]]:a[e]==a[f]&&a[d]==a[c]?[a[e],a[c]]:a[d]==a[c]?[a[e],a[c],a[f]]:[a[e],a[c],a[f],a[d]]).join(" ")}function g(a){function b(a){return"-"+a.toLowerCase()}var d=a.currentStyle,e=f(a,"fontSize"),c;for(c in d)if(Array.prototype.push.call(this,"styleFloat"==c?"float":c.replace(/[A-Z]/,b)),"width"==c)this[c]=a.offsetWidth+"px";else if("height"==c)this[c]=a.offsetHeight+"px";else if("styleFloat"!=c)if(/margin.|padding.|border.+W/.test(c)&&"auto"!=this[c])this[c]=Math.round(f(a,
c,e))+"px";else if(/^outline/.test(c))try{this[c]=d[c]}catch(g){this.outlineColor=d.color,this.outlineStyle=this.outlineStyle||"none",this.outlineWidth=this.outlineWidth||"0px",this.outline=[this.outlineColor,this.outlineWidth,this.outlineStyle].join(" ")}else this[c]=d[c];h(this,"margin");h(this,"padding");h(this,"border");this.fontSize=Math.round(e)+"px"}b.getComputedStyle||(g.prototype={constructor:g,getPropertyPriority:function(){throw Error("NotSupportedError: DOM Exception 9");},getPropertyValue:function(a){return this[a.replace(/-\w/g,
function(a){return a[1].toUpperCase()})]},item:function(a){return this[a]},removeProperty:function(){throw Error("NoModificationAllowedError: DOM Exception 7");},setProperty:function(){throw Error("NoModificationAllowedError: DOM Exception 7");},getPropertyCSSValue:function(){throw Error("NotSupportedError: DOM Exception 9");}},b.getComputedStyle=function(a){return new g(a)})})(window);
(function(b){b.querySelectorAll||(b.querySelectorAll=function(f){return"#"==f.charAt(0)?[b.getElementById(f.substr(1))]:"."==f.charAt(0)?b.getElementsByClassName(f.substr(1)):b.getElementsByTagName(f)},b.querySelector=function(b){return querySelectorAll(b)[0]})})(document);
(function(){if(Object.defineProperty&&Object.getOwnPropertyDescriptor&&Object.getOwnPropertyDescriptor(Element.prototype,"textContent")&&!Object.getOwnPropertyDescriptor(Element.prototype,"textContent").get){var b=Object.getOwnPropertyDescriptor(Element.prototype,"innerText");Object.defineProperty(Element.prototype,"textContent",{get:function(){return b.get.call(this)},set:function(f){return b.set.call(this,f)}})}})();