Skip to content

Commit

Permalink
Stylesheet is skipped when preload gets re-triggered. #190
Browse files Browse the repository at this point in the history
  • Loading branch information
pisi committed May 17, 2013
1 parent cdb8352 commit 64b20ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jquery.reel.js
Expand Up @@ -942,7 +942,7 @@ jQuery.reel || (function($, window, document, undefined){
uris= []
$overlay.addClass(loading_klass).append(preloader());
// It also finalizes the instance stylesheet and prepends it to the head.
set(_style_, $('<'+_style_+' type="text/css">'+css.rules.join('\n')+'</'+_style_+'>').prependTo(_head_));
set(_style_, get(_style_) || $('<'+_style_+' type="text/css">'+css.rules.join('\n')+'</'+_style_+'>').prependTo(_head_));
t.trigger('stop');
while(preload.length){
var
Expand Down
28 changes: 28 additions & 0 deletions test/unit/rendering.js
Expand Up @@ -320,4 +320,32 @@
});
});

asyncTest( 'Instance creates a stylesheet just once per its existence', function(){
expect(3);
var
before= 'image/to/start/with.jpg',
after= 'different/image.jpg',
pass= 0,
styles= $('style').length,
$reel= $('#image').reel({
image: before
})

equal( styles, 1, 'One test framework stylesheet');

$(document).bind('loaded.test', function(){
switch(++pass){
case 1:
equal( styles + 1, $('style').length, 'Plus one for Reel instance');
styles= $('style').length;
$reel.reel('image', after);
break;
case 2:
equal( $('style').length, styles, 'No zombie stylesheets after reload');
start();
break;
}
});
});

})(jQuery);

0 comments on commit 64b20ac

Please sign in to comment.