object-path
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -82,3 +82,3 @@ (function (root, factory){ | ||
function getShallowProperty(obj, prop) { | ||
if(options.includeInheritedProps || (typeof prop === 'number' && Array.isArray(obj)) || obj.hasOwnProperty(prop)) { | ||
if (options.includeInheritedProps || (typeof prop === 'number' && Array.isArray(obj)) || _hasOwnProperty.call(obj, prop)) { | ||
return obj[prop]; | ||
@@ -85,0 +85,0 @@ } |
{ | ||
"name": "object-path", | ||
"description": "Access deep object properties using a path", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Mario Casciaro" |
@@ -131,5 +131,6 @@ | ||
```javascript | ||
var Obj = function() {}; | ||
Obj.prototype.notOwn = {prop: 'a'}; | ||
var obj = new Obj(); | ||
var proto = { | ||
notOwn: {prop: 'a'} | ||
} | ||
var obj = Object.create(proto); | ||
@@ -141,3 +142,3 @@ //This will return undefined (or the default value you specified), because notOwn is | ||
//This will set the property on the obj instance and not the prototype. | ||
//In other words Obj.notOwn.prop === 'a' and obj.notOwn.prop === 'b' | ||
//In other words proto.notOwn.prop === 'a' and obj.notOwn.prop === 'b' | ||
objectPath.set(obj, 'notOwn.prop', 'b'); | ||
@@ -161,5 +162,6 @@ ``` | ||
```javascript | ||
var Obj = function() {}; | ||
Obj.prototype.notOwn = {prop: 'a'}; | ||
var obj = new Obj(); | ||
var proto = { | ||
notOwn: {prop: 'a'} | ||
} | ||
var obj = Object.create(proto); | ||
@@ -169,3 +171,3 @@ //This will return 'a' | ||
//This will set Obj.notOwn.prop to 'b' | ||
//This will set proto.notOwn.prop to 'b' | ||
objectPath.set(obj, 'notOwn.prop', 'b'); | ||
@@ -172,0 +174,0 @@ ``` |
12
test.js
@@ -105,2 +105,12 @@ 'use strict'; | ||
it( | ||
'should not fail on an object with a null prototype', | ||
function assertSuccessForObjWithNullProto(){ | ||
var foo = 'FOO'; | ||
var objWithNullProto = Object.create(null); | ||
objWithNullProto.foo = foo; | ||
expect(objectPath.get(objWithNullProto, 'foo')).to.equal(foo); | ||
} | ||
); | ||
it('should skip non own properties', function() { | ||
@@ -776,3 +786,3 @@ var Base = function(enabled){ }; | ||
describe('Don\' access not own properties [default]', function () { | ||
describe('Don\'t access not own properties [default]', function () { | ||
it('should not get a not own property', function() { | ||
@@ -779,0 +789,0 @@ var Obj = function() {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44106
1078
181