From 769a71298e0daa1c331e3c8e83101cb7b0c53a78 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Wed, 4 Jul 2012 15:59:33 -0700 Subject: [PATCH] enable JSHint's "forin" test --- .jshintrc | 2 +- jsdoc.js | 9 +++-- rhino_modules/jsdoc/augment.js | 26 ++++++++----- rhino_modules/jsdoc/tutorial/resolver.js | 47 +++++++++++++----------- templates/default/publish.js | 26 +++++++------ 5 files changed, 62 insertions(+), 48 deletions(-) diff --git a/.jshintrc b/.jshintrc index 08eb3b40..737dd285 100644 --- a/.jshintrc +++ b/.jshintrc @@ -2,7 +2,7 @@ "bitwise": true, "curly": true, "eqeqeq": false, - "forin": false, + "forin": true, "immed": false, "latedef": false, "newcap": false, diff --git a/jsdoc.js b/jsdoc.js index e2f3d19c..66dada0a 100644 --- a/jsdoc.js +++ b/jsdoc.js @@ -8,6 +8,8 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// +var hasOwnProp = Object.prototype.hasOwnProperty; + /** Data representing the environment in which this app is running. @namespace */ @@ -151,7 +153,9 @@ function installPlugins(plugins, p) { //...register event handlers if (plugin.handlers) { for (var eventName in plugin.handlers) { - parser.on(eventName, plugin.handlers[eventName]); + if ( hasOwnProp.call(plugin.handlers, eventName) ) { + parser.on(eventName, plugin.handlers[eventName]); + } } } @@ -168,8 +172,7 @@ function installPlugins(plugins, p) { } function indexAll(docs) { - var lookupTable = {}, - hasOwnProp = Object.prototype.hasOwnProperty; + var lookupTable = {}; docs.forEach(function(doc) { if ( !hasOwnProp.call(lookupTable, doc.longname) ) { diff --git a/rhino_modules/jsdoc/augment.js b/rhino_modules/jsdoc/augment.js index bd9d1ecc..1923e8aa 100644 --- a/rhino_modules/jsdoc/augment.js +++ b/rhino_modules/jsdoc/augment.js @@ -23,14 +23,16 @@ var doop = require("jsdoc/util/doop").doop; function mapDependencies(index) { var doclets, doc, len, dependencies = {}; for (var name in index) { - doclets = index[name]; - for (var i=0, ii=doclets.length; i