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 @@ -1177,7 +1177,6 @@ const Zone: ZoneType = (function(global: any) {
11771177 type : this . type ,
11781178 state : this . state ,
11791179 source : this . source ,
1180- data : this . data ,
11811180 zone : this . zone . name ,
11821181 invoke : this . invoke ,
11831182 scheduleFn : this . scheduleFn ,
Original file line number Diff line number Diff line change @@ -312,6 +312,32 @@ describe('Zone', function() {
312312 } ) ;
313313 } ) ;
314314 } ) ;
315+
316+ it ( 'should be able to covert element with event listener to json without cyclic error' ,
317+ function ( ) {
318+ const eventListenerSpy = jasmine . createSpy ( 'eventListener' ) ;
319+ let elemThrowErrorWhenToJson = false ;
320+ try {
321+ JSON . stringify ( button ) ;
322+ } catch ( err ) {
323+ elemThrowErrorWhenToJson = true ;
324+ }
325+
326+ // in chrome mobile, dom element will throw
327+ // cyclic error when call JSON.stringify,
328+ // so we just ignore it.
329+ if ( elemThrowErrorWhenToJson ) {
330+ return ;
331+ }
332+
333+ Zone . current . run ( function ( ) {
334+ button . addEventListener ( 'click' , eventListenerSpy ) ;
335+ } ) ;
336+
337+ expect ( function ( ) {
338+ JSON . stringify ( button ) ;
339+ } ) . not . toThrow ( ) ;
340+ } ) ;
315341 } ) ;
316342 } ) ;
317343} ) ;
You can’t perform that action at this time.
0 commit comments