diff --git a/lib/util.js b/lib/util.js index 9ead1dd..edb446e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -142,6 +142,12 @@ exports.propParse = function( data, options ) // dealing with (in the classic OO sense) for ( prop in data ) { + // ignore properties of instance prototypes + if ( !( data.hasOwnProperty( prop ) ) ) + { + continue; + } + var value = data[ prop ], getter = ( ( getset ) ? data.__lookupGetter__( prop ) : null ), setter = ( ( getset ) ? data.__lookupSetter__( prop ) : null ); diff --git a/test/test-util-prop-parse.js b/test/test-util-prop-parse.js index 9e554e0..d380477 100644 --- a/test/test-util-prop-parse.js +++ b/test/test-util-prop-parse.js @@ -146,3 +146,24 @@ assert.equal( "Property parser supports passing each property to the provided function" ); + +var Foo = function() {}; +Foo.prototype.one = 1; + +var instance = new Foo(); +instance.two = 2; + +var count = 0; +util.propParse( instance, { + each: function() + { + count++; + }, +} ); + +assert.equal( + count, + 1, + "propParse should ignore prototype properties of instances" +); +