-
Notifications
You must be signed in to change notification settings - Fork 2
/
es5.js
1 lines (1 loc) · 1004 Bytes
/
es5.js
1
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}var WebP=function(){function e(){_classCallCheck(this,e),this.isSupportWebp=!1;try{this.isSupportWebp=0==document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch(e){console.warn("This browser not support Webp!")}}return _createClass(e,[{key:"install",value:function(e,t){var n=this;e.prototype.$webp=this.isSupportWebp,e.directive("webp",function(e,t,r){if("img"===r.tag&&n.isSupportWebp){try{e.src=t.value.toString().replace(/(\.jpg|\.png)/g,".webp")}catch(e){console.error(e)}document.querySelector("html").classList.add("webp")}})}}]),e}();module.exports=new WebP;