Skip to content

Commit

Permalink
Fixed: restore load(string) and unload()
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
bfred-it committed Oct 19, 2016
1 parent ded1d07 commit c82a0e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/image-promise.browser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function trackLoading(image, src) {
export default function load(image) {
// if argument is an array, treat as
// load(['1.jpg', '2.jpg'])
if (image.length !== undefined) {
if (typeof image !== 'string' && image.length !== undefined) {
return Promise.all([].map.call(image, load));
}

Expand All @@ -34,14 +34,14 @@ export default function load(image) {
}

load.unload = function (image) {
if (!image.src) {
if (image.src) {
// an <img> was passed as argument, so nothing to unload
return;
}

// if argument is an array, treat as
// load(['1.jpg', '2.jpg'])
if (image.length !== undefined) {
if (typeof image !== 'string' && image.length !== undefined) {
[].map.call(image, load.unload);
} else if (load[image]) {
// GC, http://www.fngtps.com/2010/mobile-safari-image-resource-limit-workaround/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Load an image and return a promise in the browser, in 0.3KB",
"license": "MIT",
"repository": "bfred-it/image-promise",
"author": "Federico Brigante <bfred-it@users.noreply.github.com> (twitter.com/bfred_it)",
"author": "Federico Brigante <github@bfred.it> (bfred.it)",
"keywords": [
"browser",
"image",
Expand Down

0 comments on commit c82a0e3

Please sign in to comment.