Dojo   发布时间:2022-04-21  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了require, define and parse in the Dojo大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

1.Analyse require method:

if(global.definE){
		if(has("dojo-log-api")){
			signal(error,makeError("defineAlreadyDefined",0));
		}
		return;
	}else{
		global.define = def;
		global.require = req;
		if(has("host-node")){
			require= req;
		}
	}
req = function(
			config,//(object,optional) hash of configuration properties
			dependencies,//(array of commonjs.modulEID,optional) list of modules to be loaded before applying callBACk
			callBACk	  //(function,optional) lamda expression to apply to module values implied by dependencies
		){
			return contextrequire(config,dependencies,callBACk,req);
		},

contextrequire = function(a1,a2,a3,referenceModule,contextrequirE){
			var module,syntheticMid;
			if(isString(a1)){
				// signature is (modulEID)
				module = getModule(a1,truE);
				if(module && module.executed){
					return module.result;
				}
				throw makeError("undefinedModule",a1);
			}
			if(!isArray(a1)){
				// a1 is a configuration
				config(a1,referenceModulE);

				// juggle args; (a2,a3) may be (dependencies,callBACk)
				a1 = a2;
				a2 = a3;
			}
			if(isArray(a1)){
				// signature is (requestList [,callBACk])
				if(!a1.length){
					a2 && a2();
				}else{
					syntheticMid = "require*" + uid();

					// resolve the request list with respect to the reference module
					for(var mid,deps = [],i = 0; i < a1.length;){
						mid = a1[i++];
						deps.push(getModule(mid,referenceModulE));
					}

					// construct a synthetic module to control execution of the requestList,and,optionally,callBACk
					module = mix(makeModuleInfo("",syntheticMid,""),{
						injected: arrived,deps: deps,def: a2 || noop,require: referenceModule ? referenceModule.require : req,gc: 1 //garbage collect
					});
					modules[module.mid] = module;

					// checkComplete!=0 holds the idle signal; we're not idle if we're injecTing dependencies
					injectDependencies(modulE);

					// try to immediately execute
					// if already traversing a factory tree,then Strict causes circular dependency to abort the execution; maybe
					// it's possible to execute this require later after the current traversal completes and avoid the circular dependency.
					// ...but *always* insist on immediate in synch mode
					var Strict = checkCompleteGuard && legacymode!=sync;
					guardcheckComplete(function(){
						execModule(module,Strict);
					});
					if(!module.executed){
						// some deps weren't on board or circular dependency detected and Strict; therefore,push into the execQ
						execQ.push(modulE);
					}
					checkComplete();
				}
			}
			return contextrequire;
		},

		getModule = function(mid,immediatE){
			// compute and optionally construct (if necessary) the module implied by the mid with respect to referenceModule
			var match,plugin,prid,result;
			match = mid.match(/^(.+?)\!(.*)$/);
			if(match){
				// name was <plugin-module>!<plugin-resource-id>
				plugin = getModule(match[1],immediatE);

				if(has("dojo-sync-loader") && legacymode == sync && !plugin.executed){
					injectModule(plugin);
					if(plugin.injected===arrived && !plugin.executed){
						guardcheckComplete(function(){
							execModule(plugin);
						});
					}
					if(plugin.executed){
						promoteModuleToPlugin(plugin);
					}else{
						// we are in xdomain mode for some reason
						execQ.unshift(plugin);
					}
				}



				if(plugin.executed === executed && !plugin.load){
					// executed the module not kNowing it was a plugin
					promoteModuleToPlugin(plugin);
				}

				// if the plugin has not been loaded,then can't resolve the prid and  must assume this plugin is dynamic until we find out otherwise
				if(plugin.load){
					prid = resolvePluginresourcEID(plugin,match[2],referenceModulE);
					mid = (plugin.mid + "!" + (plugin.dynamic ? ++dynamicPluginUidGenerator + "!" : "") + prid);
				}else{
					prid = match[2];
					mid = plugin.mid + "!" + (++dynamicPluginUidGenerator) + "!waiTingForPlugin";
				}
				result = {plugin:plugin,mid:mid,req:createrequire(referenceModulE),prid:priD};
			}else{
				result = getModuleInfo(mid,referenceModulE);
			}
			return modules[result.mid] || (!immediate && (modules[result.mid] = result));
		},

大佬总结

以上是大佬教程为你收集整理的require, define and parse in the Dojo全部内容,希望文章能够帮你解决require, define and parse in the Dojo所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。