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.
This commit is contained in:
Jeff Williams 2015-06-08 15:24:55 -07:00
parent 70d13b8948
commit 01df038474
3 changed files with 17 additions and 6 deletions

View File

@ -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);

4
test/fixtures/objectkeys.js vendored Normal file
View File

@ -0,0 +1,4 @@
var myObject = {
foo: 1,
bar: 2
};

View File

@ -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');
});
});