 
       element = new Image()
 
-      element.onload = =>
+      addHandler element, 'load', =>
         if cid is @current
           @images[cid].width  = element.width
           @images[cid].height = element.height

      history.pushState null, null, '#' if isHistory

      if @options.thumbnails
        @thumbnails.html ''
        $(@overlay.querySelector('.choco-thumbnails-toggle')).off 'click'

      $(window).off 'resize'

isHistory = not not (window.history and history.pushState)
isStorage = 'localStorage' of window and window['localStorage']?
isIE8     = document.documentMode? and document.documentMode is 8

class Chocolate
  images: {}
