File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -225,24 +225,27 @@ var require;
225
225
* @param {Function= } factory 创建模块的工厂方法
226
226
*/
227
227
function define ( id , dependencies , factory ) {
228
- if ( ! arguments . length ) {
229
- return ;
230
- }
231
-
232
- if ( typeof id ! == 'string' ) {
233
- if ( id instanceof Array ) {
234
- factory = dependencies ;
235
- dependencies = id ;
228
+ // define(factory)
229
+ // define(dependencies, factory)
230
+ // define(id, factory)
231
+ // define(id, dependencies, factory)
232
+ if ( factory == null ) {
233
+ if ( dependencies == null ) {
234
+ factory = id ;
235
+ id = null ;
236
236
}
237
237
else {
238
- factory = id ;
238
+ factory = dependencies ;
239
239
dependencies = null ;
240
+ if ( id instanceof Array ) {
241
+ dependencies = id ;
242
+ id = null ;
243
+ }
240
244
}
241
- id = null ;
242
245
}
243
- else if ( ! ( dependencies instanceof Array ) ) {
244
- factory = dependencies ;
245
- dependencies = null ;
246
+
247
+ if ( factory == null ) {
248
+ return ;
246
249
}
247
250
248
251
// 出现window不是疏忽
You can’t perform that action at this time.
0 commit comments