This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscrollWidth.min.js
3 lines (2 loc) · 1.56 KB
/
scrollWidth.min.js
1
2
3
/*! scroll-width-polyfill 2018-04-05 */
var polyScrollWidth=function(u,l){var a=l.polyScrollWidth||{needsPoly:!1,usedPoly:!1,version:1.1},i=Object.getOwnPropertyDescriptor(Element.prototype,"scrollWidth").get;function o(e,t,n,l,a){var i,o,r;e=e.toLowerCase(),i="swMeasure-"+Date.now(),(o=u.createElement(e)).id=i;var d=o.style;null!==t&&(Object.keys(t.__proto__).forEach(function(e){d[e]=t[e]}),o.style=d);return n.forEach(function(e){o.style[e.name]=e.value}),"input"==e||"textarea"==e?o.value=l:o.textContent=l,u.getElementsByTagName("body")[0].appendChild(o),o=u.getElementById(i),r={scrollWidth:a?o.scrollWidth:0,clientWidth:parseInt(o.clientWidth,10)},o.outerHTML="",delete o,r}function e(){if("INPUT"!=this.nodeName&&"TEXTAREA"!=this.nodeName)return i.call(this);a.usedPoly=!0;var e="auto",t=l.getComputedStyle(this,null);"TEXTAREA"==this.nodeName&&(e=t.width);var n=o("div",t,[{name:"position",value:"absolute"},{name:"float",value:"left"},{name:"visibility",value:"hidden"},{name:"width",value:e}],this.value,!1);return Math.max(parseInt(t.width),n.clientWidth)}return function(){{if(!function(){var e=!1;0==o("input",null,[{name:"float",value:"left"},{name:"paddingLeft",value:"0px"},{name:"paddingRight",value:"0px"},{name:"position",value:"absolute"},{name:"width",value:"0px"},{name:"borderRightWidth",value:"0px"},{name:"borderLeftWidth",value:"0px"},{name:"visibility",value:"hidden"}],"Test",!0).scrollWidth&&(e=!0);return e}())return a.needsPoly=!1;a.needsPoly=!0}Object.defineProperty(Element.prototype,"scrollWidth",{configurable:!0,enumerable:!0,get:e})}(),a}(document,window);