Skip to content

Commit

Permalink
fix image plugin on IE7. delete img.onload throws errors..
Browse files Browse the repository at this point in the history
  • Loading branch information
millermedeiros committed Dec 15, 2011
1 parent bfe32c4 commit 025a2d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/image.js
@@ -1,7 +1,7 @@
/** @license
* RequireJS Image Plugin
* Author: Miller Medeiros
* Version: 0.2.0 (2011/12/06)
* Version: 0.2.1 (2011/12/15)
* Released under the MIT license
*/
define(function(){
Expand All @@ -10,6 +10,8 @@ define(function(){
CACHE_BUST_FLAG = '!bust',
RELATIVE_FLAG = '!rel';

function noop(){}

function cacheBust(url){
url = url.replace(CACHE_BUST_FLAG, '');
url += (url.indexOf('?') < 0)? '?' : '&';
Expand All @@ -25,7 +27,11 @@ define(function(){
img = new Image();
img.onload = function(evt){
onLoad(img);
delete img.onload; //release memory - suggested by John Hann
try {
delete img.onload; //release memory - suggested by John Hann
} catch(err) {
img.onload = noop; // IE7 :(
}
};
if (name.indexOf(RELATIVE_FLAG) !== -1) {
//load image relative to module path / baseUrl
Expand Down

0 comments on commit 025a2d0

Please sign in to comment.