diff --git a/src/utils.js b/src/utils.js index d93f10c50c2e..7a4d59e0803f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -39,7 +39,11 @@ function isString(what) { } function isEmptyObject(what) { - for (var _ in what) return false; // eslint-disable-line guard-for-in, no-unused-vars + for (var _ in what) { + if (what.hasOwnProperty(_)) { + return false; + } + } return true; } diff --git a/test/utils.test.js b/test/utils.test.js index 7da12461bfd7..8f2b66c641f8 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -64,6 +64,12 @@ describe('utils', function() { it('should work as advertised', function() { assert.isTrue(isEmptyObject({})); assert.isFalse(isEmptyObject({foo: 1})); + var MyObj = function() {}; + MyObj.prototype.foo = 0; + assert.isTrue(isEmptyObject(new MyObj())); + var myExample = new MyObj(); + myExample.bar = 1; + assert.isFalse(isEmptyObject(myExample)); }); });