This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -359,6 +359,41 @@ describe('Zone.patch', function () {
359359 } ) ;
360360 } ) ;
361361
362+ describe ( 'WebKitMutationObserver' , function ( ) {
363+ it ( 'should work' , function ( ) {
364+ if ( ! window . WebKitMutationObserver ) {
365+ console . log ( 'WARNING: skipping WebKitMutationObserver test (missing this API)' ) ;
366+ return ;
367+ }
368+
369+ var flag = false ,
370+ elt = document . createElement ( 'div' ) ,
371+ hasParent ;
372+
373+ runs ( function ( ) {
374+ var ob = new WebKitMutationObserver ( function ( ) {
375+ hasParent = ! ! window . zone . parent ;
376+ flag = true ;
377+ } ) ;
378+
379+ ob . observe ( elt , {
380+ childList : true
381+ } ) ;
382+
383+ elt . innerHTML = '<p>hey</p>' ;
384+ } ) ;
385+
386+ waitsFor ( function ( ) {
387+ return flag ;
388+ } , 'mutation observer to fire' , 100 ) ;
389+
390+ runs ( function ( ) {
391+ expect ( hasParent ) . toBe ( true ) ;
392+ } ) ;
393+
394+ } ) ;
395+ } ) ;
396+
362397 describe ( 'XMLHttpRequest' , function ( ) {
363398
364399 it ( 'should work with onreadystatechange' , function ( ) {
Original file line number Diff line number Diff line change @@ -267,9 +267,8 @@ Zone.patch = function patch () {
267267 'catch'
268268 ] ) ;
269269 }
270- if ( window . MutationObserver ) {
271- Zone . patchClass ( 'MutationObserver' ) ;
272- }
270+ Zone . patchClass ( 'MutationObserver' ) ;
271+ Zone . patchClass ( 'WebKitMutationObserver' ) ;
273272} ;
274273
275274//
@@ -333,7 +332,7 @@ Zone.patchClass = function (className) {
333332 }
334333 } ;
335334
336- var instance = new OriginalClass ( className === 'MutationObserver' ? function ( ) { } : undefined ) ;
335+ var instance = new OriginalClass ( className . substr ( - 16 ) === 'MutationObserver' ? function ( ) { } : undefined ) ;
337336
338337 var prop ;
339338 for ( prop in instance ) {
You can’t perform that action at this time.
0 commit comments