Skip to content

Commit cbd7074

Browse files
author
Yanis Benson
authoredOct 7, 2020
Allow getting non-enumerable properties (#54)
1 parent 614e74a commit cbd7074

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
 

‎index.js

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ module.exports = {
4343
}
4444

4545
for (let i = 0; i < pathArray.length; i++) {
46-
if (!Object.prototype.propertyIsEnumerable.call(object, pathArray[i])) {
47-
return value;
48-
}
49-
5046
object = object[pathArray[i]];
5147

5248
if (object === undefined || object === null) {

‎test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ test('get', t => {
3030
value: 'bar',
3131
enumerable: false
3232
});
33-
t.is(dotProp.get(fixture2, 'foo'), undefined);
34-
t.is(dotProp.get({}, 'hasOwnProperty'), undefined);
33+
t.is(dotProp.get(fixture2, 'foo'), 'bar');
34+
t.is(dotProp.get({}, 'hasOwnProperty'), Object.prototype.hasOwnProperty);
3535

3636
function fn() {}
3737
fn.foo = {bar: 1};
@@ -50,6 +50,11 @@ test('get', t => {
5050
t.false(dotProp.get('foo', 'foo.bar', false));
5151
t.false(dotProp.get([], 'foo.bar', false));
5252
t.false(dotProp.get(undefined, 'foo.bar', false));
53+
54+
class F4Class {}
55+
F4Class.prototype.foo = 1;
56+
const f4 = new F4Class();
57+
t.is(dotProp.get(f4, 'foo'), 1); // #46
5358
});
5459

5560
test('set', t => {

0 commit comments

Comments
 (0)
Please sign in to comment.