Skip to content

Commit

Permalink
added image file extension tests, bumped version number
Browse files Browse the repository at this point in the history
  • Loading branch information
amorey committed Dec 1, 2019
1 parent f4f9eb9 commit 02ccff1
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 12 deletions.
Binary file added .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# LoadJS Changelog

## 4.2.0 - December 1, 2019

* Added support for .webp image extensions

## 4.0.1 - September 25, 2019

* Removed unnecessary console.log() statement
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ loadjs.ready('foobar', {
```

The latest version of LoadJS can be found in the `dist/` directory in this repository:
* [https://cdn.rawgit.com/muicss/loadjs/4.0.1/dist/loadjs.js](https://cdn.rawgit.com/muicss/loadjs/4.0.1/dist/loadjs.js) (for development)
* [https://cdn.rawgit.com/muicss/loadjs/4.0.1/dist/loadjs.min.js](https://cdn.rawgit.com/muicss/loadjs/4.0.1/dist/loadjs.min.js) (for production)
* [https://cdn.rawgit.com/muicss/loadjs/4.2.0/dist/loadjs.js](https://cdn.rawgit.com/muicss/loadjs/4.2.0/dist/loadjs.js) (for development)
* [https://cdn.rawgit.com/muicss/loadjs/4.2.0/dist/loadjs.min.js](https://cdn.rawgit.com/muicss/loadjs/4.2.0/dist/loadjs.min.js) (for production)

You can also use it as a CJS or AMD module:

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loadjs",
"version": "4.0.1",
"version": "4.2.0",
"license": "MIT",
"authors": [
"Andres Morey <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion dist/loadjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function loadFile(path, callbackFn, args, numTries) {
e.rel = 'preload';
e.as = 'style';
}
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(pathname)) {
} else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
// image
e = doc.createElement('img');
e.src = pathStripped;
Expand Down
2 changes: 1 addition & 1 deletion dist/loadjs.min.js

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

2 changes: 1 addition & 1 deletion dist/loadjs.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function loadFile(path, callbackFn, args, numTries) {
e.rel = 'preload';
e.as = 'style';
}
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(pathname)) {
} else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
// image
e = doc.createElement('img');
e.src = pathStripped;
Expand Down
2 changes: 1 addition & 1 deletion examples/assets/loadjs/loadjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function loadFile(path, callbackFn, args, numTries) {
e.rel = 'preload';
e.as = 'style';
}
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(pathname)) {
} else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
// image
e = doc.createElement('img');
e.src = pathStripped;
Expand Down
2 changes: 1 addition & 1 deletion examples/assets/loadjs/loadjs.min.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loadjs",
"version": "4.0.1",
"version": "4.2.0",
"license": "MIT",
"description": "Tiny async loader for modern browsers",
"keywords": [
Expand Down
Binary file added test/.DS_Store
Binary file not shown.
Binary file added test/assets/flash.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/assets/flash.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion test/assets/loadjs/loadjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function loadFile(path, callbackFn, args, numTries) {
e.rel = 'preload';
e.as = 'style';
}
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(pathname)) {
} else if (/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(pathname)) {
// image
e = doc.createElement('img');
e.src = pathStripped;
Expand Down
2 changes: 1 addition & 1 deletion test/assets/loadjs/loadjs.min.js

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

16 changes: 16 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,22 @@ describe('LoadJS tests', function() {
});


it('detects png|gif|jpg|svg|webp extensions', function(done) {
let files = [
'assets/flash.png',
'assets/flash.gif',
'assets/flash.jpg',
'assets/flash.svg',
'assets/flash.webp'
];

loadjs(files, function() {
files.forEach(file => {assertLoaded(file);});
done();
});
});


it('supports urls with query arguments', function(done) {
var src = 'assets/flash.png?' + Math.random();

Expand Down

0 comments on commit 02ccff1

Please sign in to comment.