@@ -1500,23 +1500,27 @@ function patchClass(className) {
1500
1500
if ( ! OriginalClass ) return ;
1501
1501
1502
1502
global [ className ] = function ( fn ) {
1503
- this . _o = new OriginalClass ( zone . bind ( fn , true ) ) ;
1503
+ this . _o = new OriginalClass ( global . zone . bind ( fn , true ) ) ;
1504
+ // Remember where the class was instantiate to execute the enqueueTask and dequeueTask hooks
1505
+ this . _creationZone = global . zone ;
1504
1506
} ;
1505
1507
1506
1508
var instance = new OriginalClass ( function ( ) { } ) ;
1507
1509
1508
1510
global [ className ] . prototype . disconnect = function ( ) {
1509
1511
var result = this . _o . disconnect . apply ( this . _o , arguments ) ;
1510
- this . _active && global . zone . dequeueTask ( ) ;
1511
- this . _active = false ;
1512
+ if ( this . _active ) {
1513
+ this . _creationZone . dequeueTask ( ) ;
1514
+ this . _active = false ;
1515
+ }
1512
1516
return result ;
1513
1517
} ;
1514
1518
1515
1519
global [ className ] . prototype . observe = function ( ) {
1516
1520
if ( ! this . _active ) {
1517
- global . zone . enqueueTask ( ) ;
1521
+ this . _creationZone . enqueueTask ( ) ;
1522
+ this . _active = true ;
1518
1523
}
1519
- this . _active = true ;
1520
1524
return this . _o . observe . apply ( this . _o , arguments ) ;
1521
1525
} ;
1522
1526
@@ -1534,7 +1538,7 @@ function patchClass(className) {
1534
1538
Object . defineProperty ( global [ className ] . prototype , prop , {
1535
1539
set : function ( fn ) {
1536
1540
if ( typeof fn === 'function' ) {
1537
- this . _o [ prop ] = zone . bind ( fn ) ;
1541
+ this . _o [ prop ] = global . zone . bind ( fn ) ;
1538
1542
} else {
1539
1543
this . _o [ prop ] = fn ;
1540
1544
}
0 commit comments