sindresorhus/dot-prop

get() method's switch to object.prototype.propertyIsEnumerable broke my code #46

joshua-golub posted onGitHub

This change was made in July 2016:

use `object.prototype.propertyIsEnumerable instead of `Object.getOwnPropertyDescriptor`

Unfortunately, this change broke my code. Specifically, I was using it like this in the Express framework:

dot = require( "dot-prop" );
req.app.locals.foo = 1;
console.log( "foo = " + dot.get( req, "app.locals.foo" ) );

where the req object is defined here.

Before this change, foo = 1 was logged. After this change, foo = undefined was logged.

The problem appears to be that req.app isn't an enumerable property because it is an inherited property.

So, here's my question: why are we discriminating against inherited properties inside the get() method? That doesn't seem right to me.


This also affects getters. My current work around is to use dot-prop-immutable.

posted by OmgImAlexis over 6 years ago

@issuehunt has funded $40.00 to this issue.


posted by IssueHuntBot about 6 years ago

@sindresorhus has rewarded $36.00 to @stroncium. See it on IssueHunt

  • :moneybag: Total deposit: $40.00
  • :tada: Repository reward(0%): $0.00
  • :wrench: Service fee(10%): $4.00
posted by issuehunt-app[bot] over 4 years ago

Fund this Issue

$40.00
Rewarded

Rewarded pull request

Recent activities

stroncium was rewarded by sindresorhus for sindresorhus/dot-prop# 46
over 4 years ago
stroncium submitted an output to  sindresorhus/ dot-prop# 46
about 6 years ago