From 056ecc3834a3b323aaaa676957efcbe3f52365a0 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Thu, 13 Apr 2017 17:57:54 +0200 Subject: [PATCH] Fixed: Namespace#lookup should also check in nested namespaces (wtf) --- src/namespace.js | 6 +++++- tests/api_root-deferred.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/namespace.js b/src/namespace.js index 1d8d73dc6..399c5aa99 100644 --- a/src/namespace.js +++ b/src/namespace.js @@ -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; diff --git a/tests/api_root-deferred.js b/tests/api_root-deferred.js index 7a1ea3c86..577e7b5dc 100644 --- a/tests/api_root-deferred.js +++ b/tests/api_root-deferred.js @@ -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();