{"action":"created","issue":{"url":"https://api.github.com/repos/angular/zone.js/issues/323","repository_url":"https://api.github.com/repos/angular/zone.js","labels_url":"https://api.github.com/repos/angular/zone.js/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/angular/zone.js/issues/323/comments","events_url":"https://api.github.com/repos/angular/zone.js/issues/323/events","html_url":"https://github.com/angular/zone.js/issues/323","id":148224700,"number":323,"title":"Cordova pause event error from a null target","user":{"login":"adamdbradley","id":452425,"avatar_url":"https://avatars.githubusercontent.com/u/452425?v=3","gravatar_id":"","url":"https://api.github.com/users/adamdbradley","html_url":"https://github.com/adamdbradley","followers_url":"https://api.github.com/users/adamdbradley/followers","following_url":"https://api.github.com/users/adamdbradley/following{/other_user}","gists_url":"https://api.github.com/users/adamdbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/adamdbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamdbradley/subscriptions","organizations_url":"https://api.github.com/users/adamdbradley/orgs","repos_url":"https://api.github.com/users/adamdbradley/repos","events_url":"https://api.github.com/users/adamdbradley/events{/privacy}","received_events_url":"https://api.github.com/users/adamdbradley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"juliemr","id":2081709,"avatar_url":"https://avatars.githubusercontent.com/u/2081709?v=3","gravatar_id":"","url":"https://api.github.com/users/juliemr","html_url":"https://github.com/juliemr","followers_url":"https://api.github.com/users/juliemr/followers","following_url":"https://api.github.com/users/juliemr/following{/other_user}","gists_url":"https://api.github.com/users/juliemr/gists{/gist_id}","starred_url":"https://api.github.com/users/juliemr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliemr/subscriptions","organizations_url":"https://api.github.com/users/juliemr/orgs","repos_url":"https://api.github.com/users/juliemr/repos","events_url":"https://api.github.com/users/juliemr/events{/privacy}","received_events_url":"https://api.github.com/users/juliemr/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-04-14T01:21:28Z","updated_at":"2016-04-18T03:15:23Z","closed_at":null,"body":"Cordova fires a `pause` event when the app is put into the background, but this error is thrown from within `patchViaCapturingAllTheEvents()`:\r\n![image](https://cloud.githubusercontent.com/assets/452425/14514195/2745ffaa-01b4-11e6-80d5-89f9d07eca25.png)\r\n\r\nIt looks as though `event.target` is `null`:\r\n![image](https://cloud.githubusercontent.com/assets/452425/14514226/5e29da1e-01b4-11e6-92b4-64c6eca56fe4.png)\r\n\r\nThis only happens on Cordova's `pause` event, but is not a problem with the others:\r\nhttps://cordova.apache.org/docs/en/latest/cordova/events/events.html#pause"},"comment":{"url":"https://api.github.com/repos/angular/zone.js/issues/comments/211169887","html_url":"https://github.com/angular/zone.js/issues/323#issuecomment-211169887","issue_url":"https://api.github.com/repos/angular/zone.js/issues/323","id":211169887,"user":{"login":"adamdbradley","id":452425,"avatar_url":"https://avatars.githubusercontent.com/u/452425?v=3","gravatar_id":"","url":"https://api.github.com/users/adamdbradley","html_url":"https://github.com/adamdbradley","followers_url":"https://api.github.com/users/adamdbradley/followers","following_url":"https://api.github.com/users/adamdbradley/following{/other_user}","gists_url":"https://api.github.com/users/adamdbradley/gists{/gist_id}","starred_url":"https://api.github.com/users/adamdbradley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamdbradley/subscriptions","organizations_url":"https://api.github.com/users/adamdbradley/orgs","repos_url":"https://api.github.com/users/adamdbradley/repos","events_url":"https://api.github.com/users/adamdbradley/events{/privacy}","received_events_url":"https://api.github.com/users/adamdbradley/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T03:15:23Z","updated_at":"2016-04-18T03:15:23Z","body":"@juliemr I dug through cordova and it looks like the `pause` event ultimately [calls fireDocumentEvent](https://github.com/apache/cordova-js/blob/c517ca811b4948b630e0b74dbae6c9637939da24/src/cordova.js#L138)\r\n\r\nInside fireDocumentEvent it then uses the [createEvent method](https://github.com/apache/cordova-js/blob/c517ca811b4948b630e0b74dbae6c9637939da24/src/cordova.js#L86)\r\n\r\nNext, it passes the created `evt` to [documentEventHandlers[type].fire(evt)](https://github.com/apache/cordova-js/blob/c517ca811b4948b630e0b74dbae6c9637939da24/src/cordova.js#L141) \r\n\r\nWhich is cordova's [Channel.prototype.fire](https://github.com/apache/cordova-js/blob/24ab6855470f2dc0662624b597c98585e56a1666/src/common/channel.js#L198)\r\n\r\nThe `fireArgs` variable from within `Channel.prototype.fire` has the `null` `target`: \r\n![image](https://cloud.githubusercontent.com/assets/452425/14592783/0da37fa0-04e8-11e6-942b-2d6c80d333e7.png)\r\n\r\n`Channel.prototype.fire` then creates and [runs each function](https://github.com/apache/cordova-js/blob/24ab6855470f2dc0662624b597c98585e56a1666/src/common/channel.js#L214) in the `toCall` array:\r\n![image](https://cloud.githubusercontent.com/assets/452425/14592821/8d2e4b92-04e8-11e6-86a7-310f9be3e80e.png)\r\n\r\nOne of them being the callback created from within zone's `patchViaCapturingAllTheEvents()`. \r\n\r\nSorry I'm not able to provide an explanation as to why cordova is calling these events like this, but hopefully this can help document where the issues are coming from, and hopefully help to create tests. Hope that helps, thanks.\r\n\r\n"}}