Skip to content

Commit

Permalink
Update version to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
DonRai committed Nov 5, 2019
1 parent 6f665f5 commit 42dddf9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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; }
Expand Down Expand Up @@ -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;
Expand All @@ -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 }));
}
}]);

Expand Down
8 changes: 5 additions & 3 deletions dist/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ 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
* @returns {boolean}
*/
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;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 42dddf9

Please sign in to comment.