We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
foo -> bar -> tpl!x empty
如果tpl!x已经预先require并ready时
tpl!x
require(['foo'],callback)
require(['foo', 'empty'],callback)
原因是因为,modAutoDefine会对每个需要自动定义的模块进行modPrepare、modUpdatePreparedState、modTryInvoke调用。modUpdatePreparedState中,会尝试调用其依赖模块的modPrepare。如果模块包含resource依赖,modPrepare中会在尝试在resource加载完后重新调起modAutoDefine。当resource当前已经处于ready状态时,这个过程会马上发起。从而导致一个运行过程中,同一个模块的modUpdatePreparedState被重入。而modUpdatePreparedState中,对模块状态的写入没有做判断,从而导致模块状态可能从defined回退到prepared。
过程如下:
script onload -> modAutoDefine -> modPrepare(foo) -> modUpdatePreparedState(foo) -> modPrepare(bar) -> requireResource -> modAutoDefine -> modPrepare(foo) -> modUpdatePreparedState(foo) -> modTryInvoke(foo) -> modTryInvoke(foo)
由于:
所以,采用解决方案为:modUpdatePreparedState中,对模块状态的写入做判断
if (!modIs(id, MODULE_PREPARED) { mod.state = MODULE_PREPARED; }
The text was updated successfully, but these errors were encountered:
c30d28d
http://git-htmldocs.googlecode.com/git/git.html
Sorry, something went wrong.
No branches or pull requests
如果
tpl!x
已经预先require并ready时require(['foo'],callback)
时,callback被调用,但是未来foo模块将不存在require(['foo', 'empty'],callback)
时,callback不被调用原因是因为,modAutoDefine会对每个需要自动定义的模块进行modPrepare、modUpdatePreparedState、modTryInvoke调用。modUpdatePreparedState中,会尝试调用其依赖模块的modPrepare。如果模块包含resource依赖,modPrepare中会在尝试在resource加载完后重新调起modAutoDefine。当resource当前已经处于ready状态时,这个过程会马上发起。从而导致一个运行过程中,同一个模块的modUpdatePreparedState被重入。而modUpdatePreparedState中,对模块状态的写入没有做判断,从而导致模块状态可能从defined回退到prepared。
过程如下:
由于:
所以,采用解决方案为:modUpdatePreparedState中,对模块状态的写入做判断
The text was updated successfully, but these errors were encountered: