Skip to content

Commit

Permalink
fix(TreeRunner): Prevents returning an empty callback for AMD-ish mod…
Browse files Browse the repository at this point in the history
…ules

By default, the behavior of fetch rules was to return cb('') when
the module exists. For AMD-like modules, this is undersirable since AMD
modules can be dynamic by nature. This fix protects the if checks by
ensuring we are looking at an AMD-like module before running these tests.
  • Loading branch information
Emerson Yu committed Mar 6, 2014
1 parent eede762 commit 1bf3aac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
29 changes: 17 additions & 12 deletions dist/recent/inject.js
Expand Up @@ -4175,21 +4175,26 @@ var TreeNode = Fiber.extend(function() {
});
};

// is this module already available? If so, don't redownload. This happens often when
// there was an inline define() on the page
if (this.env.executor.getModule(nodeData.resolvedId)) {
return function(a, b, cb) {
cb('');
};
}
// for non-AMD modules, if the module is already resolved, return an empty string
// which will cause the communicator to exit early and apply content rules if required
// for AMD modules, we re-fetch every time due to the nature of dynamic modules
if (nodeData.resolvedId.indexOf('!') === -1) {
// is this module already available? If so, don't redownload. This happens often when
// there was an inline define() on the page
if (this.env.executor.getModule(nodeData.resolvedId)) {
return function(a, b, cb) {
cb('');
};
}

else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) {
return function(a, b, cb) {
cb('');
};
else if (this.env.executor.getModule(this.env.requireContext.qualifiedId(node))) {
return function(a, b, cb) {
cb('');
};
}
}

else if (fetchRules.length > 0) {
if (fetchRules.length > 0) {
return function(name, path, cb) {
var i = 0,
len = fetchRules.length;
Expand Down

0 comments on commit 1bf3aac

Please sign in to comment.