diff --git a/dist/index.js b/dist/index.js index 012eaeb..fb48843 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); @@ -14,6 +16,8 @@ var _utils = require('./utils'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -46,7 +50,8 @@ var Image = function (_Component) { alt = _props.alt, title = _props.title, style = _props.style, - className = _props.className; + className = _props.className, + rest = _objectWithoutProperties(_props, ['src', 'webp', 'alt', 'title', 'style', 'className']); var webpSupport = (0, _utils.isWebpSupported)(); var image = src; @@ -55,7 +60,7 @@ var Image = function (_Component) { image = webp; } - return _react2.default.createElement('img', { src: image, alt: alt, title: title, style: style, className: className }); + return _react2.default.createElement('img', _extends({}, rest, { src: image, alt: alt, title: title, style: style, className: className })); } }]); diff --git a/dist/utils/index.js b/dist/utils/index.js index 5df72df..652c2cd 100644 --- a/dist/utils/index.js +++ b/dist/utils/index.js @@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; -var support = undefined; +var support = void 0; /** * Check browser webp support @@ -14,9 +14,11 @@ var support = undefined; */ var isWebpSupported = exports.isWebpSupported = function isWebpSupported() { - if (support !== undefined) return support; + if (typeof support !== "undefined") return support; var elem = (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object' ? document.createElement('canvas') : {}; - return elem.toDataURL('image/webp').indexOf('data:image/webp') === 0; + support = elem.toDataURL('image/webp').indexOf('data:image/webp') === 0; + + return support; }; \ No newline at end of file diff --git a/package.json b/package.json index 6be5ab7..7ac7581 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-image-webp", - "version": "0.5.2", + "version": "0.6.0", "description": "React component for check browser support format webp and insert if supported webp image.", "repository": { "type": "git",