diff --git a/es5-sham.js b/es5-sham.js index 8491bf05..9ed3bbe3 100644 --- a/es5-sham.js +++ b/es5-sham.js @@ -413,7 +413,7 @@ if (!Object.defineProperty || definePropertyFallback) { object[property] = descriptor.value; } } else { - if (!supportsAccessors) { + if (!supportsAccessors && (('get' in descriptor) || ('set' in descriptor))) { throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); } // If we got that far then getters and setters can be defined !! diff --git a/tests/spec/s-object.js b/tests/spec/s-object.js index 8262ec92..a4370c06 100644 --- a/tests/spec/s-object.js +++ b/tests/spec/s-object.js @@ -180,6 +180,12 @@ describe('Object', function () { Object.defineProperty(42, 'name', {}); }).toThrow(); }); + + it('should not throw error for empty descriptor', function () { + expect(function () { + Object.defineProperty({}, 'name', {}); + }).not.toThrow(); + }); }); describe('Object.getOwnPropertyDescriptor', function () {