1
1
/**
2
- * @license r.js 1.0.4+ 20120106 9:40pm Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 1.0.4+ 20120118 11:43am Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName , env , fs , vm , path , exec , rhinoContext , dir , nodeRequire ,
22
22
nodeDefine , exists , reqMain , loadedOptimizedLib ,
23
- version = '1.0.4+ 20120106 9:40pm ' ,
23
+ version = '1.0.4+ 20120118 11:43am ' ,
24
24
jsSuffixRegExp = / \. j s $ / ,
25
25
commandOption = '' ,
26
26
useLibLoaded = { } ,
@@ -102,7 +102,7 @@ var requirejs, require, define;
102
102
}
103
103
104
104
/** vim: et:ts=4:sw=4:sts=4
105
- * @license RequireJS 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
105
+ * @license RequireJS 1.0.4+ Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
106
106
* Available via the MIT or new BSD license.
107
107
* see: http://github.com/jrburke/requirejs for details
108
108
*/
@@ -114,7 +114,7 @@ var requirejs, require, define;
114
114
115
115
( function ( ) {
116
116
//Change this version number for each release.
117
- var version = "1.0.4" ,
117
+ var version = "1.0.4+ " ,
118
118
commentRegExp = / ( \/ \* ( [ \s \S ] * ?) \* \/ | ( [ ^ : ] | ^ ) \/ \/ ( .* ) $ ) / mg,
119
119
cjsRequireRegExp = / r e q u i r e \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
120
120
currDirRegExp = / ^ \. \/ / ,
@@ -140,8 +140,13 @@ var requirejs, require, define;
140
140
interactiveScript = null ,
141
141
checkLoadedDepth = 0 ,
142
142
useInteractive = false ,
143
+ reservedDependencies = {
144
+ require : true ,
145
+ module : true ,
146
+ exports : true
147
+ } ,
143
148
req , cfg = { } , currentlyAddingScript , s , head , baseElement , scripts , script ,
144
- src , subPath , mainScript , dataMain , i , ctx , jQueryCheck , checkLoadedTimeoutId ;
149
+ src , subPath , mainScript , dataMain , globalI , ctx , jQueryCheck , checkLoadedTimeoutId ;
145
150
146
151
function isFunction ( it ) {
147
152
return ostring . call ( it ) === "[object Function]" ;
@@ -977,15 +982,62 @@ var requirejs, require, define;
977
982
}
978
983
} ;
979
984
980
- function forceExec ( manager , traced ) {
981
- if ( manager . isDone ) {
982
- return undefined ;
985
+ function findCycle ( manager , traced ) {
986
+ var fullName = manager . map . fullName ,
987
+ depArray = manager . depArray ,
988
+ fullyLoaded = true ,
989
+ i , depName , depManager , result ;
990
+
991
+ if ( manager . isDone || ! fullName || ! loaded [ fullName ] ) {
992
+ return result ;
993
+ }
994
+
995
+ //Found the cycle.
996
+ if ( traced [ fullName ] ) {
997
+ return manager ;
998
+ }
999
+
1000
+ traced [ fullName ] = true ;
1001
+
1002
+ //Trace through the dependencies.
1003
+ if ( depArray ) {
1004
+ for ( i = 0 ; i < depArray . length ; i ++ ) {
1005
+ //Some array members may be null, like if a trailing comma
1006
+ //IE, so do the explicit [i] access and check if it has a value.
1007
+ depName = depArray [ i ] ;
1008
+ if ( ! loaded [ depName ] && ! reservedDependencies [ depName ] ) {
1009
+ fullyLoaded = false ;
1010
+ break ;
1011
+ }
1012
+ depManager = waiting [ depName ] ;
1013
+ if ( depManager && ! depManager . isDone && loaded [ depName ] ) {
1014
+ result = findCycle ( depManager , traced ) ;
1015
+ if ( result ) {
1016
+ break ;
1017
+ }
1018
+ }
1019
+ }
1020
+ if ( ! fullyLoaded ) {
1021
+ //Discard the cycle that was found, since it cannot
1022
+ //be forced yet. Also clear this module from traced.
1023
+ result = undefined ;
1024
+ delete traced [ fullName ] ;
1025
+ }
983
1026
}
984
1027
1028
+ return result ;
1029
+ }
1030
+
1031
+ function forceExec ( manager , traced ) {
985
1032
var fullName = manager . map . fullName ,
986
1033
depArray = manager . depArray ,
987
1034
i , depName , depManager , prefix , prefixManager , value ;
988
1035
1036
+
1037
+ if ( manager . isDone || ! fullName || ! loaded [ fullName ] ) {
1038
+ return undefined ;
1039
+ }
1040
+
989
1041
if ( fullName ) {
990
1042
if ( traced [ fullName ] ) {
991
1043
return defined [ fullName ] ;
@@ -1016,7 +1068,7 @@ var requirejs, require, define;
1016
1068
}
1017
1069
}
1018
1070
1019
- return fullName ? defined [ fullName ] : undefined ;
1071
+ return defined [ fullName ] ;
1020
1072
}
1021
1073
1022
1074
/**
@@ -1029,8 +1081,9 @@ var requirejs, require, define;
1029
1081
var waitInterval = config . waitSeconds * 1000 ,
1030
1082
//It is possible to disable the wait interval by using waitSeconds of 0.
1031
1083
expired = waitInterval && ( context . startTime + waitInterval ) < new Date ( ) . getTime ( ) ,
1032
- noLoads = "" , hasLoadedProp = false , stillLoading = false , prop ,
1033
- err , manager ;
1084
+ noLoads = "" , hasLoadedProp = false , stillLoading = false ,
1085
+ onlyPluginResourceLoading = true ,
1086
+ i , prop , err , manager , cycleManager ;
1034
1087
1035
1088
//If there are items still in the paused queue processing wait.
1036
1089
//This is particularly important in the sync case where each paused
@@ -1060,7 +1113,15 @@ var requirejs, require, define;
1060
1113
noLoads += prop + " " ;
1061
1114
} else {
1062
1115
stillLoading = true ;
1063
- break ;
1116
+ if ( prop . indexOf ( '!' ) === - 1 ) {
1117
+ onlyPluginResourceLoading = false ;
1118
+ //No reason to keep looking for unfinished
1119
+ //loading. If the only stillLoading is a
1120
+ //plugin resource though, keep going,
1121
+ //because it may be that a plugin resource
1122
+ //is waiting on a non-plugin cycle.
1123
+ break ;
1124
+ }
1064
1125
}
1065
1126
}
1066
1127
}
@@ -1079,7 +1140,11 @@ var requirejs, require, define;
1079
1140
err . requireModules = noLoads ;
1080
1141
return req . onError ( err ) ;
1081
1142
}
1082
- if ( stillLoading || context . scriptCount ) {
1143
+
1144
+ //If still waiting on loads, and the waiting load is something
1145
+ //other than a plugin resource, or there are still outstanding
1146
+ //scripts, then just try back later.
1147
+ if ( ( stillLoading && ! onlyPluginResourceLoading ) || context . scriptCount ) {
1083
1148
//Something is still waiting to load. Wait for it, but only
1084
1149
//if a timeout is not already in effect.
1085
1150
if ( ( isBrowser || isWebWorker ) && ! checkLoadedTimeoutId ) {
@@ -1102,7 +1167,10 @@ var requirejs, require, define;
1102
1167
if ( context . waitCount ) {
1103
1168
//Cycle through the waitAry, and call items in sequence.
1104
1169
for ( i = 0 ; ( manager = waitAry [ i ] ) ; i ++ ) {
1105
- forceExec ( manager , { } ) ;
1170
+ if ( ( cycleManager = findCycle ( manager , { } ) ) ) {
1171
+ forceExec ( cycleManager , { } ) ;
1172
+ break ;
1173
+ }
1106
1174
}
1107
1175
1108
1176
//If anything got placed in the paused queue, run it down.
@@ -1945,7 +2013,7 @@ var requirejs, require, define;
1945
2013
//Figure out baseUrl. Get it from the script tag with require.js in it.
1946
2014
scripts = document . getElementsByTagName ( "script" ) ;
1947
2015
1948
- for ( i = scripts . length - 1 ; i > - 1 && ( script = scripts [ i ] ) ; i -- ) {
2016
+ for ( globalI = scripts . length - 1 ; globalI > - 1 && ( script = scripts [ globalI ] ) ; globalI -- ) {
1949
2017
//Set the "head" where we can append children by
1950
2018
//using the script's parent.
1951
2019
if ( ! head ) {
0 commit comments