Skip to content
New issue

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

TIMOB-11505 Android:Properly return module wrapper from require(). #3253

Merged
merged 1 commit into from
Oct 17, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions android/runtime/common/src/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Module.prototype.loadExternalModule = function(id, externalBinding, context) {
}

kroll.log(TAG, "Unable to load external module: " + id);

}

// Require another module as a child of this module.
Expand All @@ -209,7 +209,6 @@ Module.prototype.loadExternalModule = function(id, externalBinding, context) {
// of the child module.
Module.prototype.require = function (request, context, useCache) {
useCache = useCache === undefined ? true : useCache;

var id;
var filename;
var cachedModule;
Expand All @@ -232,6 +231,11 @@ Module.prototype.require = function (request, context, useCache) {
}

} else {
// Already have this precise name wrapped and cached? If yes, quick exit.
var wrapper = this.wrapperCache[request];
if (wrapper) {
return wrapper;
}
// External module?
var pathResolve = resolveLookupPaths(request, this);
id = pathResolve[0];
Expand All @@ -253,7 +257,10 @@ Module.prototype.require = function (request, context, useCache) {
if (useCache) {
cachedModule = Module.cache[filename];
if (cachedModule) {
return cachedModule.exports;
wrapper = this.wrapperCache[filename];
if (wrapper) {
return wrapper;
}
}
}

Expand Down