From 01df038474f4c480df2a0564b853bae749bd89ce Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Mon, 8 Jun 2015 15:24:55 -0700 Subject: [PATCH] unconditionally add the necessary properties to AST nodes (#976) Fixes a bizarre bug that caused us to assign the wrong name to object properties, apparently because the node ID was not defined at the appropriate time. --- lib/jsdoc/src/walker.js | 7 +------ test/fixtures/objectkeys.js | 4 ++++ test/specs/documentation/objectkeys.js | 12 ++++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/objectkeys.js create mode 100644 test/specs/documentation/objectkeys.js diff --git a/lib/jsdoc/src/walker.js b/lib/jsdoc/src/walker.js index 6e9914ca..2f5e374c 100644 --- a/lib/jsdoc/src/walker.js +++ b/lib/jsdoc/src/walker.js @@ -505,12 +505,7 @@ Walker.prototype._recurse = function(filename, ast) { var isScope = astnode.isScope(node); - // for efficiency, if the node has a `parent` property, assume that we've already - // added the required properties - if (typeof node.parent !== 'undefined') { - astnode.addNodeProperties(node); - } - + astnode.addNodeProperties(node); node.parent = parent || null; currentScope = getCurrentScope(cbState.scopes); diff --git a/test/fixtures/objectkeys.js b/test/fixtures/objectkeys.js new file mode 100644 index 00000000..326567aa --- /dev/null +++ b/test/fixtures/objectkeys.js @@ -0,0 +1,4 @@ +var myObject = { + foo: 1, + bar: 2 +}; diff --git a/test/specs/documentation/objectkeys.js b/test/specs/documentation/objectkeys.js new file mode 100644 index 00000000..eff645f8 --- /dev/null +++ b/test/specs/documentation/objectkeys.js @@ -0,0 +1,12 @@ +'use strict'; + +describe('object keys', function() { + var docSet = jasmine.getDocSetFromFile('test/fixtures/objectkeys.js'); + + it('should assign the correct longname and memberof to object keys after the first key', function() { + var bar = docSet.getByLongname('myObject.bar')[0]; + + expect(bar).toBeDefined(); + expect(bar.memberof).toBe('myObject'); + }); +});