Skip to content

Commit

Permalink
fix a image loading issue when src attrubute is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlanyuan committed Dec 17, 2018
1 parent 3f167ed commit ee469fb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/min/tiny-slider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sourcemaps/tiny-slider.js.map

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions dist/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1191,14 +1191,11 @@ var tns = function(options) {
forEach(imgs, function(img) {
var src = img.src;

if (src.indexOf('data:image') < 0) {
if (src && src.indexOf('data:image') < 0) {
addEvents(img, imgEvents);
img.src = '';
img.src = src;
addClass(img, 'loading');

// check image cache
if (img.complete) { img.naturalWidth !== 0 ? imgLoaded(img) : imgFailed(img); }
} else if (!lazyload) {
imgLoaded(img);
}
Expand Down Expand Up @@ -2242,7 +2239,6 @@ var tns = function(options) {
}

function imgFailed (img) {
console.log(img, img.src);
addClass(img, 'failed');
imgCompleted(img);
}
Expand Down
6 changes: 1 addition & 5 deletions src/tiny-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,11 @@ export var tns = function(options) {
forEach(imgs, function(img) {
var src = img.src;

if (src.indexOf('data:image') < 0) {
if (src && src.indexOf('data:image') < 0) {
addEvents(img, imgEvents);
img.src = '';
img.src = src;
addClass(img, 'loading');

// check image cache
if (img.complete) { img.naturalWidth !== 0 ? imgLoaded(img) : imgFailed(img); }
} else if (!lazyload) {
imgLoaded(img);
}
Expand Down Expand Up @@ -1810,7 +1807,6 @@ export var tns = function(options) {
}

function imgFailed (img) {
console.log(img, img.src);
addClass(img, 'failed');
imgCompleted(img);
}
Expand Down
6 changes: 1 addition & 5 deletions src/tiny-slider.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,11 @@ export var tns = function(options) {
forEach(imgs, function(img) {
var src = img.src;

if (src.indexOf('data:image') < 0) {
if (src && src.indexOf('data:image') < 0) {
addEvents(img, imgEvents);
img.src = '';
img.src = src;
addClass(img, 'loading');

// check image cache
if (img.complete) { img.naturalWidth !== 0 ? imgLoaded(img) : imgFailed(img); }
} else if (!lazyload) {
imgLoaded(img);
}
Expand Down Expand Up @@ -1810,7 +1807,6 @@ export var tns = function(options) {
}

function imgFailed (img) {
console.log(img, img.src);
addClass(img, 'failed');
imgCompleted(img);
}
Expand Down

0 comments on commit ee469fb

Please sign in to comment.