From c234de7f0573ee30ed1ecb15aa82b74c0f994876 Mon Sep 17 00:00:00 2001 From: dcodeIO Date: Sun, 18 Dec 2016 13:39:33 +0100 Subject: [PATCH] Added codegen test to determine if any ancient browsers don't actually support it --- src/namespace.js | 5 ++--- tests/codegen.js | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/codegen.js diff --git a/src/namespace.js b/src/namespace.js index 2d1cda417..0ed91efa7 100644 --- a/src/namespace.js +++ b/src/namespace.js @@ -283,9 +283,8 @@ NamespacePrototype.lookup = function lookup(path, filterType, parentAlreadyCheck return this.getRoot().lookup(path.slice(1), filterType); // Test if the first part matches any nested object, and if so, traverse if path contains more var found = this.get(path[0]); - if (found && path.length === 1 || found instanceof Namespace && (found = found.lookup(path.slice(1), true))) - if (!filterType || found instanceof filterType) - return found; + if (found && path.length === 1 && (!filterType || found instanceof filterType) || found instanceof Namespace && (found = found.lookup(path.slice(1), filterType, 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/codegen.js b/tests/codegen.js new file mode 100644 index 000000000..ccd2c5270 --- /dev/null +++ b/tests/codegen.js @@ -0,0 +1,8 @@ +var tape = require("tape"); + +var protobuf = require(".."); + +tape.test("codegen", function(test) { + test.equal(protobuf.util.codegen.supported, true, "should be supported"); + test.end(); +});