@@ -518,12 +518,14 @@ Zone.patchMutationObserverClass = function (className) {
518
518
Zone . patchDefineProperty = function ( ) {
519
519
var _defineProperty = Object . defineProperty ;
520
520
var _getOwnPropertyDescriptor = Object . getOwnPropertyDescriptor ;
521
+ var _create = Object . create ;
521
522
522
523
Object . defineProperty = function ( obj , prop , desc ) {
523
524
if ( isUnconfigurable ( obj , prop ) ) {
524
525
throw new TypeError ( 'Cannot assign to read only property \'' + prop + '\' of ' + obj ) ;
525
526
}
526
- return rewriteDescriptor ( obj , prop , desc ) ;
527
+ desc = rewriteDescriptor ( obj , prop , desc ) ;
528
+ return _defineProperty ( obj , prop , desc ) ;
527
529
} ;
528
530
529
531
Object . defineProperties = function ( obj , props ) {
@@ -533,6 +535,15 @@ Zone.patchDefineProperty = function () {
533
535
return obj ;
534
536
} ;
535
537
538
+ Object . create = function ( obj , proto ) {
539
+ if ( typeof proto === 'object' ) {
540
+ Object . keys ( proto ) . forEach ( function ( prop ) {
541
+ proto [ prop ] = rewriteDescriptor ( obj , prop , proto [ prop ] ) ;
542
+ } ) ;
543
+ }
544
+ return _create ( obj , proto ) ;
545
+ } ;
546
+
536
547
Object . getOwnPropertyDescriptor = function ( obj , prop ) {
537
548
var desc = _getOwnPropertyDescriptor ( obj , prop ) ;
538
549
if ( isUnconfigurable ( obj , prop ) ) {
@@ -542,24 +553,23 @@ Zone.patchDefineProperty = function () {
542
553
} ;
543
554
544
555
Zone . _redefineProperty = function ( obj , prop , desc ) {
545
- return rewriteDescriptor ( obj , prop , desc ) ;
556
+ desc = rewriteDescriptor ( obj , prop , desc ) ;
557
+ return _defineProperty ( obj , prop , desc ) ;
546
558
} ;
547
559
548
560
function isUnconfigurable ( obj , prop ) {
549
561
return obj && obj . __unconfigurables && obj . __unconfigurables [ prop ] ;
550
562
}
551
563
552
564
function rewriteDescriptor ( obj , prop , desc ) {
565
+ desc . configurable = true ;
553
566
if ( ! desc . configurable ) {
554
- desc . configurable = true ;
555
567
if ( ! obj . __unconfigurables ) {
556
- _defineProperty ( obj , '__unconfigurables' , {
557
- value : { }
558
- } ) ;
568
+ _defineProperty ( obj , '__unconfigurables' , { writable : true , value : { } } ) ;
559
569
}
560
570
obj . __unconfigurables [ prop ] = true ;
561
571
}
562
- return _defineProperty ( obj , prop , desc ) ;
572
+ return desc ;
563
573
}
564
574
} ;
565
575
0 commit comments