Permalink
Browse files

Small refactoring in `handleStackObject()`

  • Loading branch information...
1 parent 2a7e7d6 commit 2b95342ad2b7e96c5b4c9bd55927ba584af2ba55 @peol peol committed Mar 14, 2012
Showing with 9 additions and 12 deletions.
  1. +9 −12 lib/basket.js
View
@@ -52,29 +52,26 @@
key = storagePrefix + ( obj.key || obj.url ),
waitCount = globalWaitCount,
scriptIndex = scripts.length,
- source = localStorage.getItem( key );
+ source = localStorage.getItem( key ),
+ callback = function( text ) {
+ scripts[ scriptIndex ] = text;
+ queueExec( waitCount, obj.execute );
+ };
if ( !obj.url ) {
return;
}
- if ( obj.execute !== false ) {
- obj.execute = true;
- }
-
+ obj.execute = obj.execute !== false;
scripts[ scriptIndex ] = null;
if ( source ) {
- scripts[ scriptIndex ] = source;
- queueExec( waitCount, obj.execute );
+ callback( source );
} else {
- saveUrl( obj.url, key, function( text ) {
- scripts[ scriptIndex ] = text;
- queueExec( waitCount, obj.execute );
- });
+ saveUrl( obj.url, key, callback );
}
- if ( obj.wait ) {
+ if ( isFunc(obj.wait) ) {
basket.wait( obj.wait );
}
},

0 comments on commit 2b95342

Please sign in to comment.