react-image-fallback
Advanced tools
Comparing version 7.0.0 to 7.0.1
@@ -37,3 +37,3 @@ "use strict"; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ReactImageFallback).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, (ReactImageFallback.__proto__ || Object.getPrototypeOf(ReactImageFallback)).call(this, props)); | ||
@@ -74,7 +74,8 @@ _this.state = { | ||
var image = _ref.image; | ||
var fallbacks = _ref.fallbacks; | ||
var image = _ref.image, | ||
fallbacks = _ref.fallbacks; | ||
var fallbacksArray = Array.isArray(fallbacks) ? fallbacks : [fallbacks]; | ||
var imagesArray = image ? [image].concat(fallbacksArray) : fallbacksArray; | ||
var imagesArray = [image].concat(fallbacks).filter(function (fallback) { | ||
return !!fallback; | ||
}); | ||
this.displayImage.onerror = function () { | ||
@@ -87,3 +88,3 @@ if (imagesArray.length > 2 && typeof imagesArray[1] === "string") { | ||
_this2.setState({ | ||
imageSource: imagesArray[1] | ||
imageSource: imagesArray[1] || null | ||
}, function () { | ||
@@ -104,3 +105,13 @@ if (_this2.props.onError) { | ||
}; | ||
this.displayImage.src = imagesArray[0]; | ||
if (typeof imagesArray[0] === "string") { | ||
this.displayImage.src = imagesArray[0]; | ||
} else { | ||
this.setState({ | ||
imageSource: imagesArray[0] | ||
}, function () { | ||
if (_this2.props.onLoad) { | ||
_this2.props.onLoad(imagesArray[0]); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -107,0 +118,0 @@ }, { |
{ | ||
"name": "react-image-fallback", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "if your image doesn't exist, fallback onto another provided image.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13753
266