Skip to content

Commit

Permalink
Fixed: Namespace#lookup should also check in nested namespaces (wtf)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Apr 13, 2017
1 parent 2a30df8 commit 056ecc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ Namespace.prototype.lookup = function lookup(path, filterTypes, parentAlreadyChe
return found;
} else if (found instanceof Namespace && (found = found.lookup(path.slice(1), filterTypes, true)))
return found;
}
// Otherwise try each nested namespace
} else
for (var i = 0; i < this.nestedArray.length; ++i)
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i].lookup(path, filterTypes, true)))
return found;
// If there hasn't been a match, try again at the parent
if (this.parent === null || parentAlreadyChecked)
return null;
Expand Down
3 changes: 2 additions & 1 deletion tests/api_root-deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tape.test("extension fields", function(test) {
extensionField = extendedType.get(declaringField.fullName);
test.equal(extensionField, declaringField.extensionField, "should become instantly available if their extended type is knwon");

root.add(type = new Type("Test"));
ns.remove(extendedType);
type.remove(declaringField);
type.add(declaringField);
test.throws(function() {
root.resolveAll();
Expand Down

0 comments on commit 056ecc3

Please sign in to comment.