Skip to content

Commit

Permalink
Fixed an exception when xhr is null
Browse files Browse the repository at this point in the history
Close #39
  • Loading branch information
estum committed Sep 23, 2016
1 parent 4de82b7 commit 07450b1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/assets/javascripts/growlyflash/listener.coffee
Expand Up @@ -33,14 +33,15 @@ class Listener
@stack ?= new Stack()
@process_static() if window.flashes?
($ context).on Growlyflash.Listener.EVENTS, (event, xhr) =>
xhr ?= event.data?.xhr
source = process_from_header(xhr.getResponseHeader(Growlyflash.Listener.HEADER))
@stack.push_only_fresh source
if xhr ?= event.data?.xhr
source = process_from_header(xhr.getResponseHeader(Growlyflash.Listener.HEADER))
@stack.push_only_fresh source
return

process_static: ->
@stack.push alert for alert in process(window.flashes)
delete window.flashes

@Growlyflash.Listener = Listener
@Growlyflash.listen_on = (context) ->
@listener ?= new @Listener(context)
@listener ?= new @Listener(context)

0 comments on commit 07450b1

Please sign in to comment.