Comparing version 3.5.3 to 3.5.4
{ | ||
"name": "loadjs", | ||
"version": "3.5.3", | ||
"version": "3.5.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "authors": [ |
# LoadJS Changelog | ||
## 3.5.4 - March 28, 2018 | ||
* Added support for loading images | ||
## 3.5.3 - March 21, 2018 | ||
@@ -4,0 +8,0 @@ |
@@ -106,2 +106,3 @@ loadjs = (function () { | ||
beforeCallbackFn = args.before || devnull, | ||
pathStripped = path.replace(/^(css|img)!/, ''), | ||
isCss, | ||
@@ -118,3 +119,7 @@ e; | ||
e.rel = 'stylesheet'; | ||
e.href = path.replace(/^css!/, ''); // remove "css!" prefix | ||
e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix | ||
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { | ||
// image | ||
e = doc.createElement('img'); | ||
e.src = pathStripped; | ||
} else { | ||
@@ -121,0 +126,0 @@ // javascript |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){var a=function(){},i={},u={},f={};function o(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function s(n,e){n.call&&(n={success:n}),e.length?(n.error||a)(e):(n.success||a)(n)}function h(t,r,c,i){var o,s,n=document,e=c.async,u=(c.numRetries||0)+1,f=c.before||a;i=i||0,/(^css!|\.css$)/.test(t)?(o=!0,(s=n.createElement("link")).rel="stylesheet",s.href=t.replace(/^css!/,"")):((s=n.createElement("script")).src=t,s.async=void 0===e||e),!(s.onload=s.onerror=s.onbeforeload=function(n){var e=n.type[0];if(o&&"hideFocus"in s)try{s.sheet.cssText.length||(e="e")}catch(n){e="e"}if("e"==e&&(i+=1)<u)return h(t,r,c,i);r(t,e,n.defaultPrevented)})!==f(t,s)&&n.head.appendChild(s)}function t(n,e,t){var r,c;if(e&&e.trim&&(r=e),c=(r?t:e)||{},r){if(r in i)throw"LoadJS";i[r]=!0}!function(n,r,e){var t,c,i=(n=n.push?n:[n]).length,o=i,s=[];for(t=function(n,e,t){if("e"==e&&s.push(n),"b"==e){if(!t)return;s.push(n)}--i||r(s)},c=0;c<o;c++)h(n[c],t,e)}(n,function(n){s(c,n),o(r,n)},c)}return t.ready=function(n,e){return function(n,t){n=n.push?n:[n];var e,r,c,i=[],o=n.length,s=o;for(e=function(n,e){e.length&&i.push(n),--s||t(i)};o--;)r=n[o],(c=u[r])?e(r,c):(f[r]=f[r]||[]).push(e)}(n,function(n){s(e,n)}),t},t.done=function(n){o(n,[])},t.reset=function(){i={},u={},f={}},t.isDefined=function(n){return n in i},t}(); | ||
loadjs=function(){var l=function(){},c={},f={},u={};function s(e,n){if(e){var t=u[e];if(f[e]=n,t)for(;t.length;)t[0](e,n),t.splice(0,1)}}function o(e,n){e.call&&(e={success:e}),n.length?(e.error||l)(n):(e.success||l)(e)}function h(t,r,i,c){var s,o,e=document,n=i.async,f=(i.numRetries||0)+1,u=i.before||l,a=t.replace(/^(css|img)!/,"");c=c||0,/(^css!|\.css$)/.test(t)?(s=!0,(o=e.createElement("link")).rel="stylesheet",o.href=a):/(^img!|\.(png|gif|jpg|svg)$)/.test(t)?(o=e.createElement("img")).src=a:((o=e.createElement("script")).src=t,o.async=void 0===n||n),!(o.onload=o.onerror=o.onbeforeload=function(e){var n=e.type[0];if(s&&"hideFocus"in o)try{o.sheet.cssText.length||(n="e")}catch(e){n="e"}if("e"==n&&(c+=1)<f)return h(t,r,i,c);r(t,n,e.defaultPrevented)})!==u(t,o)&&e.head.appendChild(o)}function t(e,n,t){var r,i;if(n&&n.trim&&(r=n),i=(r?t:n)||{},r){if(r in c)throw"LoadJS";c[r]=!0}!function(e,r,n){var t,i,c=(e=e.push?e:[e]).length,s=c,o=[];for(t=function(e,n,t){if("e"==n&&o.push(e),"b"==n){if(!t)return;o.push(e)}--c||r(o)},i=0;i<s;i++)h(e[i],t,n)}(e,function(e){o(i,e),s(r,e)},i)}return t.ready=function(e,n){return function(e,t){e=e.push?e:[e];var n,r,i,c=[],s=e.length,o=s;for(n=function(e,n){n.length&&c.push(e),--o||t(c)};s--;)r=e[s],(i=f[r])?n(r,i):(u[r]=u[r]||[]).push(n)}(e,function(e){o(n,e)}),t},t.done=function(e){s(e,[])},t.reset=function(){c={},f={},u={}},t.isDefined=function(e){return e in c},t}(); |
@@ -114,2 +114,3 @@ (function(root, factory) { | ||
beforeCallbackFn = args.before || devnull, | ||
pathStripped = path.replace(/^(css|img)!/, ''), | ||
isCss, | ||
@@ -126,3 +127,7 @@ e; | ||
e.rel = 'stylesheet'; | ||
e.href = path.replace(/^css!/, ''); // remove "css!" prefix | ||
e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix | ||
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { | ||
// image | ||
e = doc.createElement('img'); | ||
e.src = pathStripped; | ||
} else { | ||
@@ -129,0 +134,0 @@ // javascript |
@@ -106,2 +106,3 @@ loadjs = (function () { | ||
beforeCallbackFn = args.before || devnull, | ||
pathStripped = path.replace(/^(css|img)!/, ''), | ||
isCss, | ||
@@ -118,3 +119,7 @@ e; | ||
e.rel = 'stylesheet'; | ||
e.href = path.replace(/^css!/, ''); // remove "css!" prefix | ||
e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix | ||
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { | ||
// image | ||
e = doc.createElement('img'); | ||
e.src = pathStripped; | ||
} else { | ||
@@ -121,0 +126,0 @@ // javascript |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){var a=function(){},i={},u={},f={};function o(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function s(n,e){n.call&&(n={success:n}),e.length?(n.error||a)(e):(n.success||a)(n)}function h(t,r,c,i){var o,s,n=document,e=c.async,u=(c.numRetries||0)+1,f=c.before||a;i=i||0,/(^css!|\.css$)/.test(t)?(o=!0,(s=n.createElement("link")).rel="stylesheet",s.href=t.replace(/^css!/,"")):((s=n.createElement("script")).src=t,s.async=void 0===e||e),!(s.onload=s.onerror=s.onbeforeload=function(n){var e=n.type[0];if(o&&"hideFocus"in s)try{s.sheet.cssText.length||(e="e")}catch(n){e="e"}if("e"==e&&(i+=1)<u)return h(t,r,c,i);r(t,e,n.defaultPrevented)})!==f(t,s)&&n.head.appendChild(s)}function t(n,e,t){var r,c;if(e&&e.trim&&(r=e),c=(r?t:e)||{},r){if(r in i)throw"LoadJS";i[r]=!0}!function(n,r,e){var t,c,i=(n=n.push?n:[n]).length,o=i,s=[];for(t=function(n,e,t){if("e"==e&&s.push(n),"b"==e){if(!t)return;s.push(n)}--i||r(s)},c=0;c<o;c++)h(n[c],t,e)}(n,function(n){s(c,n),o(r,n)},c)}return t.ready=function(n,e){return function(n,t){n=n.push?n:[n];var e,r,c,i=[],o=n.length,s=o;for(e=function(n,e){e.length&&i.push(n),--s||t(i)};o--;)r=n[o],(c=u[r])?e(r,c):(f[r]=f[r]||[]).push(e)}(n,function(n){s(e,n)}),t},t.done=function(n){o(n,[])},t.reset=function(){i={},u={},f={}},t.isDefined=function(n){return n in i},t}(); | ||
loadjs=function(){var l=function(){},c={},f={},u={};function s(e,n){if(e){var t=u[e];if(f[e]=n,t)for(;t.length;)t[0](e,n),t.splice(0,1)}}function o(e,n){e.call&&(e={success:e}),n.length?(e.error||l)(n):(e.success||l)(e)}function h(t,r,i,c){var s,o,e=document,n=i.async,f=(i.numRetries||0)+1,u=i.before||l,a=t.replace(/^(css|img)!/,"");c=c||0,/(^css!|\.css$)/.test(t)?(s=!0,(o=e.createElement("link")).rel="stylesheet",o.href=a):/(^img!|\.(png|gif|jpg|svg)$)/.test(t)?(o=e.createElement("img")).src=a:((o=e.createElement("script")).src=t,o.async=void 0===n||n),!(o.onload=o.onerror=o.onbeforeload=function(e){var n=e.type[0];if(s&&"hideFocus"in o)try{o.sheet.cssText.length||(n="e")}catch(e){n="e"}if("e"==n&&(c+=1)<f)return h(t,r,i,c);r(t,n,e.defaultPrevented)})!==u(t,o)&&e.head.appendChild(o)}function t(e,n,t){var r,i;if(n&&n.trim&&(r=n),i=(r?t:n)||{},r){if(r in c)throw"LoadJS";c[r]=!0}!function(e,r,n){var t,i,c=(e=e.push?e:[e]).length,s=c,o=[];for(t=function(e,n,t){if("e"==n&&o.push(e),"b"==n){if(!t)return;o.push(e)}--c||r(o)},i=0;i<s;i++)h(e[i],t,n)}(e,function(e){o(i,e),s(r,e)},i)}return t.ready=function(e,n){return function(e,t){e=e.push?e:[e];var n,r,i,c=[],s=e.length,o=s;for(n=function(e,n){n.length&&c.push(e),--o||t(c)};s--;)r=e[s],(i=f[r])?n(r,i):(u[r]=u[r]||[]).push(n)}(e,function(e){o(n,e)}),t},t.done=function(e){s(e,[])},t.reset=function(){c={},f={},u={}},t.isDefined=function(e){return e in c},t}(); |
{ | ||
"name": "loadjs", | ||
"version": "3.5.3", | ||
"version": "3.5.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Tiny async loader for modern browsers", |
@@ -5,3 +5,3 @@ # LoadJS | ||
LoadJS is a tiny async loader for modern browsers (747 bytes). | ||
LoadJS is a tiny async loader for modern browsers (789 bytes). | ||
@@ -14,5 +14,5 @@ [![Dependency Status](https://david-dm.org/muicss/loadjs.svg)](https://david-dm.org/muicss/loadjs) | ||
LoadJS is a tiny async loading library for modern browsers (IE9+). It has a simple yet powerful dependency management system that lets you fetch JavaScript and CSS files in parallel and execute code after the dependencies have been met. The recommended way to use LoadJS is to include the minified source code of [loadjs.js](https://raw.githubusercontent.com/muicss/loadjs/master/dist/loadjs.min.js) in your <html> (possibly in the <head> tag) and then use the `loadjs` global to manage JavaScript dependencies after pageload. | ||
LoadJS is a tiny async loading library for modern browsers (IE9+). It has a simple yet powerful dependency management system that lets you fetch JavaScript, CSS and image files in parallel and execute code after the dependencies have been met. The recommended way to use LoadJS is to include the minified source code of [loadjs.js](https://raw.githubusercontent.com/muicss/loadjs/master/dist/loadjs.min.js) in your <html> (possibly in the <head> tag) and then use the `loadjs` global to manage JavaScript dependencies after pageload. | ||
LoadJS is based on the excellent [$script](https://github.com/ded/script.js) library by [Dustin Diaz](https://github.com/ded). We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/error callbacks and to optimize the library for modern browsers. LoadJS is 747 bytes (minified + gzipped). | ||
LoadJS is based on the excellent [$script](https://github.com/ded/script.js) library by [Dustin Diaz](https://github.com/ded). We kept the behavior of the library the same but we re-wrote the code from scratch to add support for success/error callbacks and to optimize the library for modern browsers. LoadJS is 789 bytes (minified + gzipped). | ||
@@ -22,17 +22,22 @@ Here's an example of what you can do with LoadJS: | ||
```javascript | ||
// define a dependency bundle | ||
// define a dependency bundle and execute code when it loads | ||
loadjs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar'); | ||
// execute code when the bundle loads | ||
loadjs.ready('foobar', function() { | ||
/* foo.js & bar.js loaded */ | ||
}); | ||
``` | ||
// OR use more advanced syntax for more options | ||
You can also use more advanced syntax for more options: | ||
```javascript | ||
// define a dependency bundle with advanced options | ||
loadjs(['/path/to/foo.js', '/path/to/bar.js'], 'foobar', { | ||
before: function(path, scriptEl) { /* execute code before fetch */ }, | ||
async: true, // load files synchronously or asynchronously (default: true) | ||
numRetries: 3 // see caveats about using numRetries with async:false (default: 0) | ||
}); | ||
loadjs.ready('foobar', { | ||
success: function() { /* foo.js & bar.js loaded */ }, | ||
error: function(depsNotFound) { /* foobar bundle load failed */ }, | ||
before: function(path, scriptEl) { /* execute code before fetch */ }, | ||
async: true, // load files synchronously or asynchronously (default: true) | ||
numRetries: 3 // number of times to retry fetch (default: 0) | ||
}); | ||
@@ -42,4 +47,4 @@ ``` | ||
The latest version of LoadJS can be found in the `dist/` directory in this repository: | ||
* [loadjs.js](https://cdn.rawgit.com/muicss/loadjs/3.5.3/dist/loadjs.js) | ||
* [loadjs.min.js](https://cdn.rawgit.com/muicss/loadjs/3.5.3/dist/loadjs.min.js) | ||
* [loadjs.js](https://cdn.rawgit.com/muicss/loadjs/3.5.4/dist/loadjs.js) | ||
* [loadjs.min.js](https://cdn.rawgit.com/muicss/loadjs/3.5.4/dist/loadjs.min.js) | ||
@@ -57,15 +62,5 @@ You can also use it as a CJS or AMD module: | ||
// execute code when the bundle loads | ||
loadjs.ready('foobar', function() { | ||
/* foo.js & bar.js loaded */ | ||
}); | ||
// OR use more advanced syntax for more options | ||
loadjs.ready('foobar', { | ||
success: function() { /* foo.js & bar.js loaded */ }, | ||
error: function(depsNotFound) { /* foobar bundle load failed */ }, | ||
before: function(path, scriptEl) { /* execute code before fetch */ }, | ||
async: true, // load files synchronously or asynchronously (default: true) | ||
numRetries: 3 // number of times to retry fetch (default: 0) | ||
}); | ||
``` | ||
@@ -108,7 +103,7 @@ | ||
1. Fetch JavaScript and CSS files | ||
1. Fetch JavaScript, CSS and image files | ||
```javascript | ||
loadjs(['/path/to/foo.css', '/path/to/bar.js'], function() { | ||
/* foo.css and bar.js loaded */ | ||
loadjs(['/path/to/foo.css', '/path/to/bar.png', 'path/to/thunk.js'], function() { | ||
/* foo.css, bar.png and thunk.js loaded */ | ||
}); | ||
@@ -125,2 +120,10 @@ ``` | ||
1. Force treat file as image | ||
```javascript | ||
loadjs(['img!/path/to/image.custom'], function() { | ||
/* image.custom loaded */ | ||
}); | ||
``` | ||
1. Add a bundle id | ||
@@ -206,2 +209,4 @@ | ||
}); | ||
// NOTE: Using `numRetries` with `async: false` can cause files to load out-of-sync on retries | ||
``` | ||
@@ -279,2 +284,22 @@ | ||
1. Implement a require-like dependency manager | ||
```javascript | ||
var bundles = { | ||
'bundleA': ['/file1.js', '/file2.js'], | ||
'bundleB': ['/file3.js', '/file4.js'] | ||
}; | ||
function require(bundleIds, callbackFn) { | ||
bundleIds.forEach(function(bundleId) { | ||
if (!loadjs.isDefined(bundleId)) loadjs(bundles[bundleId], bundleId); | ||
}); | ||
loadjs.ready(bundleIds, callbackFn); | ||
} | ||
require(['bundleA'], function() { /* bundleA loaded */ }); | ||
require(['bundleB'], function() { /* bundleB loaded */ }); | ||
require(['bundleA', 'bundleB'], function() { /* bundleA and bundleB loaded */ }); | ||
``` | ||
## Directory structure | ||
@@ -281,0 +306,0 @@ |
@@ -105,2 +105,3 @@ /** | ||
beforeCallbackFn = args.before || devnull, | ||
pathStripped = path.replace(/^(css|img)!/, ''), | ||
isCss, | ||
@@ -117,3 +118,7 @@ e; | ||
e.rel = 'stylesheet'; | ||
e.href = path.replace(/^css!/, ''); // remove "css!" prefix | ||
e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix | ||
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { | ||
// image | ||
e = doc.createElement('img'); | ||
e.src = pathStripped; | ||
} else { | ||
@@ -120,0 +125,0 @@ // javascript |
@@ -106,2 +106,3 @@ loadjs = (function () { | ||
beforeCallbackFn = args.before || devnull, | ||
pathStripped = path.replace(/^(css|img)!/, ''), | ||
isCss, | ||
@@ -118,3 +119,7 @@ e; | ||
e.rel = 'stylesheet'; | ||
e.href = path.replace(/^css!/, ''); // remove "css!" prefix | ||
e.href = pathStripped; //.replace(/^css!/, ''); // remove "css!" prefix | ||
} else if (/(^img!|\.(png|gif|jpg|svg)$)/.test(path)) { | ||
// image | ||
e = doc.createElement('img'); | ||
e.src = pathStripped; | ||
} else { | ||
@@ -121,0 +126,0 @@ // javascript |
@@ -1,1 +0,1 @@ | ||
loadjs=function(){var a=function(){},i={},u={},f={};function o(n,e){if(n){var t=f[n];if(u[n]=e,t)for(;t.length;)t[0](n,e),t.splice(0,1)}}function s(n,e){n.call&&(n={success:n}),e.length?(n.error||a)(e):(n.success||a)(n)}function h(t,r,c,i){var o,s,n=document,e=c.async,u=(c.numRetries||0)+1,f=c.before||a;i=i||0,/(^css!|\.css$)/.test(t)?(o=!0,(s=n.createElement("link")).rel="stylesheet",s.href=t.replace(/^css!/,"")):((s=n.createElement("script")).src=t,s.async=void 0===e||e),!(s.onload=s.onerror=s.onbeforeload=function(n){var e=n.type[0];if(o&&"hideFocus"in s)try{s.sheet.cssText.length||(e="e")}catch(n){e="e"}if("e"==e&&(i+=1)<u)return h(t,r,c,i);r(t,e,n.defaultPrevented)})!==f(t,s)&&n.head.appendChild(s)}function t(n,e,t){var r,c;if(e&&e.trim&&(r=e),c=(r?t:e)||{},r){if(r in i)throw"LoadJS";i[r]=!0}!function(n,r,e){var t,c,i=(n=n.push?n:[n]).length,o=i,s=[];for(t=function(n,e,t){if("e"==e&&s.push(n),"b"==e){if(!t)return;s.push(n)}--i||r(s)},c=0;c<o;c++)h(n[c],t,e)}(n,function(n){s(c,n),o(r,n)},c)}return t.ready=function(n,e){return function(n,t){n=n.push?n:[n];var e,r,c,i=[],o=n.length,s=o;for(e=function(n,e){e.length&&i.push(n),--s||t(i)};o--;)r=n[o],(c=u[r])?e(r,c):(f[r]=f[r]||[]).push(e)}(n,function(n){s(e,n)}),t},t.done=function(n){o(n,[])},t.reset=function(){i={},u={},f={}},t.isDefined=function(n){return n in i},t}(); | ||
loadjs=function(){var l=function(){},c={},f={},u={};function s(e,n){if(e){var t=u[e];if(f[e]=n,t)for(;t.length;)t[0](e,n),t.splice(0,1)}}function o(e,n){e.call&&(e={success:e}),n.length?(e.error||l)(n):(e.success||l)(e)}function h(t,r,i,c){var s,o,e=document,n=i.async,f=(i.numRetries||0)+1,u=i.before||l,a=t.replace(/^(css|img)!/,"");c=c||0,/(^css!|\.css$)/.test(t)?(s=!0,(o=e.createElement("link")).rel="stylesheet",o.href=a):/(^img!|\.(png|gif|jpg|svg)$)/.test(t)?(o=e.createElement("img")).src=a:((o=e.createElement("script")).src=t,o.async=void 0===n||n),!(o.onload=o.onerror=o.onbeforeload=function(e){var n=e.type[0];if(s&&"hideFocus"in o)try{o.sheet.cssText.length||(n="e")}catch(e){n="e"}if("e"==n&&(c+=1)<f)return h(t,r,i,c);r(t,n,e.defaultPrevented)})!==u(t,o)&&e.head.appendChild(o)}function t(e,n,t){var r,i;if(n&&n.trim&&(r=n),i=(r?t:n)||{},r){if(r in c)throw"LoadJS";c[r]=!0}!function(e,r,n){var t,i,c=(e=e.push?e:[e]).length,s=c,o=[];for(t=function(e,n,t){if("e"==n&&o.push(e),"b"==n){if(!t)return;o.push(e)}--c||r(o)},i=0;i<s;i++)h(e[i],t,n)}(e,function(e){o(i,e),s(r,e)},i)}return t.ready=function(e,n){return function(e,t){e=e.push?e:[e];var n,r,i,c=[],s=e.length,o=s;for(n=function(e,n){n.length&&c.push(e),--o||t(c)};s--;)r=e[s],(i=f[r])?n(r,i):(u[r]=u[r]||[]).push(n)}(e,function(e){o(n,e)}),t},t.done=function(e){s(e,[])},t.reset=function(){c={},f={},u={}},t.isDefined=function(e){return e in c},t}(); |
@@ -353,2 +353,120 @@ /** | ||
// ========================================================================== | ||
// Image file loading tests | ||
// ========================================================================== | ||
describe('Image file loading tests', function() { | ||
function assertLoaded(src) { | ||
var i = new Image(); | ||
i.src = src; | ||
assert.equal(i.naturalWidth > 0, true); | ||
} | ||
function assertNotLoaded(src) { | ||
var i = new Image(); | ||
i.src = src; | ||
assert.equal(i.naturalWidth, 0) | ||
} | ||
it('should load one file', function(done) { | ||
loadjs(['assets/flash.png'], { | ||
success: function() { | ||
assertLoaded('assets/flash.png'); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should load multiple files', function(done) { | ||
loadjs(['assets/flash.png', 'assets/flash.jpg'], { | ||
success: function() { | ||
assertLoaded('assets/flash.png'); | ||
assertLoaded('assets/flash.jpg'); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should support forced "img!" files', function(done) { | ||
var src = 'assets/flash.png?' + Math.random(); | ||
loadjs(['img!' + src], { | ||
success: function() { | ||
assertLoaded(src); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should call error callback on one invalid path', function(done) { | ||
var src1 = 'assets/flash.png?' + Math.random(), | ||
src2 = 'assets/flash-doesntexist.png?' + Math.random(); | ||
loadjs(['img!' + src1, 'img!' + src2], { | ||
success: function() { | ||
throw new Error('Executed success callback'); | ||
}, | ||
error: function(pathsNotFound) { | ||
assert.equal(pathsNotFound.length, 1); | ||
assertLoaded(src1); | ||
assertNotLoaded(src2); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should support mix of img and js', function(done) { | ||
var src = 'assets/flash.png?' + Math.random(); | ||
loadjs(['img!' + src, 'assets/file1.js'], { | ||
success: function() { | ||
assert.equal(pathsLoaded['file1.js'], true); | ||
assertLoaded(src); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should load external img files', function(done) { | ||
this.timeout(0); | ||
var src = 'https://www.muicss.com/static/images/mui-logo.png?'; | ||
src += Math.random(); | ||
loadjs(['img!' + src], { | ||
success: function() { | ||
assertLoaded(src); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('should call error on missing external file', function(done) { | ||
this.timeout(0); | ||
var src = 'https://www.muicss.com/static/images/'; | ||
src += 'mui-logo-doesntexist.png?' + Math.random(); | ||
loadjs(['img!' + src], { | ||
success: function() { | ||
throw new Error('Executed success callback'); | ||
}, | ||
error: function(pathsNotFound) { | ||
assertNotLoaded(src); | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); | ||
// ========================================================================== | ||
// API tests | ||
@@ -355,0 +473,0 @@ // ========================================================================== |
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
936476
47
25193
375