Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
3 | var anObject = require('../internals/an-object');
|
---|
4 | var toPropertyKey = require('../internals/to-property-key');
|
---|
5 | var definePropertyModule = require('../internals/object-define-property');
|
---|
6 | var fails = require('../internals/fails');
|
---|
7 |
|
---|
8 | // MS Edge has broken Reflect.defineProperty - throwing instead of returning false
|
---|
9 | var ERROR_INSTEAD_OF_FALSE = fails(function () {
|
---|
10 | // eslint-disable-next-line es/no-reflect -- required for testing
|
---|
11 | Reflect.defineProperty(definePropertyModule.f({}, 1, { value: 1 }), 1, { value: 2 });
|
---|
12 | });
|
---|
13 |
|
---|
14 | // `Reflect.defineProperty` method
|
---|
15 | // https://tc39.es/ecma262/#sec-reflect.defineproperty
|
---|
16 | $({ target: 'Reflect', stat: true, forced: ERROR_INSTEAD_OF_FALSE, sham: !DESCRIPTORS }, {
|
---|
17 | defineProperty: function defineProperty(target, propertyKey, attributes) {
|
---|
18 | anObject(target);
|
---|
19 | var key = toPropertyKey(propertyKey);
|
---|
20 | anObject(attributes);
|
---|
21 | try {
|
---|
22 | definePropertyModule.f(target, key, attributes);
|
---|
23 | return true;
|
---|
24 | } catch (error) {
|
---|
25 | return false;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.