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