1
1
'use strict' ;
2
2
var global = require ( '../internals/global' ) ;
3
+ var getOwnPropertyDescriptor = require ( '../internals/object-get-own-property-descriptor' ) . f ;
3
4
var isForced = require ( '../internals/is-forced' ) ;
4
5
var path = require ( '../internals/path' ) ;
5
6
var bind = require ( '../internals/bind-context' ) ;
@@ -21,16 +22,18 @@ var wrapConstructor = function (NativeConstructor) {
21
22
} ;
22
23
23
24
/*
24
- options.target - name of the target object
25
- options.global - target is the global object
26
- options.stat - export as static methods of target
27
- options.proto - export as prototype methods of target
28
- options.real - real prototype method for the `pure` version
29
- options.forced - export even if the native feature is available
30
- options.bind - bind methods to the target, required for the `pure` version
31
- options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
32
- options.unsafe - use the simple assignment of property instead of delete + defineProperty
33
- options.sham - add a flag to not completely full polyfills
25
+ options.target - name of the target object
26
+ options.global - target is the global object
27
+ options.stat - export as static methods of target
28
+ options.proto - export as prototype methods of target
29
+ options.real - real prototype method for the `pure` version
30
+ options.forced - export even if the native feature is available
31
+ options.bind - bind methods to the target, required for the `pure` version
32
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
33
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
34
+ options.sham - add a flag to not completely full polyfills
35
+ options.enumerable - export as enumerable property
36
+ options.noTargetGet - prevent calling a getter on target
34
37
*/
35
38
module . exports = function ( options , source ) {
36
39
var TARGET = options . target ;
@@ -43,7 +46,8 @@ module.exports = function (options, source) {
43
46
var target = GLOBAL ? path : path [ TARGET ] || ( path [ TARGET ] = { } ) ;
44
47
var targetPrototype = target . prototype ;
45
48
46
- var FORCED , USE_NATIVE , VIRTUAL_PROTOTYPE , key , sourceProperty , targetProperty , resultProperty ;
49
+ var FORCED , USE_NATIVE , VIRTUAL_PROTOTYPE ;
50
+ var key , sourceProperty , targetProperty , nativeProperty , resultProperty , descriptor ;
47
51
48
52
for ( key in source ) {
49
53
FORCED = isForced ( GLOBAL ? key : TARGET + ( STATIC ? '.' : '#' ) + key , options . forced ) ;
@@ -52,8 +56,13 @@ module.exports = function (options, source) {
52
56
53
57
targetProperty = target [ key ] ;
54
58
59
+ if ( USE_NATIVE ) if ( options . noTargetGet ) {
60
+ descriptor = getOwnPropertyDescriptor ( nativeSource , key ) ;
61
+ nativeProperty = descriptor && descriptor . value ;
62
+ } else nativeProperty = nativeSource [ key ] ;
63
+
55
64
// export native or implementation
56
- sourceProperty = USE_NATIVE ? nativeSource [ key ] : source [ key ] ;
65
+ sourceProperty = ( USE_NATIVE && nativeProperty ) ? nativeProperty : source [ key ] ;
57
66
58
67
if ( USE_NATIVE && typeof targetProperty === typeof sourceProperty ) continue ;
59
68
0 commit comments